Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Home Automation using ESP32 & Blynk 2.0 with Real-Time Feedback
ESP32 Projects IoT Projects

Home Automation using ESP32 & Blynk 2.0 with Real-Time Feedback

Mamtaz AlamBy Mamtaz AlamUpdated:February 5, 20241 Comment6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Home Automation using ESP32 & Blynk 2.0 with Real-Time Feedback
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this IoT project, we will learn how to make an IoT-based Home Automation project using ESP32 and the new Blynk 2.0 IoT app to control a 4-channel relay module from the manual switch & smartphone. The project has Real-Time Feedback System. We can use the Blynk IoT app from anywhere in the world & using Internet Connectivity we can monitor the real-time feedback in Blynk 2.0 IoT App or Blynk cloud web dashboard.

This tutorial is all about Controlling Peripherals like AC Appliances or bulbs via Relay from Blynk 2.0 IoT App or Blynk cloud web dashboard using ESP32 WiFi Module. We would basically call it a Home Automation Project. Home automation is the automatic control of electronic devices in your home. These devices are connected to the Internet, which allows them to be controlled remotely. Earlier we made so many Home Automation projects which are as follows:

  • Home Automation with Arduino IoT Cloud & ESP32
  • Home Automation using Google Firebase & ESP8266
  • Home Automation using Blynk & ESP8266
  • Home Automation using ESP8266 WebServer
  • Home Automation using Android & ESP8266
  • Home Automation using ESP8266 & Alexa
  • Home Automation using ESP32 & AWS IoT Core
  • Home Automation using ESP32 & Alexa
  • Home Automation using ESP32 WebServer




Bill of Materials

For this project, we will need an ESP32 Board, 4 channel relay, and a few jumper wires. For the demo, we can use 4 bulbs with 4 holders or any other electrical appliances.

All the components can be easily purchased from Amazon through the below Amazon purchase links.

S.N.ComponentsQuantityPurchase Links
1ESP32 WiFi Module1Amazon | AliExpress
25V Relay4Amazon | AliExpress
3Push Button Switches4Amazon | AliExpress
47805 Voltage Regulator IC1Amazon | AliExpress
5DC Power Jack DCJ02021Amazon | AliExpress
6Diode 1N40074Amazon | AliExpress
7Resistor 330-ohm5Amazon | AliExpress
8NPN Transistor BC5474Amazon | AliExpress
9Terminal Block 5mm4Amazon | AliExpress
10LED 5mm Any Color1Amazon | AliExpress
11Female Header2 SetAmazon | AliExpress

Circuit Diagram & Hardware

The circuit for Home Automation using Blynk 2.0 & ESP32 with Real-Time Feedback is very simple. I used Fritzing software to draw the schematic. The below circuit diagram is the circuit that you need to Assemble.

Home Automation using ESP32 & Blynk 2.0 with Feedback

The ESP32 Board has so many GPIOs Pins. In this project, we will be using GPIO19, GPIO18, GPIO5 & GPIO17 for controlling the Relay. Across the output of the relay, we will use bulbs for testing and demo. You can use a 9V DC Adapter to power the circuit as the output of 7805 Voltage Regulator IC connects to Vin of ESP32.

Home Automation with Feedback

As a feedback system, there are 4 button switches connected directly to the ESP32 GPIO Pins. The ESP32 Pins used are GPIO27, GPIO14, GPIO12 & GPIO13.

Internet & Manual Control Home Automation System with Feedback



Project PCB Gerber File & PCB Ordering Online

If you don’t want to assemble the circuit on a breadboard and you want PCB for the project, then here is the PCB for you. I used EasyEDA to design the Schematic & PCB. The Schematic & PCB Board for ESP32 Home Automation using Blynk 2.0 looks something like the below.

Home Automation Schamatic Blynk 2.0

PCB Home Automation Blynk 2.0

The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from ALLPCB at 1$ only.

Download Gerber File: Home Automation PCB

You can use this Gerber file to order high quality PCB for this project. To do that visit the ALLPCB official website by clicking here: https://www.allpcb.com/.

You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.

After filling all details, select your country and shipping method. Finally you can place the order.


Blynk 2.0 Web & Mobile Dashboard Setup

Now let’s set up the Blynk Web Dashboard first. To do that visit blynk.io and sign up using the email ID.

First Add a New Device.

Select the first option, i.e. From Template.

Give Any Name to Template and Device and Click on Create.

A New Device will be created. A snip of the code header file will appear on the Dashboard. Copy and save this code as it will be used in the Arduino IDE.

Click on the Template logo and select the Template that you just created.

A template page will open. From this template Select the Web Dashboard.

From this page click on edit. Now we need to add the widget to the Dashboard.

Drag the widget called Switch from the left side and place it on the dashboard.

Create such 4 widgets as we have 4 relays to control.

Click on Setting Icon on Widget 1. The following page will open.

Give Title Name anything. For example Light1 or Realy1. And under the Datastream part, select Virtual Pin.

