Overview

In this NodeMCU ESP8266 project, I demonstrated how to build a home automation system using the NodeMCU app and Blynk. With this IoT project, you can control four home appliances from a smartphone. If WiFi is not available, you can control the lighting manually.

This image has an empty alt attribute; its file name is esp8266.png

Required Hardware Components

Hardware

  • NodeMCU
  • Relay
  • Voltage Regulator IC
  • Female DC Power Jack
  • Female Header

Software:

  • Code Composer Studio

Bill of Materials

S.NoCOMPONENTSDESCRIPTIONQUANTITYlink
1ESP8266-12E BoardESP8266-12E Board1https://www.amazon.com/Arduino-A000066-ARDUINO-UNO-R3/dp/B008GRTSV6
2Relay
5V Relay
4ader-em18-board-with-serial-ttl-interfacing-125-khz-through-a-rs232-converter-to-pc/?src=google&kwd=&adgroup={adgroup}&devicec&campaign={campaign}&adgroup={adgroup}&keyword=&matchtype=&gclid=CjwKCAjw49qKBhAoEiwAHQVTo-i85TwixHnJAFNHLfwUknLhBVYloMe3ECBLmMFtUFrk8qGBxO0vzhoCIAQQAvD_BwE
6Jumper WiresJumper Wires40https://www.flipkart.com/arduino-female-male-dupont-20cm-jumper-wire-40pcs-interconnect-electronic-hobby-kit/p/itmf8e5ezvkequ3h?pid=EHKF8DVBG9BXZHHH&lid=LSTEHKF8DVBG9BXZHHHUGSG9J&marketplace=FLIPKART&cmpid=content_electronic-hobby-kit_14498130132_u_8965229628_gmc_pla&tgi=sem,1,G,11214002,u,,,543116155366,,,,c,,,,,,,&ef_id=CjwKCAjwndCKBhAkEiwAgSDKQYwKr3euuMpKCLDJnf-

What is NodeMcu8266

NodeMcu8266 is a development board based on the esp8266 wifi module. NodeMcu8266 is an open-source device that is primarily used to manufacture IoT devices.

It can be programmed using the Arduino IDE and the coding structure is still similar to Arduino, but the ArduinoIDE does not come with ESP compatible boards pre-installed, so you need to add/import the board’s attachments to the IDE before programming and its very easy to do ESP series boards were not initially developed for compatibility with the Arduino IDE, so in the Arduino IDE, each pin on the NodeMCU corresponds to a different IDE’s GPIO pin. Here is the pin mapping for the NodeMCU GPIO pins. In Coding, you can directly write the NodeMCu digital pins as D1, D2, D3… or the corresponding GPIO PIN.

Steps to import ESP panel libraries:

Specification:

ESP8266 based development kit includes GPIO, PWM, IIC, 1-Wire and ADC on one board. Boost your development in the fastest way in combination with NodeMCU firmware

  • Wi-Fi Module – ESP-12E module similar to ESP-12 module but with 6 extra GPIOs.
  • USB – micro USB port for power, programming and debugging
  • Headers – 2x 2.54mm 15-pin header with access to GPIOs, SPI, UART, ADC, and power pins
  • Misc – Reset and Flash buttons
  • Power – 5V via micro USB port
  • Dimensions – 49 x 24.5 x 13mm
This image has an empty alt attribute; its file name is esp8266-1.png

Shortcode

This image has an empty alt attribute; its file name is image-36.png
This image has an empty alt attribute; its file name is image-37.png
http://arduino.esp8266.com/stable/package_esp8266com_index.json

Click on the Ok button.

Go to ‘Tools and Board’, from the drop-down menu select ‘ Board Manager’.

This image has an empty alt attribute; its file name is image-38-1024x362.png



This image has an empty alt attribute; its file name is image-39-1024x571.png
  • When you select the ESP8266 package then a ‘Install button’ will appea, click on it.this file file is around 160mb in size and will take some time to download.
  • After Completion, you will be able to find the different boards of ESP series in Arduino IDE and Installation is complete.

