In this project, we will use an ESP8266 NodeMCU to control four relays using both Arduino IoT Cloud and manual push buttons. This allows remote switching via the cloud while maintaining local control. The project is ideal for home automation applications, allowing you to control lights, fans, and other appliances via the internet.
Features
✅ Remote Control – Operate relays via the Arduino IoT Cloud dashboard
✅ Manual Control – Use physical push buttons to toggle relays
✅ WiFi Connectivity Indicator – An LED shows the status of the WiFi connection
✅ State Synchronization – Whether toggled manually or remotely, relay states remain synchronized
Components Required
- ESP8266 NodeMCU
- 4-Channel Relay Module
- Push Buttons (x4)
- WiFi Router for Internet Connectivity
- Jumper Wires
- Power Adapter (5V, 2A recommended)
Circuit Diagram
Connections
Relays
Relay | ESP8266 Pin |
---|---|
Relay 1 | D1 (GPIO 5) |
Relay 2 | D2 (GPIO 4) |
Relay 3 | D5 (GPIO 14) |
Relay 4 | D6 (GPIO 12) |
Push Buttons
Switch | ESP8266 Pin |
---|---|
Switch 1 | SD3 (GPIO 10) |
Switch 2 | D3 (GPIO 0) |
Switch 3 | D7 (GPIO 13) |
Switch 4 | RX (GPIO 3) |
WiFi LED
- WiFi Status LED → D0 (GPIO 16)
Setting Up Arduino IoT Cloud
Step 1: Create a New Thing
- Go to Arduino IoT Cloud
- Create a new “Thing”
- Add four Boolean variables:
relay1
relay2
relay3
relay4
- Set each as Read & Write with ON_CHANGE trigger.
Step 2: Configure Device
- Select ESP8266 NodeMCU as the device
- Link your WiFi credentials
- Copy the Secret Key for use in the code
Arduino Code
Upload the following final working code to your ESP8266:
How It Works
- Cloud Dashboard: The Arduino IoT Cloud lets you toggle each relay remotely.
- Manual Push Buttons: Pressing a button toggles its corresponding relay.
- WiFi LED Indicator: If WiFi is disconnected, the LED turns ON; otherwise, it stays OFF.
- State Synchronization: The relays remain updated whether controlled remotely or manually.
Demonstration Video
i Will upload it soon
Future Improvements
- 📌 Add MQTT or Blynk for additional control options
- 📌 Use Alexa for voice-based relay switching
- 📌 Expand to more relays for home automation
Conclusion
This ESP8266-based 4-channel relay project enables seamless home automation with cloud and manual control. Whether you want to remotely switch lights, appliances, or fans, this project is a great starting point.
If you liked this project, give it a thumbs up and share it with others! 🚀