Under Datastream Section, Select Virtual Pin V0. Then Click on Create and then on Save.

Similarly, do the same for the remaining 3 widgets. Give them the names Light2, Light3, and Light4, and Select Virtual Pin as V1, V2, and V3 respectively. Click on Save and Apply to make changes to what setup has been made so far.

Now your Web Dashboard is Finally Ready.

Using this Web Dashboard, you can control your Home Appliances.

Apart from the Web Dashboard, you can also set up your Mobile App Dashboard. For that download the Blynk from Playstore or AppStore. And you can follow the video below to set up the Dashboard. The Mobile App Dashboard looks something like this.



Code/Program: ESP32 Blynk 2.0 Home Automation with Feedback

The source code or program for Home Automation using ESP32 & Blynk 2.0 with Real-Time Feedback System is written in Arduino IDE.
1. Blynk Library: https://github.com/blynkkk/blynk-library
2. AceButton Library: https://github.com/bxparks/AceButton

Now copy the following code and paste it on your Arduino IDE Sketch. But before that, you need to make modifications to the following lines.

1
2
3
#define BLYNK_TEMPLATE_ID "TMPLiEm_ytX0"
#define BLYNK_DEVICE_NAME "APP"
#define BLYNK_AUTH_TOKEN "a16wQs9JID48MryB6TdLaONpFgRw5ymo"

You can get these details from the Web Dashboard Setup.

Apart from these, modify the WiFi SSID and Password from the following lines.

1
2
char ssid[] = "*****************";
char pass[] = "*****************";

Now copy the following code and upload it to the ESP32 Board.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#define BLYNK_TEMPLATE_ID "TMPLiEm_ytX0"
#define BLYNK_DEVICE_NAME "APP"
#define BLYNK_AUTH_TOKEN "a16wQs9JID48MryB6TdLaONpFgRw5ymo"
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "*****************";
char pass[] = "*****************";
 
bool fetch_blynk_state = true;  //true or false
 
//#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <AceButton.h>
using namespace ace_button;
 
// define the GPIO connected with Relays and switches
#define RelayPin1 19  //D19
#define RelayPin2 18  //D18
#define RelayPin3 5  //D5
#define RelayPin4 17  //D17
 
#define SwitchPin1 27  //D27
#define SwitchPin2 14  //D14
#define SwitchPin3 12  //D12
#define SwitchPin4 13  //D13
 
#define wifiLed   2   //D2
 
//Change the virtual pins according the rooms
#define VPIN_BUTTON_1    V1
#define VPIN_BUTTON_2    V2
#define VPIN_BUTTON_3    V3
#define VPIN_BUTTON_4    V4
 
// Relay State
bool toggleState_1 = LOW; //Define integer to remember the toggle state for relay 1
bool toggleState_2 = LOW; //Define integer to remember the toggle state for relay 2
bool toggleState_3 = LOW; //Define integer to remember the toggle state for relay 3
bool toggleState_4 = LOW; //Define integer to remember the toggle state for relay 4
 
int wifiFlag = 0;
 
char auth[] = BLYNK_AUTH_TOKEN;
 
ButtonConfig config1;
AceButton button1(&config1);
ButtonConfig config2;
AceButton button2(&config2);
ButtonConfig config3;
AceButton button3(&config3);
ButtonConfig config4;
AceButton button4(&config4);
 
void handleEvent1(AceButton*, uint8_t, uint8_t);
void handleEvent2(AceButton*, uint8_t, uint8_t);
void handleEvent3(AceButton*, uint8_t, uint8_t);
void handleEvent4(AceButton*, uint8_t, uint8_t);
 
BlynkTimer timer;
 
// When App button is pushed - switch the state
 
BLYNK_WRITE(VPIN_BUTTON_1)
{
  toggleState_1 = param.asInt();
  digitalWrite(RelayPin1, !toggleState_1);
}
 
BLYNK_WRITE(VPIN_BUTTON_2)
{
  toggleState_2 = param.asInt();
  digitalWrite(RelayPin2, !toggleState_2);
}
 
BLYNK_WRITE(VPIN_BUTTON_3)
{
  toggleState_3 = param.asInt();
  digitalWrite(RelayPin3, !toggleState_3);
}
 
BLYNK_WRITE(VPIN_BUTTON_4)
{
  toggleState_4 = param.asInt();
  digitalWrite(RelayPin4, !toggleState_4);
}
 
void checkBlynkStatus()
{ // called every 3 seconds by SimpleTimer
 
  bool isconnected = Blynk.connected();
  if (isconnected == false)
  {
    wifiFlag = 1;
    Serial.println("Blynk Not Connected");
    digitalWrite(wifiLed, LOW);
  }
  if (isconnected == true)
  {
    wifiFlag = 0;
    if (!fetch_blynk_state)
    {
      Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
      Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
      Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
      Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
    }
    digitalWrite(wifiLed, HIGH);
    Serial.println("Blynk Connected");
  }
}
 
