Smart Home Controller
Kode Team
Intermediate4 viewsiothome-automationmqttlvgl
Build a centralized smart home hub using Kode Dot. Control lights, fans, and sensors over MQTT with a clean touchscreen interface.
Overview
In this project, we build a smart home controller using the Kode Dot as the central hub. The device connects to your local MQTT broker and provides a touchscreen UI to control lights, read temperature sensors, and manage automation rules.
What you'll learn
- Setting up MQTT on ESP32-S3
- Building LVGL touchscreen interfaces
- Reading I2C sensors (BME280)
- Controlling relays via GPIO expansion
Hardware Setup
Components
- Kode Dot (main controller)
- Inventor Module (GPIO breakout)
- 4-channel relay module
- BME280 temperature/humidity sensor
- Jumper wires
Wiring
Connect the relay module to GPIOs 1-4 on the Inventor Module. The BME280 connects via I2C (SDA/SCL on the magnetic connector).
MQTT Client Setup
#include <WiFi.h>
#include <PubSubClient.h>
const char* ssid = "your-wifi";
const char* mqtt_server = "192.168.1.100";
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
WiFi.begin(ssid, password);
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
}
void callback(char* topic, byte* payload, unsigned int length) {
String msg = String((char*)payload).substring(0, length);
if (String(topic) == "home/light/1") {
digitalWrite(RELAY_1, msg == "ON" ? HIGH : LOW);
}
}