From One Relay to an Ecosystem
It started with a single ESP32 controlling a relay to toggle a light bulb. That was 2023. Today, our SmartHome ecosystem manages 9+ IoT devices across multiple rooms, with real-time MQTT communication, over-the-air firmware updates, and cross-platform control from Flutter, Web, and Alexa.
The Hardware Stack
Each node in our smart home network runs on the ESP32 platform:
// Core ESP32 Configuration
#define DEVICE_ID "living_room_main"
#define MQTT_BROKER "mqtt.circuvent.local"
#define MQTT_PORT 1883
#define OTA_HOSTNAME "esp32-living-room"
#define FIRMWARE_VERSION "3.2.1"
// Pin Mapping
const int RELAY_PINS[] = {25, 26, 27, 14};
const int SENSOR_DHT = 4;
const int SENSOR_PIR = 15;
const int SENSOR_LDR = 34;
const int LED_STATUS = 2;MQTT Topic Architecture
We designed a hierarchical topic structure that scales:
home/{room}/{device}/{action}
home/{room}/{device}/status
home/{room}/sensors/{type}
home/system/ota/{device_id}
home/system/health/{device_id}This means:
home/living_room/light_1/toggle — Control a specific lighthome/kitchen/sensors/temperature — Read kitchen temperaturehome/system/health/esp32_bedroom — Device health checkOTA Update System
One of our biggest challenges was updating firmware across 9 devices without physically accessing each one. We built a custom OTA system:
void setupOTA() {
ArduinoOTA.setHostname(OTA_HOSTNAME);
ArduinoOTA.setPassword(OTA_PASSWORD);
ArduinoOTA.onStart([]() {
mqtt.publish("home/system/ota/status", "updating");
disableAllRelays(); // Safety first
});
ArduinoOTA.onEnd([]() {
mqtt.publish("home/system/ota/status", "complete");
ESP.restart();
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
int percent = (progress / (total / 100));
if (percent % 10 == 0) {
char msg[32];
snprintf(msg, sizeof(msg), "progress:%d", percent);
mqtt.publish("home/system/ota/progress", msg);
}
});
ArduinoOTA.begin();
}Energy Monitoring
Each SmartHome node reports energy consumption data:
The data flows from ESP32 → MQTT → Firebase → Flutter Dashboard, giving homeowners complete visibility into their energy usage.
Flutter Cross-Platform App
The SmartHome Flutter app is our most mature mobile product: