ESP32 recording button presses, and serving webpage that graphs the numbers over time.

Overview

ESP32-IoT-button-graph-test

ESP32 recording button presses, and serving webpage via webSockets in order to graph the responses. The objective was to test the ESP32 webSocket implementation written in microPython.

To implement, upload firmware.bin to ESP32-dev board

copy all *.py files and *.html/js to ESP32 root directory.

connect two buttons, each with pull up resistors (1 KOhm), on pins 18 and 19

Pin 19 keeps track of fastCountPin, i.o.w. high freq pulses.

Pin 18 keeps track of slowCountPin, i.o.w. low freq pulses (acts like a reset button to Pin 19 counter).


Used : WebSocket libs jczic / MicroWebSrv2

Firmware was compiled from scratch in order to accomodate Websocket MicroPython Server files into 4MB flash memory.

Need to find the website that showed me howto compile ESP32 firmware in Linux Mint (Was not an easy task. Lots of trial and error).

boot.py :	

starts the show Need to enable which Wifi script to run --- AccessPoint or local Wifi network Next enable the pulse_detector.py script, which starts the button press detection

pulse_detector.py

initiates PIN properties, init's webSocket server, increases pin counter, prepares JSON packet and transmits client endpoint
also outputs to terminal: access via screen /dev/ttyUSB0 115200 JSON Packet msgJson = {} msgJson['slowCounter'] = slowCounter msgJson['fastCounter'] = fastCounter msgJson['timeDiff'] = str(time_diff_ms) msgJson['timeDiff_units'] = "ms" msgJson['timeT0'] = str(time_t0) msgArr.append(msgJson)

ws_server.py

serves HTML / CSS and javascript files creates / server endpoints for each js,html, css file

ws_index.html

call JS scripts : moment.min.js ( datetime libs ); Chart.min.js ( Chart libs in HTML5 )

The following snippet creates a webSocket instance. The downside, is that the connection disconnects, but doesn't reconnect, if no activity detected.

counter) { console.log(msgJson.timeDiff); } pulses_dataValuesArr.push(msgJson.fastCounter); pulses_datalabelStructure.push(counter); timing_dataValuesArr.push(msgJson.timeDiff); timing_datalabelStructure.push(counter); chartPulses.update(); chartTiming.update(); counter += 1; // }; ws.onclose = function(evt) { console.log("Connection closed."); }; ws.closeConn = () => { ws.close(); } } ">
        function startingWS ()
        {
            ws = new WebSocket("ws://" + window.location.hostname);

            ws.onopen = function(evt) { 
              console.log("Connection open ..."); 
              ws.send("Hello WebSockets!");
            };

            ws.onmessage = function(evt) {
              console.log( "Received Message: " + evt.data);
              msgJson = JSON.parse(evt.data);
              if(msgJson.slowCounter > counter)
              {
                console.log(msgJson.timeDiff);
              }
              pulses_dataValuesArr.push(msgJson.fastCounter);
              pulses_datalabelStructure.push(counter);

              timing_dataValuesArr.push(msgJson.timeDiff);
              timing_datalabelStructure.push(counter);

            chartPulses.update();
            chartTiming.update();

              counter += 1;
              //
            };

            ws.onclose = function(evt) {
              console.log("Connection closed.");
            };

            ws.closeConn = () => {
                ws.close();
            }
        }
Owner
f-caro
I like Linux, embedded systems programming... My style is break-it-as-you-make-it...
f-caro
Control the lights of Alienware computers under GNU/Linux systems.

