How e2002/yoradio works
Project type and purpose
• This is an embedded IoT application running on an ESP32 device. It implements a web-radio that can play Internet streams or SD-card audio via either an I2S DAC or a VS1053 audio decoder, presents a local web-UI (SPIFFS), supports hardware controls (buttons, encoder, IR, touchscreen), publishes status/control via MQTT (for Home Assistant and other clients), and exposes a Telnet/CLI interface.
File structure
• Top-level:
• HA/custom_components/yoradio → Home Assistant integration
• examples/ → Arduino example option and plugin sketches
• nextion/ → Nextion HMI project files
• yoRadio/ → Main Arduino project directory
• broken204/ → Patches for Adafruit display libraries
• yoRadio/data/www/… → Compressed HTML/CSS/JS UI files stored in SPIFFS
• yoRadio/src/ → Device firmware source, subdivided into:
• core/ → Business logic: audio, network, config, controls, display, MQTT, telnet, SD, RTC
• displays/→ Display-driver abstractions, configurations, fonts, widget code
• AsyncWebServer, AsyncTCP, async-mqtt-client → Embedded HTTP, WebSocket, MQTT client stack
• audioI2S, audioVS1053, IRremoteESP8266, OneButton, etc. → Embedded drivers for hardware modules
• pluginsManager/ → Event-hook infrastructure for extendible plugins
• main.cpp + yoRadio.ino → Entry point and Arduino setup/loop
README insights
• Describes hardware variants (I2S vs VS1053, dozens of display models, buttons, encoder, IR, touchscreen, RTC)
• Describes workflow: generate myoptions.h, upload SPIFFS, flash firmware, configure WiFi via captive-portal, browse web UI, control via MQTT/HA.
• Emphasizes embedded HTTP server, SPIFFS data store, MQTT topics, Telnet/CLI, plugin architecture.
Main components
a. Hardware layer
• ESP32 SoC
• Audio output: I2S DAC or VS1053 module
• Device (one of many SPI/I2C LCD/OLED or Nextion touch panel)
• Controls: Buttons, rotary encoder (+ switch), IR receiver, optional touchscreen
• Storage: SD card (SPI) and SPIFFS (on-chip flash)
• RTC module (I2C DS3231/DS1307)
• LED_BUILTIN, light sensor, backlight control
b. Firmware / Software layer (running on ESP32 FreeRTOS)
• Startup & configuration loader (options.h / myoptions.h)
• Plugin manager (lifecycle & event dispatch)
• Core logic:
• AudioHandler: stream fetch, decode (I2S or VS1053), buffer management
• DisplayManager: update screen, widgets, screensaver
• NetServer: HTTP + WebSocket server (AsyncWebServer / AsyncTCP) serving SPIFFS UI
• MQTT client (async-mqtt-client) publishing and subscribing to control/status
• Telnet/CLI interface for commands
• SDCard manager (playlist import/export, file indexing)
• RTC support: NTP sync, display clock
• Control input handlers: buttons, encoder, IR, touchscreen
• File system: SPIFFS partition (web UI, playlists, WiFi list)
c. External systems
• Web browser (UI) connecting over WiFi HTTP to device’s captive-portal
• MQTT broker (local or cloud)
• Home Assistant (custom component) subscribes/publishes via MQTT
• WiFi network, captive-portal AP
Relationships and interactions
• On boot: core reads configuration, mounts SPIFFS, initializes hardware drivers, registers HTTP/MQTT/Telnet services, loads plugins.
• HTTP server → serves compressed UI pages from SPIFFS; WebSocket pushes status updates; REST endpoints accept config commands.
• MQTT client ↔ broker: publishes status topics, subscribes to command topic. Home Assistant custom component uses it.
• Audio pipeline: HTTP stream or SD read → AudioHandler → I2S or VS1053 → speaker
• Pipeline: DisplayManager receives events (track/volume/time) → renders via driver
• Input pipeline: button/encoder/IR/touch events → core action or plugin
• Plugins subscribe to core events via pluginsManager
• Telnet server listens on TCP port, routes commands to core
Architectural patterns and design principles
• Layered architecture: hardware abstraction → core services → network interfaces → plugins
• Event-driven: plugins hook into lifecycle events; WebSocket pushes updates; input triggers events
• Modular drivers: each display, audio, input driver lives in its own folder, following consistent interfaces
• Single source of configuration: myoptions.h influences hardware wiring & feature flags
• Async I/O: HTTP, WebSocket, MQTT run on separate FreeRTOS tasks/cores, non-blocking
Technologies, frameworks, libraries
• Platform: Arduino-ESP32 / FreeRTOS
• Networking: AsyncWebServer, AsyncTCP
• MQTT: async-mqtt-client
• Audio: ESP32-audioI2S / ESP32-vs1053_ext
• Displays: Adafruit_GFX + model-specific drivers (integrated into project), Nextion
• Input: IRremoteESP8266, OneButton, custom encoder code
• File System: SPIFFS (Sketch data) + SD (SdFat)
• RTC: RTCLib
Final advice
• Be exhaustive: include every peripheral, every major firmware component, and every external integration
• Event-driven nature: indicate plugin hooks, WebSocket push, MQTT pub/sub
• Validate with README: ensure each feature (web UI, remote control, HA integration, SD mode) is represented