Home > Projects > Home Automation Projects > Oct Home Automation using ESP8266 & Blynk App – IoT

Oct Home Automation using ESP8266 & Blynk App – IoT

Summary of Oct Home Automation using ESP8266 & Blynk App – IoT


This article details a home automation project using an ESP8266 microcontroller and the Blynk Android app to control appliances via WiFi. The system enables remote management of devices, reducing human effort while improving energy efficiency and saving time.

Parts used in Home Automation using ESP8266 & Blynk App:

  • ESP8266 (NodeMCU)
  • 470Ω Resistor
  • LED
  • Breadboard
  • USB Cable
  • Connecting Wires
  • Android Phone with Blynk App
  • 4-Channel Relay Board
  • AC Mains Appliances (Bulbs)

home automation system is an automating the bulk of electronic and electrical tasks within a home. It uses a combination of hardware and software to enable control and management over appliances and devices within a home.

Home automation not only refers to reduce human efforts but also energy efficiency and time saving. Here we are performing home automation by using ESP8266 – WiFi SoC and Blynk Playstore App.

Components Required

  • ESP8266
  • 470Ω Resistor
  • LED
  • Breadboard
  • USB Cable
  • Connecting Wires
  • Android Phone with Blynk App

Hardware

Circuit Diagram

Home-Automation-using-using-ESP8266-Blynk-App-Circuit-Diagram

Circuit Diagram Explanation

NodeMCU to 4- Channel Relay Board

  • Connect D0 pin of NodeMCU to D1 pin of 4- Channel Relay board.
  • Connect D1 pin of NodeMCU to D2 pin of 4- Channel Relay board.
  • Connect D2 pin of NodeMCU to D3 pin of 4- Channel Relay board.
  • Connect D3 pin of NodeMCU to D4 pin of 4- Channel Relay board.
  • Connect 3.3V of NodeMCU to Vcc pin of 4- Channel Relay board.
  • Connect GND pin of NodeMCU to GNDpin of 4- Channel Relay board.

Software

Blynk Library Installation

  1. Download the zip file for Blynk Library : Blynk_Release_v0.4.8
  2. Extract the downloaded zip file in a folder.
  3. Open up Arduino IDEgo to: File -> Preferences and under the Settings tab, copy the sketchbook location path.
  4. Now open the file explorer and go to the copied path location. This is the path where all the libraries are installed. So, we have to copy all the newly downloaded Blynk libraries into this folder.
    • Copy the files/folders from the Libraries folder of the downloaded Blynk directory, and paste it to the Libraries folder of your Arduino IDE’s directory (The path which we copied in step 3).
    • Similarly, copy the files/folder from the Tools folder of the downloaded Blynk directory, and paste it to the Tools folder of your Arduino IDE’s directory.

Installation and Configuration of Blynk App

  1. Firstly install “Blynk” application from play-store and open it.
  2. Create an account by using Email account or Facebook account.
  3. Click on New Project, enter the Project Name (enter the Project Name according to your wish) as “Home Automation“, Choose Device as “NodeMCU“, Connection Type as “Wi-Fi” and then click “Create” icon.
  4. After the creation of Project, App will send the Auth Token code to registered Email ID.
  5. Click on the “+” icon which located on top right side of the app to create buttons.
  6. Enter the button name and select the GPIO pins (exmaple: D0, D1, D2, D3)

Programming ESP8266 – Blynk App

Arduino Code

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = “YourAuthToken”;

char ssid[] = “YourNetworkName”;
char pass[] = “YourPassword”;

void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}

void loop()
{
Blynk.run();
}

Code Explanation

We are including ESP8266 WiFi library which provides ESP8266 specific WiFi routines and we are calling it to connect to the network. BlynkSimpleEsp8266 library establishes the communication between Blynk App and ESP8266.

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
Get and enter Auth Token which is received from the Blynk App while creating a Project.
char auth[] = “YourAuthToken”;
Get and enter the “ssid” and “password” i.e.,  your WiFi name and password.
char ssid[] = “SERVER NAME”;
char pass[] = “SERVER PASSWORD”;
Put your setup or configuration code in the setup function, it will only run once during the startup.
Here in the setup function, it will initialize serial communication for debugging and logging with a baud rate of 115200. This begins the connection for respective Blynk Auth Token, Server Name and Server Password.
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}

Put your main code in void loop() function to run repeatedly. This continuously runs with Blynk App commands.
void loop()
{
Blynk.run();
}

Working

The home automation circuit is built around ESP8266, Blynk Android App, and a 4-channel relay board. The hardware set up should be according to the circuit diagram. AC mains appliances(Bulbs) will be connected to relays which are controlled by the ESP8266.

User has to install and configure the Blynk App as per the above instructions.

Whenever the user presses a icon in the app, then that information will be send to ESP8266 via WiFi. The ESP8266 analyses the received commands and turns ON/OFF of the respective device via 4 – channel Relay board.
Read More Information…..

Quick Solutions to Questions related to Home Automation using ESP8266 & Blynk App:

  • What is the primary purpose of this home automation system?
    The system automates electronic tasks to reduce human effort, improve energy efficiency, and save time.
  • How do I install the Blynk Library in Arduino IDE?
    Download the zip file, extract it, locate the sketchbook path in Preferences, and copy the Libraries and Tools folders into the corresponding directories.
  • Which device should be selected when creating a new project in the Blynk App?
    You must choose NodeMCU as the device type when setting up the project.
  • How are the GPIO pins on the NodeMCU connected to the relay board?
    D0 connects to D1, D1 to D2, D2 to D3, and D3 to D4 on the relay board.
  • Where does the user find the Auth Token required for the code?
    The Auth Token is sent to the registered email address after creating a project in the Blynk App.
  • What happens when a user presses an icon in the Blynk App?
    The command is sent via WiFi to the ESP8266, which analyzes it and turns the respective device ON or OFF via the relay board.
  • Which libraries are included in the provided Arduino code?
    The code includes the ESP8266WiFi library and the BlynkSimpleEsp8266 library.
  • What is the function of the void loop() in the code?
    The void loop() function runs repeatedly to continuously execute commands received from the Blynk App.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top