Home Automation using Blynk and NodeMCU
- RaviKumar Uthirapathy
- May 31, 2020
- 2 min read
This article help to control the home appliances from any where in the world using smart phone and internet connection.
Hardware Required:
NodeMCU
4 Channel Relay
5v/2A DC micro USB power adapter
Software Required:
Blynk App on Android mobile phone
Arduino IDE on windows PC
Circuit Diagram :

Connect NodeMcu GPIO D0 Pin To IN1 Of Relay 1 in Board
Connect NodeMcu GPIO D1 Pin To IN2 Of Relay 2 in Board
Connect NodeMcu GPIO D2 Pin To IN3 Of Relay 3 in Board
Connect NodeMcu GPIO D3 Pin To IN4 Of Relay 4 in Board
Arduino Code :
#define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> char auth[] = "-----------------------------------";// your authentication code which is received on setup of Blynk app on smart phone // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "----------"; char pass[] = "----------"; int relay1 = 16; //GPIO16 D0 pin int relay2 = 5; //GPIO5 D1 pin int relay3 = 4; //GPIO4 D2 pin int relay4 = 0; //GPIO0 D3 pin void setup() { // Debug console Serial.begin(115200); pinMode(relay1,OUTPUT); pinMode(relay2,OUTPUT); pinMode(relay3,OUTPUT); pinMode(relay4,OUTPUT); digitalWrite(relay1, HIGH); digitalWrite(relay2, HIGH); digitalWrite(relay3, HIGH); digitalWrite(relay4, HIGH); Blynk.begin(auth, ssid, pass); // You can also specify server: //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80); //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080); } void loop() { Blynk.run(); }
The following steps to be followed for Blynk app integration :
Download Blynk Application from Google Play store:
Download and install the Blynk App Here:
Create a Blynk App:
Step1: For new users Sign Up and old users just Log in.
Step2: Create a New Project and Choose NodeMCU board in the Choose device drop-down and then click create.
Step 3: Now you will receive an email with the Authentication Token. You need to place it in the Arduino Code. Before that, we will finish the App Creation.
Step 4: Click on the ‘+’ Icon on the top right corner. Now Widget box will open, We need 4 buttons to control the relay. So add 4 buttons by choosing it here.
Step 5: Now tap on the button from the Homepage to configure it. Choose the Output Pin D0 and Select the Mode as Switch. Then go back. Configure the remaining buttons in the same way.
Step 6: Now we have the App ready.
Step 7: Now connect the NodeMCU to the PC and open Arduino IDE.
Install the Blynk library from Sketch>Include Library> Manage Library and search for blynk and install it. Or you can install using Git Method from here.
In case, you are using ESP8266 or NodeMCU for the first time you need to add NodeMCU on boards manager and the ESP8266Wifi.h library to be installed. Otherwise, skip to step8

Step 8: Copy the following code or Open File->Examples and navigate to Blynk->WiFi->NodeMCU.
You need to modify only three things in this code.
Paste the Authentication Token that you received in your email at ‘YourAuthToken’. Then add your SSID and Password in the code as ‘YourNetworkName’ and ‘YourPassword’.
Comments