Deep Dive: How I Built Lumen A Self-Hosted, Local-First ESP32 Smart Lighting Controller
How do you build a smart lighting controller that keeps working reliably without the cloud, external servers, or hardcoded GPIO pins?
I just published a full 36-minute technical walkthrough taking Lumen - my open-source, self-hosted ESP32 smart lighting controller - completely apart: from the hardware and HAL board profiles down to the firmware architecture, CIE dimming curve, local automation engine, ESP-NOW multi-controller linking, and Home Assistant integration.
- 🎥 Full Tutorial Video: I turned a $5
ESP32into a self-hosted, local-first smart lighting hub! | Full Tutorial - 💻 GitHub Repository:
github.com/charithmadhuranga/Lumen
Overview: What Lumen Does
Lumen turns an ESP32 into a complete, self-contained lighting controller with its own web application served directly from flash.
Lights, rooms, groups, scenes, interactive floor plans, and automations all run locally on the board with no user account and no internet connection required.
Everything demonstrated in the tutorial runs on real hardware - both a KinCony KC868-AP controller and a generic ESP32 DevKit.
What's Covered in the Tutorial
1. Hardware & Hardware Abstraction Layer (HAL)
- PWM & I/O Expansion: How the
ESP32dims lights directly via PWM, and how the KinCony KC868-AP extends capabilities with aPCA9685PWM driver,PCF8574digital inputs, and relays. - Board Profiles: How the HAL and JSON board profiles decouple hardware definitions from firmware logic so no GPIO pin number is hardcoded.
2. Firmware Architecture & Lighting Engine
- Concurrency & State Ownership: A clean embedded architecture built around a single lighting task that owns hardware outputs, fed by bounded command queues and an internal event bus.
- From a Browser Tap to PWM: How a UI interaction translates into smooth 20 ms transitions, perceptually linear brightness via the CIE dimming curve, and the color/tunable-white mixing engine.
3. Boot Sequence, Flash Web App & Security
- Persistent Storage & Boot: How configuration survives power cuts, how the boot sequence initializes safely, and how the web UI is served straight from flash.
- Secure First Start: Enforced password setup on initial boot,
PBKDF2credential hashing, session management, and rate limiting.
4. Rooms, Scenes, Floor Plans & Local Automations
- Rooms, Groups & Scenes: Organizing fixtures and smoothly fading between multi-light scenes.
- Interactive SVG Floor Plans: Uploading custom floor plans to place live-glowing light controls - and why every uploaded SVG is validated twice for safety.
- Local Automation Engine: Running time-based, sunrise/sunset, physical input, and rule-based automations locally with built-in loop protection.
5. Integrations, Multi-Controller ESP-NOW & Safe OTA
- Home Assistant & Network Control: Two-way integration with Home Assistant via
MQTTauto-discovery, alongside signed TCP and UDP control protocols. - Routerless Multi-Controller Linking (ESP-NOW): How multiple Lumen boards coordinate directly over
ESP-NOWwith device ownership rules, custom frame formatting, and replay protection. - Resilient OTA Updates: Self-verifying firmware updates with automatic rollback protection and backup/restore workflows.
Video Chapters
0:00Intro and welcome to Lumen1:50The hardware4:24Firmware architecture7:05HAL, drivers and board profiles10:06Storage, boot and the web app12:30Flashing and the first start14:53From a tap to PWM18:16Rooms, groups and scenes20:16Floor plans22:22The automation engine25:00MQTT and Home Assistant28:06Multiple controllers: ESP-NOW31:02Networking and security32:57Updates, rollback and backups
Links & Source Code
- Watch the Full Tutorial:
- Explore the Repo on GitHub: https://github.com/charithmadhuranga/Lumen
If you're designing local-first ESP32 firmware, working with Home Assistant MQTT discovery, or building your own smart lighting hardware, feel free to explore the repository and share your feedback in the comments!
Comments
No comments yet. Start the discussion.