How mfactory-osaka/esptimecast works
Purpose and Entry Points
ESPTimeCast is Arduino firmware for Wi‑Fi-connected ESP8266/ESP32 LED matrix clocks using MAX7219 hardware. It synchronizes time, retrieves weather, hosts local configuration/control endpoints, and renders rotating display modes. Platform-specific sketch entry points are ESPTimeCast_ESP32/ESPTimeCast_ESP32.ino and ESPTimeCast_ESP8266/ESPTimeCast_ESP8266.ino.
Platform Split
The repository maintains parallel firmware implementations for ESP32-family and ESP8266-family targets rather than a shared core. Each target owns its sketch, embedded UI, lookup data, font, and version metadata:
• ESPTimeCast_ESP32/ESPTimeCast_ESP32.ino
• ESPTimeCast_ESP8266/ESPTimeCast_ESP8266.ino
• ESPTimeCast_ESP32/version.h
The ESP32 path supports the wider ESP32/S2/S3/C3 board family; ESP8266 has its own networking/TLS constraints, notably for Nightscout bridge behavior.
Boot, Network, and Persistence
Firmware boots into either configured Wi‑Fi client mode or a recovery/first-time AP mode. AP mode exposes the setup portal when Wi‑Fi cannot connect. Configuration, credentials, API keys, display preferences, and persistent messages are stored in LittleFS; config backup/restore is exposed through HTTP endpoints. OTA capability depends on target flash partitioning and is served by the firmware web interface.
Embedded Web and HTTP Control Boundary
The device runs an asynchronous HTTP server, serving an embedded browser UI and machine-oriented endpoints. The UI payload is compiled into firmware rather than uploaded as filesystem assets:
• ESPTimeCast_ESP32/index_html.h
• ESPTimeCast_ESP8266/index_html.h
/action is the central local-network control boundary for UI, Home Assistant, scripts, and the companion browser extension. It accepts display/navigation settings, messages, brightness, timers, stopwatch, Pomodoro, persistence, and restart commands. Temporary API messages are distinct from persistent UI messages, with protected-message conflict behavior.
Time, Weather, and External Data
The runtime periodically obtains time from configurable NTP servers, applies IANA timezone/DST rules, and fetches weather from OpenWeatherMap using configured location and API credentials. Weather/time availability drives display fallbacks. Optional bridge behavior repurposes a secondary server/URL setting for RSS headlines, YouTube counts, or Nightscout glucose data; ESP32 can directly use HTTPS where ESP8266 may use an intermediary bridge.
Timezone and localization lookup data are compiled in:
• ESPTimeCast_ESP32/tz_lookup.h
• ESPTimeCast_ESP32/days_lookup.h
• ESPTimeCast_ESP32/months_lookup.h
Display State Machine and Hardware Output
The main loop coordinates a mode scheduler and priority overrides. Normal rotation includes clock, weather, optional description/date/countdown/Nightscout, and persistent message modes. Higher-priority timer, stopwatch, Pomodoro, and protected/temporary messages can take control; expiration returns rendering to the appropriate saved or rotating state. Output is rendered through MD_Parola/MD_MAX72xx to an 8×32 MAX7219 matrix over board-specific SPI GPIO mappings.
Custom glyphs, icons, day symbols, and visual status states are firmware assets:
• ESPTimeCast_ESP32/mfactoryfont.h
• ESPTimeCast_ESP8266/mfactoryfont.h
Material Dependencies and Interfaces
Firmware is built in Arduino IDE against ESP8266 or Espressif ESP32 board runtimes, ArduinoJson, MD_Parola/MD_MAX72xx, ESPAsyncWebServer, and platform async TCP libraries. External interfaces are Wi‑Fi, local HTTP/mDNS, NTP, OpenWeatherMap, optional Nightscout/RSS/YouTube bridge sources, OTA update clients, and physical GPIO buttons. The browser installer at esptimecast.com and companion extension are external delivery/control clients, not code contained in this repository.
Main entry points: ESPTimeCast_ESP32.ino ESP32 sketch · ESPTimeCast_ESP8266.ino ESP8266 sketch · index_html.h Embedded web UI · version.h Version metadata
Components 19
ESP32 firmware
- ESP32 sketch · Supports ESP32-family boards.
ESPTimeCast_ESP32/ESPTimeCast_ESP32.ino - Embedded web UI
ESPTimeCast_ESP32/index_html.h - Version metadata
ESPTimeCast_ESP32/version.h - Timezone and locale data
ESPTimeCast_ESP32/tz_lookup.h - Display font assets
ESPTimeCast_ESP32/mfactoryfont.h
ESP8266 firmware
- ESP8266 sketch · Uses target-specific networking and TLS behavior.
ESPTimeCast_ESP8266/ESPTimeCast_ESP8266.ino - Embedded web UI
ESPTimeCast_ESP8266/index_html.h - Display font assets
ESPTimeCast_ESP8266/mfactoryfont.h
Device runtime
- Boot and Wi-Fi state · Uses client Wi-Fi or recovery setup AP mode.
- LittleFS settings · Stores credentials, configuration, API keys, and messages.
- Async HTTP server · Serves UI, backup/restore, OTA, and control endpoints.
- /action control · Accepts display, message, timer, persistence, and restart commands.
- Time and weather sync · Applies NTP, timezone/DST rules, and OpenWeatherMap data.
- Optional external bridge · Provides RSS, YouTube, or Nightscout data; ESP8266 may require an intermediary.
- Display scheduler · Rotates normal modes and applies timer, message, and Pomodoro overrides.
- MAX7219 matrix · Renders through MD_Parola and MD_MAX72xx to the 8×32 LED display.
- GPIO buttons
Other components
- Local clients · Browser UI, Home Assistant, scripts, and companion extension.
- Internet services · NTP, OpenWeatherMap, and optional bridge sources.
Connections 23
- ESP32 sketch → Boot and Wi-Fi state: boots
- ESP8266 sketch → Boot and Wi-Fi state: boots
- ESP32 sketch → Async HTTP server: runs
- ESP8266 sketch → Async HTTP server: runs
- Embedded web UI → Async HTTP server: served by
- Embedded web UI → Async HTTP server: served by
- Boot and Wi-Fi state → LittleFS settings: loads settings
- Async HTTP server → LittleFS settings: backup and restore
- Local clients → Async HTTP server: local HTTP
- Async HTTP server → /action control: routes
- /action control → LittleFS settings: persists settings
- /action control → Display scheduler: controls
- Boot and Wi-Fi state → Time and weather sync: connectivity
- Internet services → Time and weather sync: NTP and weather
- Internet services → Optional external bridge: optional feeds
- Time and weather sync → Display scheduler: time and weather state
- Optional external bridge → Display scheduler: secondary content
- GPIO buttons → Display scheduler: local controls
- Timezone and locale data → Time and weather sync: timezone and localization
- Display scheduler → MAX7219 matrix: renders current mode
- Display font assets → MAX7219 matrix: glyphs
- Display font assets → MAX7219 matrix: glyphs
- Version metadata → ESP32 sketch: build metadata