This project demonstrates a fully-featured ESP32 relay panel with:
-
4 relays controllable via wall switches, IR remote, MQTT (Home Assistant).
-
PIR motion sensor with adaptive cooldown and time-based relay activation:
- Day (09:00–18:00): Relay1
- Evening (18:00–23:00): Relay1 + Relay2
- Night (23:00–09:00): Relay3
- Relay4 always triggered by PIR if all relays are OFF
-
WiFi LED indicator: solid when online, blinks on IR press
-
MQTT Home Assistant Discovery for all 4 relays
-
OTA updates via ArduinoOTA
-
NTP synchronization with persistent time storage in Preferences/NVS
- ESP32 DevKit (DOIT ESP32 DEVKIT V1 recommended)
- 4-channel relay module (active LOW)
- 4 wall switches (momentary, INPUT_PULLUP)
- PIR sensor
- IR receiver
- LED for WiFi status (optional)
| Function | Pin |
|---|---|
| Relay 1 | 23 |
| Relay 2 | 19 |
| Relay 3 | 18 |
| Relay 4 | 5 |
| Switch 1 | 13 |
| Switch 2 | 12 |
| Switch 3 | 14 |
| Switch 4 | 27 |
| PIR | 34 |
| IR Receiver | 35 |
| WiFi LED | 2 |
-
Arduino IDE or PlatformIO
-
Libraries:
WiFi.hPubSubClientIRremote(v4.x)PreferencesArduinoOTAtime.h(built-in)