Loading 3D model… large boards can take a moment.
mi69.py is the main script of an embedded, Wi-Fi-enabled FM radio and smart clock interface built on MicroPython. It combines a real-time clock, OLED UI, FM tuner, and web connectivity into a single-threaded yet responsive application, suitable for microcontrollers like the Raspberry Pi Pico W.
┌────────────┐
│ Button │◄────────────┐
└────┬───────┘ │
▼ │
┌─────────────┐ Debounce, Hold Detection
│ Main │─────────────┘
│ (mi69.py) │
└────┬────────┘
┌─────────┴─────────┐
▼ ▼
┌────────────┐ ┌────────────┐
│ Display │ │ Radio │
│ (OLED + UI)│ │ (FM chip) │
└────┬───────┘ └────┬───────┘
▼ ▼
┌──────────┐ ┌────────────┐
│ Web Time │ │ Web Server │◄──── Access via browser
└──────────┘ └────────────┘
mi69.py – Main Control Loopweb_data.json)oled_dirty, json_dirty flags minimize redundant writesutime.ticks_ms() is used to throttle updates_locklibraries/display.py – OLED DrawingEncapsulates all drawing on the OLED display using framebuf:
display_clock_time(rtc.datetime())display_radio_freq(101.9)display_volume(5)Also handles font scaling, screen clearing, and line placement.
libraries/radio.py – FM Radio ControlControls an FM tuner (likely via I2C/SPI). Key methods:
set_freq(freq): set frequency (MHz)seek_up() / seek_down(): scan for stationsset_volume(level): 0–15 volume levelsKeeps state internally for restoring or syncing with UI/web.
config/resources.py – Global Shared StateContains:
oled_dirty, json_dirty, btn_short_req, etc._lock used by both threadsThis is the “RAM” for the system shared across all modules.
web_connectivity/web.py – HTTP ServerA simple HTTP server that runs on a new thread:
GET /status: Return JSON statePOST /set_time, POST /set_volume, etc.web_data.json using the shared _lockThis lets users control and monitor the device remotely.
web_data.json – State FileJSON-encoded structure for UI and web server to share state.
{
"volume": 5,
"frequency": 101.9,
"time": "12:34:56",
"alarm_enabled": false
}
Used for persistence and as a synchronization bridge.
_thread module for background web server_lock for:
from _thread import start_new_thread
start_new_thread(WebServer().start, ())
ticks_ms()main, display, radio, web, resourcesThis project is a highly educational template for combining hardware control, UI, web connectivity, and concurrency in MicroPython. It’s a complete working system for embedded devices with many real-world use cases.
No comments yet. Be the first to ask about this board.