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
A Home Assistant integration for Solaredge inverters

A Home Assistant integration for Solaredge inverters. Supports multiple inverters chained through RS485.

Seth 50 Dec 23, 2022
Python library to manipulate Ingenico mobile payment device like iCT220 or iWL220 equipped with Telium Manager. RS232/USB.

Python library to manipulate Ingenico mobile payment device like iCT220 or iWL220 equipped with Telium Manager. RS232/USB.

TAHRI Ahmed R. 72 Dec 24, 2022
Raspberry Pi Pico support for VS Code

Pico-Go VS Code Extension Pico-Go provides code auto-completion and allows you to communicate with your Raspberry Pi Pico board using the built-in REP

Chris Wood 114 Dec 28, 2022
Pure micropython ESP32 SPI driver for sdcard and screen at the same SPI bus

micropython-esp32-spi-sdcard-and-screen-driver Proof of concept of Pure micropython espidf SPI driver for sdcard with screen at the same SPI bus (exam

Thomas Favennec 7 Mar 14, 2022
Andreas Frisch 1 Jan 10, 2022
A DiY holiday project to demonstrate how you can send data from adafruitIO cloud to a balena edge device

holiday-star balena ❤️ adafruitIO Introduction A DiY holiday project to demonstrate how you can send data from adafruitIO cloud to a balena edge devic

Ayan Pahwa 3 Dec 20, 2021
Sensor of Temperature Feels Like for Home Assistant.

Please ⭐ this repo if you find it useful Sensor of Temperature Feels Like for Home Assistant Installation Install from HACS (recommended) Have HACS in

Andrey 60 Dec 25, 2022
Transform a Raspberry Pi into a network diagnostic machine.

EtherView Last updated jan 30, 2022. Welcome to the EtherView project! This is a project to transform a RaspberryPi into a portable network diagnostic

1 Jan 30, 2022
Technical Answers to Real-World Problems. Evolution of Watering Manually to Watering Automatically.

Automatic Watering System using Soil Moisture Sensor and RTC Timer with Arduino Technical Answers to Real-World Problems Know the plant, Grow the plan

NelakurthiSudheer 3 Jan 03, 2022
The software that powers the sPot: a 4th generation

This code is meant to accompany this project in which a Spotify client is built into an iPod "Classic" from 2004. Everything is meant to run on a Raspberry Pi Zero W.

Guy Dupont 683 Dec 28, 2022
Code and build instructions for Snap, a simple Raspberry Pi and LED machine to show you how expensive the electricyty is at the moment

Code and build instructions for Snap, a simple Raspberry Pi and LED machine to show you how expensive the electricyty is at the moment. On row of LEDs shows the cost of the hour, the other row the co

Johan Jonk Stenström 3 Sep 08, 2022
Programmable Rainbow Redstone Computer

Programmable Rainbow Redstone Computer Table of contents What is it? Program flasher How to use it What is it? PRRC is Programmable Rainbow Redstone C

Fern H 2 Jun 07, 2022
It is a serial communicator(controller, receiver...), communicate with sensor LP20 which is a laser ranger.

Intro It is a serial communicator(controller, receiver...), communicate with sensor LP20 which is a laser ranger. Its datasheet is contained in this r

3 Sep 19, 2022
A python script for macOS to enable scrolling with the 3M ergonomic mouse EM500GPS in any application.

A python script for macOS to enable scrolling with the 3M ergonomic mouse EM500GPS in any application.

3 Feb 19, 2022
Intel Realsense t265 into Unreal Engine

t265_UE Intel Realsense t265 into Unreal Engine. Windows only, and Livelink plugin is 4.26.2 only at the moment. Might recompile it for different vers

Bjarke Aagaard 30 Jan 02, 2023
2021 Real Robot Challenge Phase2 attemp

Real_Robot_Challenge_Phase2_AE_attemp We(team name:thriftysnipe) are the first place winner of Phase1 in 2021 Real Robot Challenge. Please see this pa

Qiang Wang 2 Nov 15, 2021
PBA: Pleco Breeding Assistant

A small monitor that reports the external, fishroom and water change parameters to have suitable water parameters and induce breeding. These two features already represent 50% of the "reproductive su

Mirko Mancin 1 Jan 19, 2022
This Home Assistant custom component adds support for controlling Midea dehumidiferes on local network.

This is a custom component for Home assistant that adds support for Midea dehumidifier appliances via the local area network. midea-dehumidifier-lan H

Nenad Bogojevic 97 Jan 08, 2023
Resmed_myair_sensors - This is a Home Assistant custom component to pull daily CPAP data from ResMed's myAir service using an undocumented API

resmed_myair This component will set up the following platforms. Platform Description sensor Show info from the myAir API. Installation Using the tool

Preston Tamkin 17 Dec 29, 2022
circuitpython version of PyBasic for microcontrollers

cPyBasic Circuitpython version of PyBasic for microcontrollers Current version work only for Adafruit titano & CardKB for now. The origninal PyBasic w

BeBoXoS 3 Nov 14, 2021