IoT Project using ESP8266 NodeMCU Relay Control with Blynk - DIY Smart Plug

Published at : 23 Dec 2025

In this ESP8266 IoT project, you will learn how to build an IoT-based DIY Smart Plug using the NodeMCU Blynk IoT platform, 2 relay modules, and manual latched switches. This IoT tutorial shows how to control appliances both locally and remotely, with real-time app monitoring, offline manual control, and EEPROM state memory.

Enroll Altium Student Lab for FREE: https://www.altium.com/in/yt/techstudycell
Limited Time offer for students.

This project is ideal for smart home beginners, DIY enthusiasts, and those who want to build reliable IoT appliances using the Blynk IoT (New) platform.

Download Code for ESP8266 Blynk IoT-based home automation project from the following article:
https://iotcircuithub.com/esp8266-nodemcu-blynk-iot-diy-smart-plug/

Sign up Blynk IoT Cloud:
https://www.blynk.io/

I have covered the following topic in this ESP8266 Blynk IoT project:
00:36 Quick demo on ESP8266 NodeMCU-based Smart Plug.
02:24 Required Components for ESP8266 DIY smart plug.
02:43 Circuit diagram of ESP8266 WiFi relay module project.
03:09 Configure the Blynk IoT cloud for ESP8266 NodeMCU relay.
05:08 Source code for the Blynk ESP8266 control relay.
09:00 Configure the Blynk IoT app for ESP8266 project.

Required Components for this IoT-based DIY smart relay:
ESP8266 NodeMCU WiFi module
2-channel relay module (active-LOW)
5-mm LED + 220Ω resistor for WiFi status
2 latched switches (ON/OFF toggle or rocker switch)
5A 3 pin socket
Jumper wires

Important points:
1. In code, you have to update only the BLYNK_TEMPLATE_ID, BLYNK_DEVICE_NAME, Authentication Token, and WiFi details as shown in the video.
2. Removed periodic virtualWrite to reduced the Blynk cloud requests for free plan.
3. Use a stable 5V power supply for NodeMCU + Relays.
4. EEPROM memory stores relay states after power failure.
5. Always use relays with adequate current rating.
**Please take proper safety precautions while working with high voltages.

The ESP8266 NodeMCU continuously reads the state of two latched switches, where each switch directly controls a relay by turning it ON when the switch connects the input pin to GND. Along with manual control, the Blynk app buttons (V1 and V2) can also operate the relays remotely over WiFi or the internet. Whenever a relay changes state—whether from the mobile app or the physical switch—the new state is immediately applied to the relay hardware, sent back to the Blynk app for real-time feedback (if the device is online), and saved to EEPROM when the EEPROM_FLAG is enabled.
During startup, the NodeMCU reads the saved relay states from EEPROM and restores them automatically, ensuring the appliances return to their previous conditions after a reset or power failure.
A timer regularly checks the WiFi and Blynk connection status and updates the WiFi LED indicator accordingly. The Blynk.run() function is executed only when WiFi is connected, keeping manual relay control fast and responsive even when there is no internet connectivity.

#homeautomation #blynk #esp8266
-------------------------------------------------------
Thanks For Watching...
✅ SUBSCRIBE ✅LIKE ✅SHARE ✅ COMMENTS

Find out more such projects: https://iotcircuithub.com/
Facebook: https://www.facebook.com/techstudycell/
Instagram: https://www.instagram.com/techstudycell/
Telegram: https://t.me/techstudycell/
-------------------------------------------------------

-------------------------------------------------------
WARNING:
This video is for demonstration and educational purposes only.
Each demonstration presents risks and hazards that must be fully understood before attempting.
And should be performed only by professionals
------------------------------------------------------

Other useful IoT projects:
Latest ESP32 projects playlist:
https://www.youtube.com/playlist?list=PLlBmS9EKFydee7YsvVP_5TiPDeH38PwlK

Latest NodeMCU projects playlist:
https://www.youtube.com/playlist?list=PLlBmS9EKFydcv9ffXm72-cU9_EusicIjO

Arduino Home Automation Projects playlist:
https://youtube.com/playlist?list=PLlBmS9EKFydcxOoCht4ocLEV5zUdoCwsd