DIY Smart Switch with HomeKit and Home Assistant support, built on the ESP8266.

/status endpoint and MQTT diagnostic sensors expose free heap, uptime, HomeKit client count, and last reset reason without needing serial access| Component | Description |
|---|---|
| WeMos D1 Mini Pro V3.0 | ESP8266 MCU |
| MH-SR602 | PIR motion sensor |
| OLED LCD Shield 0.66” | SSD1306 64x48 I2C display |
| DHT11 | Temperature & humidity sensor |
| Wemos D1 Mini Relay Shield | NO/NC relay output |
| 110v-220v to 5v PSU | AC-DC power supply |
| OMRON 12x12x6mm | Tactile push button |
Full bill of materials with purchase links in sch/README.md. Schematic in sch/, 3D-printable enclosure STLs in stl/.
| Pin | Function |
|---|---|
| D8 | Relay |
| D7 | Physical switch (INPUT_PULLUP) |
| D4 | DHT11 data |
| D3 | PIR motion sensor |
| SDA/SCL | OLED I2C |
Install the following in Arduino IDE:
Edit src/suitchi/Constants.h:
#define homeKitPin "1CB8"
#define homeKitPassword "111-11-111"
#define bridgeName "Suitchi 1CB8"
#define otaName "suitchi_1CB8"
#define serialNumber "123457"
Edit src/suitchi/wifi_info.h with your WiFi credentials:
const char *ssid = "YourSSID";
const char *password = "YourPassword";
To enable MQTT with Home Assistant autodiscovery, uncomment and configure in Constants.h:
#define MQTT_ENABLED
#define MQTT_SERVER "192.168.1.100"
#define MQTT_PORT 1883
#define MQTT_USER ""
#define MQTT_PASS ""
#define MQTT_NODE_ID "suitchi_1cb8"
#define MQTT_TOPIC_PREFIX "suitchi/1CB8"
#define MQTT_PUBLISH_INTERVAL 30000
Once connected, the device publishes discovery configs to homeassistant/ and all entities appear automatically in Home Assistant grouped under a single device. The switch supports bidirectional control — toggling from HA, HomeKit, or the physical button keeps all three in sync.
src/suitchi/suitchi.ino in Arduino IDESubsequent updates can be done over-the-air via ArduinoOTA.
The device runs a web server on port 80:
| Endpoint | Description |
|---|---|
GET / |
Welcome message |
GET /TH |
JSON temperature and humidity |
GET /motion |
JSON motion and occupancy state |
GET /status |
JSON free heap, HomeKit clients, uptime, and reset reason |
When MQTT is enabled, the following topics are published under the configured prefix (e.g., suitchi/1CB8/):
| Topic | Type | Description |
|---|---|---|
status |
Availability (LWT) | online/offline — set automatically by broker on disconnect |
temperature |
State (retained) | Temperature in °C |
humidity |
State (retained) | Humidity in % |
heat_index |
State (retained) | Heat index in °C |
motion |
State (retained) | ON/OFF |
occupancy |
State (retained) | ON/OFF |
switch |
State (retained) | ON/OFF |
switch/set |
Command | Send ON/OFF to control the relay |
heap |
Diagnostic | Free heap in bytes |
uptime |
Diagnostic | Seconds since boot |
reset_reason |
Diagnostic (retained) | Last ESP reset reason |