Circuit Diagram & Connection

A circuit diagram for Blynk controlled home automation using ESP8266 is given below. With this circuit diagram, you can assemble the circuit on a breadboard using a 4 channel relay and a NodeMCU board.

This image has an empty alt attribute; its file name is image-41-1024x645.png
This image has an empty alt attribute; its file name is 12-2.jpg
This image has an empty alt attribute; its file name is f3a0241b-7f73-4943-acd1-37847c12bb46

Setting up Blynk Application

Now let’s get to know the Blynk app. In this project, all the controls are implemented by the Blynk application. Blynk is a platform with IOS and Android applications to control Arduino, Raspberry Pi and the like through the Internet. It is a digital control panel where you can create a graphical interface for your project by simply dragging and dropping tools.

Download Blynk App on your smartphone through Play Store. Create an account and then click New Project.

This image has an empty alt attribute; its file name is image-42.png

You can download the Blynk app from the Playstore if you are an Android user. You can also install the Blynk app on IOS from the App Store.

Now let’s set up the Blynk app for an IoT home automation project. First, open the app and create a new account with your email ID. Then click “New Project”.

Now you can follow the images below for a complete setup guide.

You can download the Blynk app from the Playstore if you are an Android user. You can also install the Blynk app on IOS from the App Store.

Now let’s set up the Blynk app for an IoT home automation project. First, open the app and create a new account with your email ID. Then click “New Project”.

Now you can follow the images below for a complete setup guide.

This image has an empty alt attribute; its file name is image-47.png
This image has an empty alt attribute; its file name is image-48.png

Create a project in Blynk App

Now, add 4 buttons from the Widget box as we are using 4 channel relay

This image has an empty alt attribute; its file name is image-49.png



This image has an empty alt attribute; its file name is image-50.png
This image has an empty alt attribute; its file name is image-51.png

From the top, when you click “Email Everyone”, an authentication code will be sent to your email address. This code is very important because it is required in the program/code. So open your email id and check the token.

This image has an empty alt attribute; its file name is image-52-1024x544.png

Click on button -> change its name -> change PIN to digital pin say D3 depending upon your connection. Repeat process for 4 relays. I am using D1 for relay 1, D2 for relay 2, D3 for relay 3 and D4 for relay 4.

Source Code/Program

Here is the Blynk based home automation code, you can copy and paste the code into your Arduino IDE. But before that, you need to add the Blynk library to the Arduino IDE.

Download Blynk Library

https://github.com/blynkkk/blynk-library

Final Code

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
 
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "c5lRcTsZ2GwLyRtQ098wzuVdFz__sbXx";
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = Devilal;
char pass[] = Home@123;
 
  int Fan_1         = 12;  // D6 pin 
  int Light_1       = 14;  // D2 pin 
  int Bed_Light_1   = 4;   // D1 pin 
  int TV_1          = 5;   // D5 pin 
 
void setup()
{
  // Debug console
  Serial.begin(115200);
 
  pinMode(Fan_1,OUTPUT);
  pinMode(Light_1,OUTPUT);
  pinMode(Bed_Light_1,OUTPUT);
  pinMode(TV_1,OUTPUT);
 
  digitalWrite(Fan_1, HIGH);
  digitalWrite(Light_1, HIGH);
  digitalWrite(Bed_Light_1, HIGH);
  digitalWrite(TV_1, HIGH);
 
  Blynk.begin(auth, ssid, pass);

}
 
void loop()
{
  Blynk.run();
}
  • Note: many people saying we are getting ESP8266WiFi.h unable to find ESP8266WiFi.h file
    after uploading the file also facing sam issue because you selected the wrong board
  • ESP8266WiFi.h library file support for ESP8266 NODEMCU Board not for ESP32_ Wroom_32

Output Images

By Admin

Leave a Reply

Your email address will not be published.

%d bloggers like this: