Home Automation using NodeMCU & Blynk App (IoT) – WiFi Relay Module

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.

Home automation with NodeMCU and Blynk pic 1

Required Component for NodeMCU Project

Nodemcu and Relay module
  1. NodeMCU board
  2. Relay Module 5volt
  3. 5 volt DC supply

Circuit for NodeMCU Blynk Relay

NodeMCU Relay module circuit 1

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.

NodeMCU input and output pins

Install Blynk App from Google Playstore

Blynk App download

After installing the Blynk app, enter the Email ID and set the password to Sign Up.

Create a Project in Blynk App

Blynk App set up for Node MCU

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

Blynk example sketch for NODEMCU

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:

  1. Auth Token received in Email at “YourAuthToken”
  2. WiFi Network Name at “YourNetworkName”
  3. WiFi Password at “YourPassword”

Now select the NodeMCU board and PORT in Arduino IDE. Now click on the upload button to program the NodeMCU.

Tutorial Video for the Nodemcu Blynk Relay

Create Switches in the Blynk App

Home automation with NodeMCU and Blynk pic 6

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 App
Click on 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

NodeMCU Relay module circuit 2

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.

Controlling AC Lamps with WiFi

Home automation with NodeMCU and Blynk pic 5

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.

You can also subscribe to our newsletter to receive more such useful electronics projects through email.

Please do share your feedback on this NodeMCU project. Thank you for your time.