Description:
In this IoT based project, we will learn how to make a Home Automation project using NodeMCU and Blynk App. The circuit is very simple, we just need a Nodemcu board and a relay module to control home appliances securely from the smartphone through the internet.
I have shared all the details like esp8266 NodeMCU pinout, circuit, Arduino sketch, Blynk App setup for this smart home project.
Required Component For NodeMCU Project
- NodeMCU board
- Relay Module 5volt
- 5 volt DC supply
Circuit For NodeMCU Blynk Relay
The circuit for this home automation project is very simple. We just need a relay module and NodeMCU board for this circuit. And we can control different home appliances from Blynk App.
Here I have used a 2-channel relay module but you can also connect 4-channel or 6-channel relay module with node MCU. For that, you can use D1, D2, D5, D6, D7, D8 pins of NodeMCU.
I have shared all the GPIO details of the esp8622 NodeMCU board in the following picture.
Install Blynk App From Google Playstore
After installing the Blynk app, enter the Email ID and set the password to Sign Up.
Create A Project In Blynk App
To Create a new project in the Blynk app you have to give the Project Name and Choose The Device. In this IoT project, I will use NodeMCU, so I have selected NodeMCU.
After that Blynk app will send an Auth Token to the registered email id. We need that Auth Token while programming the NodeMCU.
Code For NodeMCU Blynk WiFi Relay
For this smart home project, we need to install the Blynk Library before programming the NodeMCU board.
Click Here to download Latest Blynk Library.
Then to get this Blynk example sketch for Nodemcu go to
File–> Examples–> Blynk–>Boards WiFi –>NodeMCU
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
void setup()
{
// Debug console
Serial.begin(9600);
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();
}
Then enter the following details in the code:
- Auth Token received in Email at “YourAuthToken”
- WiFi Network Name at “YourNetworkName”
- WiFi Password at “YourPassword”
Now select the NodeMCU board and PORT in Arduino IDE. Now click on the upload button to program the NodeMCU.
Create Switches In The Blynk App
Now I have to create switches in the Blynk app to control the relay module.
Steps To Create A Switch In Blynk App:
Open the project in the Blynk AppClickon the “+” icon on the top.
select the Button
Click on that button and select the Output Pin –> D1 & Mode –> Switch
In similar way create switch with D2 Pin of NodeMCU
You can also refer the tutorial video for creating the switch in the Blynk App
Connect The Home Appliances
Here I have connected two AC lamps. You can connect any other home appliances with this wifi relay module.
And as I said before you can also connect 4 channel or 6 channel relay module with ESP8266 NodeMCU. For that, you can use D1, D2, D5, D6, D7, D8 as output pins of node MCU.
Now we can control these AC lamps or any other home appliances from the smartphone. So this a very simple but useful internet of things project where I can control home appliances from anywhere if I have an internet connection on my mobile.
I hope, you like this IoT based project with NodeMCU.