Espmpui for ESP32-S2
An ESP32 display project for ESP32-S2.
Parts and sourceBefore you start
Confirm board compatibility and supported firmware targets in the upstream documentation.
Upstream README
espmpui: Reactive Web Micro-Framework & Device Management Toolkit for MicroPython
A zero-dependency reactive micro-framework and device management toolkit that brings app-like web dashboards, mobile Wi-Fi captive portals, persistent configuration, and OTA updating to your ESP32 or Pico W in under 15 lines of pure Python.
espmpui is an ultra-lightweight, zero-dependency reactive web micro-framework and device management toolkit for MicroPython (ESP32, ESP32-S2/S3, ESP32-C3/C6, and Raspberry Pi Pico W).
It pairs a declarative Python API with a pre-gzipped, CDN-free embedded frontend (~13.2 KB) synchronized in real-time over WebSockets.
π· View More Screenshots (Heap Telemetry & Diagnostics)
Memory & GC Tracking
Live Telemetry & Terminal Stream
β‘ Why espmpui?
Building web interfaces for microcontrollers usually means wrestling with raw socket strings, 1995-style HTML forms, or heavy Node/npm pipelines that exhaust microcontroller memory.
espmpui provides a complete, modern embedded device interface out-of-the-box:
- No Frontend Toolchain Needed: Zero
npmbuilds, Webpack configs, or CDN dependencies. The single-page app (~13.2 KB) is served straight from device flash. - Two-Way Reactive Sync: State changes update connected web clients in real-time via compact (~35 byte) WebSocket diffs.
- Low Memory Footprint: Operates within
< 8 KB RAMoverhead and< 4 KB RAMduring OTA updates. Built specifically for constrained microcontrollers. - Fault-Isolated Execution: User callback crashes are caught gracefully without breaking the
uasyncioserver loop. - Complete Hardware Lifecycle: Out-of-the-box Wi-Fi captive portal, persistent flash config store, real-time diagnostics, and drag-and-drop OTA firmware updating.
π How Does It Compare?
| Feature | espmpui |
Microdot / Picoweb | ESPHome / Tasmota | Blynk / Cloud IoT |
|---|---|---|---|---|
| Language | MicroPython | MicroPython | C++ / YAML | C++ / Python |
| Turnkey Modern UI | β Built-in (MUI style) | β Manual HTML/CSS | β Built-in | β App-based |
| Zero Frontend Tooling | β Pre-compiled (~13.2 KB) | β Build your own | β Pre-compiled | β Cloud setup |
| Local / Air-Gapped | β 100% Local | β Local | β Local | β Requires Cloud |
| Embeddable in Custom Code | β
Yes (import espmpui) |
β Yes | β Owns entire firmware | β οΈ Partial |
| Captive Portal + OTA Included | β Turnkey | β Manual implementation | β Built-in | β οΈ Paid / Complex |
| RAM Overhead | < 8 KB | < 10 KB | ~30β60 KB | ~20β40 KB |
π₯οΈ Hardware & Platform Support
| Target Platform | Status | Connection | Features Supported |
|---|---|---|---|
| ESP32 / ESP32-S2 / ESP32-S3 | β Tested | Wi-Fi / AP | Full suite (Captive Portal, Diagnostics, OTA Partition Switch) |
| ESP32-C3 / ESP32-C6 (RISC-V) | β Tested | Wi-Fi / AP | Full suite |
| Raspberry Pi Pico W | β Tested | Wi-Fi / AP | Full suite (OTA operates in filesystem write mode) |
| Desktop Simulation (macOS/Linux/Win) | β Tested | localhost:80 |
Full UI & Controls simulation (no hardware required) |
π Quick Start in 60 Seconds
Option A: Test on your Desktop (No Hardware Required)
You can test espmpui directly on your computer before plugging in a microcontroller:
git clone https://github.com/csseeker/espmpui.git
cd espmpui
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements-dev.txt
# Run the minimal controls demo locally
python examples/01_minimal_controls.py
Open http://localhost:80/ in your browser.
Option B: Deploy to a Physical ESP32 or Pico W
1. Install espmpui on your board
Method 1: Local Copy (Recommended β Offline & Instant)
make deploy
# Or via mpremote directly:
mpremote cp -r src/espmpui :lib/
Method 2: Install via mip
mpremote mip install github:csseeker/espmpui
(Or directly from your board's REPL over Wi-Fi: import mip; mip.install("github:csseeker/espmpui"))
[!TIP] macOS Note (
SSL: CERTIFICATE_VERIFY_FAILED): Ifmpremote mipfails with certificate verification errors on macOS (common with python.org installs), run:"/Applications/Python 3.13/Install Certificates.command" # Or inside your virtualenv: export SSL_CERT_FILE=$(python3 -m certifi)
2. Run your first dashboard
Save this as main.py on your ESP32:
import espmpui
from machine import Pin
import network
# 1. Connect to local Wi-Fi (or use espmpui's Captive Portal)
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("YOUR_WIFI_SSID", "YOUR_WIFI_PASSWORD")
led = Pin(2, Pin.OUT, value=0)
# 2. Build Dashboard
app = espmpui.App(title="ESP32 IoT Dashboard", theme="dark")
tab = app.tab("Controls", icon="sliders")
tab.switch("LED", value=False, on_change=lambda w, val: led.value(1 if val else 0))
tab.slider("Speed", min=0, max=100, step=5, value=25, unit="%", on_change=lambda w, val: print("Speed:", val))
tab.button("Pulse", accent="danger", on_click=lambda w: print("Pulse clicked!"))
# 3. Turnkey System Health Diagnostics & Web OTA Updater
app.enable_diagnostics()
app.enable_ota()
if __name__ == "__main__":
app.run(port=80)
Run it immediately:
mpremote run main.py
Check the serial console for your device IP and navigate to http://<ESP32_IP>:80/.
π§° Turnkey Features
| Feature | Description | Example |
|---|---|---|
| Core Widgets | Switches, range sliders, push buttons, metrics, and tab navigation. | 01_minimal_controls.py |
| Sensor Telemetry | Canvas sparkline charts, metrics, and live camera streaming (OV2640). | 02_sensor_telemetry.py |
| Wi-Fi Captive Portal | SoftAP + DNS interception (192.168.4.1) for painless mobile Wi-Fi onboarding. |
04_wifi_provisioner_portal.py |
| Persistent Config | Schema-driven form generator with atomic, corruption-proof /config.json saves. |
05_persistent_config_store.py |
| Live Diagnostics | Out-of-the-box RAM/heap meters, flash storage usage, manual GC trigger, and soft reboot. | 06_live_diagnostics.py |
| Web OTA Updater | Browser drag-and-drop firmware flashing with SHA-256 verification and partition switching. | 07_web_ota_updater.py |
π§ͺ Testing & Verification
Unit tests use Python's standard unittest module and run standalone without hardware:
# Run all tests
make test
# or: python3 -m unittest discover -s tests -p "test_*.py"
# Run linter
make lint
# or: ruff check .
π Technical References
- Feature Reference & Deep-Dive Guide β Architectural justifications and component guides.
- Product & Technical Roadmap β Phased milestones, priorities, and detailed task breakdowns.
- System Value Proposition & Personas β Target user personas, before/after journeys, and feature gating rules.
- Architecture & System Design β System architecture, component trees, and dataflow.
- WebSocket Wire Protocol Specification β JSON opcode schemas, event flows, and diff formats.
- Concurrency & Resilience Specification β Cooperative slicing, backpressure queues, and fault isolation.
π License & Disclaimer
This project is licensed under the MIT License.
Disclaimer of Warranty
Important: This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, non-infringement, or system uptime.
In no event shall the authors, maintainers, or contributors be held liable for any claim, damages, hardware damage (including but not limited to bricked microcontrollers, corrupted flash memory, or electrical hazards), data loss, or other liabilities arising from the use of, or inability to use, this software. Users and developers are solely responsible for testing and validating their device configurations, wiring, and firmware updates.