Before requesting support please consider that this software is not actively developed. I created it in 2014 for managing my Alienware M14X-R1 (where

rsm 111 Dec 05, 2022
Samples for robotics, node, python, and bash

RaspberryPi Robot Project Technologies: Render: intent Currently designed to act as programmable sentry.

Martin George 1 May 31, 2022
Event-based hardware simulation framework

An event-based multi-device simulation framework providing configuration and orchestration of complex multi-device simulations.

Diamond Light Source Controls Group 3 Feb 01, 2022
Repo for the esp32s2 version of the Wi-Fi Nugget

Repo for the esp32s2 version of the Wi-Fi Nugget

HakCat 30 Nov 05, 2022
Raspberry Pi Spectrometer

PySpectrometer 2021-03-05 Raspberry Pi Spectrometer The PySpectrometer is a Python (OpenCV and Tkinter) implementation of an optical spectrometer. The

Les Wright 538 Jan 05, 2023
Open source home automation that puts local control and privacy first.

Home Assistant Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiast

Home Assistant 57k Jan 01, 2023
Simple Weather Check base on Hefeng api, Work on raspberry Pi

Simple Weather Check base on Hefeng api, Work on raspberry Pi

Retr0mous 28 Sep 17, 2022
Various programs in Atari BASIC for #FujiNet for Atari 8-bit

FujiNet Various programs in Atari BASIC for #FujiNet for Atari 8-bit FujiNet-3D Tic Tac Toe In 1978, Scott Adams wrote a 3-D Tic Tac Toe game, for pla

Kay Savetz 2 Jan 01, 2022
Интеграция Home Assistant с ЛК "Интер РАО"

ЕЛК ЖКХ «Интер РАО» для Home Assistant Предоставление информации о текущем состоянии ваших аккаунтов в ЕЛК ЖКХ. Введение @ TODO @ Установка Посредство

Alexander Ryazanov 27 Nov 05, 2022
A PYTHON Library for Controlling Motors using SOLO Motor Controllers with RASPBERRY PI, Linux, windows, and more!

A PYTHON Library for Controlling Motors using SOLO Motor Controllers with RASPBERRY PI, Linux, windows, and more!

SOLO Motor Controllers 3 Apr 29, 2022
This is an incredible led matrix simulation using the ultimate mosaik co-simulation framework.

This project uses the mosaik co-simulation framework, developed by the brilliant developers at the high-ranked Offis institue for computer science, Oldenburg, Germany, to simulate multidimensional LE

Felix 1 Jan 28, 2022
A ch341dll Wrap is for using in Python 32bits windows to access I2C SPI and MDIO (by GPIO), and Demo with display PC sreen on OLED by i2c or SPI .

ch341dll_wrap_typcal_app A ch341dll Wrap is for using in Python 32bits windows to access I2C SPI and MDIO (by GPIO). In addition, I provided 3 Demo. I

13 Jan 02, 2023
A Fast, Easy, and User Friendly way to control Robotics Actuators.

T-Motor Controller A Fast, Easy, and User Friendly way to control Robotics Actuators. View Demo · Report Bug · Request Feature Table of Contents About

26 Aug 23, 2022
Scripts for measuring and displaying thermal behavior on Voron 3D printers

Thermal Profiling Measuring gantry deflection and frame expansion This script runs a series of defined homing and probing routines designed to charact

Jon Sanders 30 Nov 27, 2022
Yet another automation project because a smart light is more than just on or off.

Automate home Yet another home automation project because a smart light is more than just on or off. Overview When talking about home automation there

Maja Massarini 62 Oct 10, 2022
ROS2 nodes for Waveshare Alphabot2-Pi mobile robot.

ROS2 for Waveshare Alphabot2-Pi This repo contains ROS2 packages for the Waveshare Alphabot2-Pi mobile robot: alphabot2: it contains the nodes used to

Michele Rizzo 2 Oct 11, 2022
Segger Embedded Studio project for building & debugging Flipper Zero firmware.

Segger Embedded Studio project for Flipper Zero firmware Установка Добавить данный репозиторий в качестве сабмодуля в корень локальной копии репозитор

25 Dec 28, 2022
Automate gate/garage door opening via 433.92MHz emitter with Raspberry Pi, Home Assistant and Homekit.

Automate opening your garage door / gate Summary This project sums up how I automated opening my garage door using a Raspberry PI, a 433Mhz emitter, H

Julien Fouilhé 29 Nov 30, 2022
A 3rd party Moonraker component to create timelapse of 3D prints.

A 3rd party Moonraker component to create timelapse of 3D prints.

Mainsail-Crew 166 Dec 26, 2022
Micro Displays for Raspberry Pi

micro-displays Micro Displays for Raspberry Pi Why? I'm super bored in lockdown. Add a Raspberry Pi 400 and a few tiny displays... The top half of the

ig 291 Jul 06, 2022