Control and mointor an ESP32 over serial
Project description
ESPCTL
your ESP32 controllable from Python and your browser. No install, no cloud, 100% locally on your machine add one line to your firmware and get a live data + control panel
espctl is an arduino header only library for esp32 along with a python package and web serial browser client which are connected by a shared line based serial protocol ( read below for more info about the espctl protocol)
the python package could be used to colled data frames via pandas and matplotlib to plot the live graphs along with regular CRUD operations
Why ESPCTL?
reflashing your board each time and waiting for arduino to compile everything??
trying to mentally plot a wall of Serial.println numbers. and nobody needs an account or cloud dashboard to drag a slider on a project that's liteterally six inches from their laptop plugged into the same usb cable
ESPCTL fixes all of that with one header file. You declare your controls in firmware, plug in, and a live plot + working widgets just show up in Python, in your browser, whatever. No setup, no cap.
Features
- easy one line setup -
#include "espctl.h" - auto generated web ui
- easy native python access - widgets are plain attributes:
board.threshold = 120 - data logging - record data into a csv or pull a pandas DataFrame
- live plotting - matplotlib for live plots of data
- gpio read/write - access gpio directly without tweaking the firware
- browser flashing - flash your mcu directly from the browser
Quick Start
1. Arduino library
copy firmware/espctl.h to your sketch and:
#include "espctl.h"
ESPCtl board;
void setup(){
board.begin() // serial @ 921600 baud
board.addSlider("threshold", 0, 255, 100)
board.addToggle("ledOn", true);
board.addValue("bpm");
}
void loop(){
board.data("bpm", readBPM());
int t = board.getSlider("threshold");
board.update // MUST BE CALLED EVERY LOOP
}
you can also refer to examples/blink.ino for a working sketch
2. Python client
pip install espctl
from espctl import ESPCtl
import time
board = ESPCtl()
print(board.bpm) #write
board.threshold = 120 #read
with board.record("session.csv"):
time.sleep(60)
df = board.to_df() # pandas df
board.plot("bpm") # matplotlive
3. Web client
open web/index.html and use it directly to connect to the board
espctl protocol:
all msg are new lines over serial - baud 921600
firmware to client
Schema sent on boot
$S{"widgets":[{"id":"bpm","type":"value"},
{"id":"threshold", "type":"slider","min":0,"max":255,"value":100}]}
data update
$D<id>,<value>
pin state
$R<pin>,<state>
anything without "$"
normal log
client to firmware
? -> request schema
!<id>,<value> -> set a widget
><pin>,<0|1> -> write GPIO
<<pin> -> read GPIO
Contributing
Issues and PRs welcome. Good first contributions: testing on more ESP32 dev boards and reporting port detection quirks, imporving error messages, add more example sketches, add more widgets
Scope (v0.1)
Supported: ESP32(classic) only Widgets - slider, toggle, and value Live plots - only 1
future plans (v0.2)
other chips - esp8266, S3, C3 more widgets multi plot
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file espctl-0.1.1.tar.gz.
File metadata
- Download URL: espctl-0.1.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8d4d90c3ce831ffe267a54533ef98ed109c3839259e221b251ecd1dffc7caaa
|
|
| MD5 |
d005026772f998a0f2ae2e94bb230aeb
|
|
| BLAKE2b-256 |
37dadc301730e7f555ba34172acfe4a68690873c3204c9f9f215221aa3fce437
|
File details
Details for the file espctl-0.1.1-py3-none-any.whl.
File metadata
- Download URL: espctl-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6887a8fe326e2bd52da116c8d5f19d8a0f8d1f1085234ec7790814ce993ef2ec
|
|
| MD5 |
eab745d60e0576f5dd61f1dddcfe40a0
|
|
| BLAKE2b-256 |
f613436bc8ffb2111fdfd29812d076b339b92be7cf6e6b9616220037f6607a58
|