BLYNK_CONNECTED()
{
  // Request the latest state from the server
  if (fetch_blynk_state)
  {
    Blynk.syncVirtual(VPIN_BUTTON_1);
    Blynk.syncVirtual(VPIN_BUTTON_2);
    Blynk.syncVirtual(VPIN_BUTTON_3);
    Blynk.syncVirtual(VPIN_BUTTON_4);
  }
}
 
void setup()
{
  Serial.begin(9600);
 
  pinMode(RelayPin1, OUTPUT);
  pinMode(RelayPin2, OUTPUT);
  pinMode(RelayPin3, OUTPUT);
  pinMode(RelayPin4, OUTPUT);
 
  pinMode(wifiLed, OUTPUT);
 
  pinMode(SwitchPin1, INPUT_PULLUP);
  pinMode(SwitchPin2, INPUT_PULLUP);
  pinMode(SwitchPin3, INPUT_PULLUP);
  pinMode(SwitchPin4, INPUT_PULLUP);
 
  //During Starting all Relays should TURN OFF
  digitalWrite(RelayPin1, !toggleState_1);
  digitalWrite(RelayPin2, !toggleState_2);
  digitalWrite(RelayPin3, !toggleState_3);
  digitalWrite(RelayPin4, !toggleState_4);
 
  digitalWrite(wifiLed, LOW);
 
  config1.setEventHandler(button1Handler);
  config2.setEventHandler(button2Handler);
  config3.setEventHandler(button3Handler);
  config4.setEventHandler(button4Handler);
 
  button1.init(SwitchPin1);
  button2.init(SwitchPin2);
  button3.init(SwitchPin3);
  button4.init(SwitchPin4);
 
  //Blynk.begin(auth, ssid, pass);
  WiFi.begin(ssid, pass);
  timer.setInterval(2000L, checkBlynkStatus); // check if Blynk server is connected every 2 seconds
  Blynk.config(auth);
  delay(1000);
 
  if (!fetch_blynk_state) {
    Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
    Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
    Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
    Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
  }
}
 
void loop()
{
  Blynk.run();
  timer.run(); // Initiates SimpleTimer
 
  button1.check();
  button2.check();
  button3.check();
  button4.check();
}
 
void button1Handler(AceButton* button, uint8_t eventType, uint8_t buttonState)
{
  Serial.println("EVENT1");
  switch (eventType)
  {
    case AceButton::kEventReleased:
      Serial.println("kEventReleased");
      digitalWrite(RelayPin1, toggleState_1);
      toggleState_1 = !toggleState_1;
      Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
      break;
  }
}
 
void button2Handler(AceButton* button, uint8_t eventType, uint8_t buttonState)
{
  Serial.println("EVENT2");
  switch (eventType)
  {
    case AceButton::kEventReleased:
      Serial.println("kEventReleased");
      digitalWrite(RelayPin2, toggleState_2);
      toggleState_2 = !toggleState_2;
      Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
      break;
  }
}
 
void button3Handler(AceButton* button, uint8_t eventType, uint8_t buttonState)
{
  Serial.println("EVENT3");
  switch (eventType)
  {
    case AceButton::kEventReleased:
      Serial.println("kEventReleased");
      digitalWrite(RelayPin3, toggleState_3);
      toggleState_3 = !toggleState_3;
      Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
      break;
  }
}
 
void button4Handler(AceButton* button, uint8_t eventType, uint8_t buttonState)
{
  Serial.println("EVENT4");
  switch (eventType)
  {
    case AceButton::kEventReleased:
      Serial.println("kEventReleased");
      digitalWrite(RelayPin4, toggleState_4);
      toggleState_4 = !toggleState_4;
      Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
      break;
  }
}


Testing the ESP32 Blynk 2.0 Home Automation Project

Once the code is uploaded, you can start testing the project.

Home Automation Blynk 2.0 with Feedback

The ESP32 will connect to the WiFi Network and establishes the Connection with Blynk Web and Mobile Dashboard.

Now you can turn ON/OFF the relays from the Mobile and Web Dashboard. You just need to click the Dashboard button.

Home Automation Blynk 2.0 with Manual Feedback System

Apart from the Dashboard part, you can also press the Push Buttons manually to turn ON/OFF the Relay. The manual pressing will also be reflected on the Mobile/Web Dashboard.

This is how you can implement the Internet & Manual Control Home Automation System Project with Real-Time Feedback using ESP32 & New Blynk 2.0 IoT App.


Video Tutorial & Guide

Home Automation using ESP32 & Blynk 2.0 with Real-Time Feedback
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleSX1272 Based LoRa USB Dongle Gateway 868/915MHz
Next Article The processes of PCB Design that you should know

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 14, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

Updated:June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20261K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
View 1 Comment

1 Comment

  1. Jade on December 11, 2022 3:52 PM

    Hi, may I know. What board do I need to choose when I use arduino ide software for my esp32 wroom with external antenna ?

    Reply

CommentsCancel reply

Latest Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 14, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU
    High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.