Back
Apr 15, 2026 · 9 min read

esp-home: ESP32 home automation, phase by phase

My final-year project: ESP32 home automation built phase by phase, from an isolated access point to MQTT + Home Assistant.

ESP32MQTTHome AssistantIoTC/C++
facumruiz/esp-home

esp-home is the final project of my Embedded Systems & IoT degree. The goal was to take an ESP32 board from an isolated device to a node integrated into a real home-automation setup — and to do it step by step, without rewriting the whole firmware at each stage.

The goal

Build a progressive home-automation system: each phase had to work on its own and, at the same time, be the foundation of the next. That way the project could be shown, tested and documented at any point along the way.

Phase by phase

I started with a local access point and an HTTP webserver to toggle an LED from the browser — zero dependency on the home network. Then I stood up Home Assistant in Docker as the central brain. Finally I moved communication to MQTT, with automatic fallback between AP and STA so the device is never unreachable.

The technical decision

MQTT instead of HTTP polling: the ESP32 publishes its state and subscribes to commands by topic. Small messages, cheap reconnection, and Home Assistant discovers the device almost on its own.

// the ESP32 listens for commands and publishes state
esp_mqtt_client_subscribe(client, "home/led/set", 1);

void on_message(const char *topic, const char *payload) {
  if (!strcmp(topic, "home/led/set"))
    gpio_set_level(LED_GPIO, atoi(payload));
}

Modules

On top of that base I added a WS2812B strip controllable over MQTT and a local webserver, plus an LM393 light sensor that enables an automatic mode: the lights respond to ambient light with no intervention.

Outcome

A home-automation system working end to end — firmware in C/C++ with ESP-IDF, an MQTT broker and Home Assistant — documented phase by phase in the repository so it can be reproduced or extended. The video shows the system in action.

Stack
ESP-IDFC/C++MQTTHome AssistantDocker
Back