Full-stack web application for Raspberry Pi Pico WH, displaying data gathered from connected sensors in the form of an interactive dashboard.
First make sure the Pi Pico is connected to the approprate port (my setup script
assumes it is /dev/ttyACM0):
ls /dev | grep ttyACMThen run the setup script to setup the virtual environment, Wi-Fi config and some useful aliases:
source setup.shFinally, use the run alias to run the project:
run src/main.pyI used the hottest tech stack in the web-apps-for-microcontrollers world:
- MicroPython
- Txt
- Vanilla JS
- Pico CSS
- Lightweight Charts
| Schema | Result |
|---|---|
The server has been implemented according to this very serious UML diagram:
As you can see, the web dashboard is implemented using Server Side Rendering and HTML As The Engine Of State (mostly) with some JS to prevent additional page refreshes. The reason behind this decision is I have recently been reading too much about htmx and React Server Components. If you're considering writing your own application based on this one, I suggest implementing your own frontend as a SPA with a fully JSON API, as rendering templates on the Pico is expensive and may lead to memory shortages.
Additionally, if you're creating a lot of temporary objects, make sure to manually trigger garbage collection to prevent memory fragmentation:
# server.py
import gc
# this runs after sending responses to clean up all UI component objects
gc.collect()dafvid/micropython-bmp280 - custom driver for BMP280