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
SALUS THERMOSTAT Custom component for Home-Assistant

Home-Assistant Custom Components Custom Components for Home-Assistant (http://www.home-assistant.io) Salus Thermostat Climate Component My device is R

21 Dec 18, 2022
Automatic CPU speed & power optimizer for Linux

Automatic CPU speed & power optimizer for Linux based on active monitoring of laptop's battery state, CPU usage, CPU temperature and system load. Ultimately allowing you to improve battery life witho

Adnan Hodzic 3.4k Jan 07, 2023
A simple Picobot project implemented in Python

Python-Picobot A simple Picobot project implemented in Python About Explanation This is my first programming project. Picobot use rules.txt file which

Shayan Shiravani 0 Apr 03, 2022
Jarvis: a personal assistant which can help you to manage your system

Jarvis Jarvis is personal AI based assistant which can help you to manage stuff in your computer. This is demo but I decided to make it more better so

2 Jun 02, 2022
It is a program that displays the current temperature of the GPU and CPU in real time and stores the temperature history.

HWLogger It is a program that displays the current temperature of the GPU and CPU in real time and stores the temperature history. Sample Usage Run HW

Xeros 0 Apr 05, 2022
[unmaintained] WiFi tools for linux

Note: This project is unmaintained. While I would love to keep up the development on this project, it is difficult for me for several reasons: I don't

Rocky Meza 288 Dec 13, 2022
Unofficial Playdate reverse-engineering notes/tools - covers file formats, server API and USB commands

Unofficial Playdate reverse-engineering notes/tools - covers file formats, server API and USB commands ⚠️ This documentation is unofficial and is not

James 106 Dec 31, 2022
ok-system-helper是一个简单的系统硬件的实时信息收集工具,使用python3.x开发

ok-system-helper ok-system-helper是一个简单的系统硬件的实时信息收集工具,使用python3.x开发,支持哪些硬件:CPU、内存、SWAP、磁盘、网卡流量。用户可在自己的项目中直接引入、开箱即用,或者结合flask等web框架轻松做成http接口供前端调用,亦可通过注

xlvchao 1 Feb 08, 2022
Open-Source board for converting RaspberryPI to Brain-computer interface

The easiest way to the neuroscience world with the shield for RaspberryPi - PIEEG (website). Open-source. Crowdsupply This project is the result of se

Ildaron 436 Jan 01, 2023
CircuitPython library for the CH559 USB to Serial chip

CH559 (USB to Serial) CircuitPython Library Why? Because you might want to get keyboard/mouse/gamepad/HID input into your CircuitPython projects witho

Guy Dupont 3 Nov 19, 2022
Python information display framework aimed at e-ink devices

My display, using a Raspberry Pi Zero W and Waveshare 6" e-paper hat infodisplay Modular information display framework aimed at e-ink devices. Built u

Niek Blankers 3 Apr 08, 2022
Setup DevTerm to be a cool non-GUI device

DevTerm hobby project I bought this amazing device: DevTerm A-0604. It has a beefy ARM processor, runs a custom version of Armbian, embraces Open Sour

Alex Shteinikov 9 Nov 17, 2022
MicroPython driver for 74HC595 shift registers

MicroPython 74HC595 A MicroPython library for 74HC595 8-bit shift registers. There's both an SPI version and a bit-bang version, each with a slightly

Mike Causer 17 Nov 29, 2022
MPY tool - manage files on devices running MicroPython

mpytool MPY tool - manage files on devices running MicroPython It is an alternative to ampy Target of this project is to make more clean code, faster,

Pavel Revak 5 Aug 17, 2022
Monorepo for my Raspberry Pi dashboard and GPS satellite listener.

🥧 pi dashboard My blog post: Listening to Satellites with my Raspberry Pi This is the monorepo for my Raspberry Pi dashboard!

Andrew Healey 27 Jun 08, 2022
Rasberry Pie GPIO memory game. Press the corresponding key to the lit LED.

RPie-keyboard-game Rasberry Pie GPIO memory game. Press the corresponding key to the lit LED. Randem LED (general output) is lit up on rasberrypi rand

Shawn Dowling 1 Oct 24, 2021
This Home Assistant custom component adding support for controlling Midea dehumidifiers on local network.

This custom component for Home Assistant adds support for Midea air conditioner and dehumidifier appliances via the local area network. homeassistant-

Nenad Bogojevic 92 Dec 31, 2022
Code reimplementation of some papers published in SAIL-Lab

SAIL SAIL-Lab统一代码库 Motivation 创建这个项目的动机最早来源于实验室组内成员相互Debug代码的时候遇到的麻烦。

Jianwen Chen 8 Nov 15, 2022
Component for deep integration LedFx from Home Assistant.

LedFX for Home Assistant Component for deep integration LedFx from Home Assistant. Table of Contents FAQ Install Config Performance FAQ Q. What versio

Dmitry Mamontov 28 Dec 13, 2022
Watson-Assistant with integration capabilities

Watson-Assistant-Integration Watson-Assistant with integration capabilities "main.py" should be deployed as Cloud Function (Action) on IBM Cloud. For

Sergey Usachev 1 Dec 20, 2021