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 with Arduino IoT Cloud using ESP32
ESP32 Projects IoT Projects

Home Automation with Arduino IoT Cloud using ESP32

Mamtaz AlamBy Mamtaz AlamUpdated:February 5, 20241 Comment6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Home Automation Arduino IoT Cloud ESP32
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview: Home Automation with Arduino IoT Cloud & ESP32

In this project, we will learn about the application of Arduino IoT Cloud with ESP32. Recently the Arduino Community launched their IoT platform called Arduino IoT Cloud. You can connect multiple devices to each other and allow them to exchange real-time data. You can also monitor data from anywhere using a simple user interface. To learn more about the Arduino IoT Cloud, you can go through the documentation part.

As an example, you can control multiple home appliances from the Arduino IoT Cloud Dashboard. We will interface a 4 channel relay with ESP32 WiFI Module & send the ON/OFF commands either from the mobile phone dashboard or from Computer Dashboard and Control Relay, Light, or anything else. So, let’s see how can deploy this entire system. To know more about the Arduino IoT Cloud, you can refer the article Getting Started Tutorial


But before that, you can check some of our Home Automation Projects made using ESP8266 or ESP32:
1. Home Automation using NodeMCU & Alexa
2. Home Automation using NodeMCU & Android
3. Home Automation using ESP8266 WebServer
4. Home Automation using Blynk & NodeMCU
5. Home Automation using Google Firebase & NodeMCU
6. Home Automation using AWS IoT Core & ESP32
7. Home Automation using Alexa & ESP32
8. Home Automation using ESP32 WebServer


Bill of Materials

For this project, we will need an ESP32 Board, 4 channel relay, few jumper wires and breadboard. For 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.Components NameQuantityPurchase Links
1ESP32 WiFi Module1Amazon | AliExpress
2Relay 5V 4Amazon | AliExpress
37805 Voltage Regulator 1Amazon | AliExpress
4DC Power Jack DCJ02021Amazon | AliExpress
5Diode 1N40074Amazon | AliExpress
6Resistor 330-ohm5Amazon | AliExpress
7BC547 NPN Transistor4Amazon | AliExpress
8Terminal Block 5mm4Amazon | AliExpress
9LED 5mm Any Color1Amazon | AliExpress
10Female Header 2.54mm2 SetAmazon | AliExpress

Circuit Diagram & Hardware

The circuit for Home Automation using Arduino IoT Cloud & ESP32 is very simple. I used Fritzing software to draw the schematic. The below diagram is only for the breadboard Assembly.

Home Automation ESP32

The ESP32 Board has so many GPIOs Pins. In this project, we will be using GPIO19, GPIO21, GPIO22 & GPIO23 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 Arduino IoT Cloud ESP32




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 PCB. The PCB Board for Home Automation with ESP32 looks something like below.

Home Automation ESP32 PCB

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: ESP32 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.

You can assemble the components on the PCB Board.


Setting Up Arduino IoT Cloud Dashboard

Now it’s time to set up the Arduino IoT Cloud Dashboard. Go to the Arduino Store. Click on IoT Cloud.

Then you need to create a Thing first. To do that click on add variable.

Name the variable anything like Light1. In the variable type select bool. So an automatic variable declaration will be done. Then click on Add variable. The first variable is created.

Similarly create other three variables with names Light2, Light3, Light4.

Now, we need to configure a device as well. For that select the device option. From the list select a 3rd party device. Then select ESP32. From this list select ESP32 Developer Module.

Click to continue and give any name to the device. Then click Next. So device ID & Secret Key is created here. Save this device ID for the coding part. Or simply download this PDF File which has the information of Secret Key. Then click on continue.

Now again you need to set up the Network Credentials. So input your SSID, Password as well as Secret Key that you created earlier. Finally, everything is set now.

Go to the dashboard. Here we need to build a dashboard.

From the edit option add a variable. So select switch.

Give it any name. Then link a variable. Click on Done.

Similarly, add 3 more variables for 3 different switches and link the variable to them. You can arrange the widget or resize the widget as you wish.

So finally you are done. The dashboard setup is ready.



Source Code/Program

Now let’s go to the sketch for Home Automation with Arduino IoT Cloud & ESP32.

There are 4 variables with bool automatically declared.

1
2
3
4
  bool light1;
  bool light2;
  bool light3;
  bool light4;

In the setup part, we will define 4 pins of ESP32 as output. Those 4 pins are pins 19, 21, 22, and 23.

1
2
3
4
  pinMode (19, OUTPUT);
  pinMode (21, OUTPUT);
  pinMode (22, OUTPUT);
  pinMode (23, OUTPUT);

Initialize them with high logic, so that all appliances are turned off initially.

1
2
3
4
  digitalWrite (19, HIGH);
  digitalWrite (21, HIGH);
  digitalWrite (22, HIGH);
  digitalWrite (23, HIGH);

Below the void Light function, assign a condition that if the command from the Arduino IoT Cloud Dashboard Pin is high, the relay should turn ON. Else if the command is low, the relay should turn OFF.

1
2
3
4
5
6
7
8
  if (light1==1)
  {
    digitalWrite (19, LOW);
  }
  else
  {
    digitalWrite (19, HIGH);
  }

Here is the complete code that you can use for this project.


Home_Automation.ino

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
#include "arduino_secrets.h"
/*
  Sketch generated by the Arduino IoT Cloud
  https://cloud.arduino.cc/
 
  Arduino IoT Cloud Variables description
 
  The following variables are automatically generated and updated when changes are made to the Thing
 
  bool light1;
  bool light2;
  bool light3;
  bool light4;
 
  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/
 
#include "thingProperties.h"
 
void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  pinMode (19, OUTPUT);
  pinMode (21, OUTPUT);
  pinMode (22, OUTPUT);
  pinMode (23, OUTPUT);
  
  digitalWrite (19, HIGH);
  digitalWrite (21, HIGH);
  digitalWrite (22, HIGH);
  digitalWrite (23, HIGH);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);
 
  // Defined in thingProperties.h
  initProperties();
 
  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
*/
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}
 
void loop() {
  ArduinoCloud.update();
  // Your code here
  
  
}
 
void onLight1Change()
{
  if (light1==1)
  {
    digitalWrite (19, LOW);
  }
  else
  {
    digitalWrite (19, HIGH);
  }
}
 
void onLight2Change()
{
  if (light2==1)
  {
    digitalWrite (21, LOW);
  }
  else
  {
    digitalWrite (21, HIGH);
  }
}
 
void onLight3Change()
{
  if (light3==1)
  {
    digitalWrite (22, LOW);
  }
  else
  {
    digitalWrite (22, HIGH);
  }
}
 
void onLight4Change()
{
  if (light4==1)
  {
    digitalWrite (23, LOW);
  }
  else
  {
    digitalWrite (23, HIGH);
  }
}


thingProperties.h

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
// Code generated by Arduino IoT Cloud, DO NOT EDIT.
 
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
 
 
const char THING_ID[]           = "86fc6944-21a5-4447-a980-125dc1b15276";
const char DEVICE_LOGIN_NAME[]  = "7a1770df-b86b-46df-b8de-5a3603eb8d68";
 
const char SSID[]               = SECRET_SSID;    // Network SSID (name)
const char PASS[]               = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[]  = SECRET_DEVICE_KEY;    // Secret device password
 
void onLight1Change();
void onLight2Change();
void onLight3Change();
void onLight4Change();
 
bool light1;
bool light2;
bool light3;
bool light4;
 
void initProperties(){
 
  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(light1, READWRITE, ON_CHANGE, onLight1Change);
  ArduinoCloud.addProperty(light2, READWRITE, ON_CHANGE, onLight2Change);
  ArduinoCloud.addProperty(light3, READWRITE, ON_CHANGE, onLight3Change);
  ArduinoCloud.addProperty(light4, READWRITE, ON_CHANGE, onLight4Change);
 
}
 
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);


arduino_secrets.h

1
2
3
#define SECRET_SSID ""
#define SECRET_PASS ""
#define SECRET_DEVICE_KEY ""



Apart from the code part, we need to upload the code. But before that, we need to install a driver or install an Agent to flash the code directly from the browser. Follow the instruction on your screen to install the agent.

Once the driver is installed, the COM port will appear. Then select the ESP32 Developer Board from the list and the COM port as well. Then, upload the code. It will take some time to upload the code and when it’s done, some message will appear below the window.


Testing: Home Automation with Arduino IoT Cloud & ESP32

After uploading the code, open the Serial Monitor. It will show WiFi connection is established and then the device is connected to Arduino IoT Cloud Dashboard.

Open the dashboard now, so you can see the switch can be turned ON and OFF or enabled or disabled. You can do the initial testing. Here we can send the command to see whether the on-board LED from the Relay will turn ON or not.

You can control the light bulb from Mobile Dashboard. For that install Arduino IoT Remote from Playstore. Sign in using the same ID and password.

Go to the dashboard to control the appliances easily.


Video Tutorial & Guide

Arduino IoT Cloud Based Home Automation & Appliances Control Project using ESP32
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleGetting Started with Arduino IoT Cloud with ESP8266
Next Article MQTT Based Wind Weather Station using GSM & Arduino

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 21, 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, 20262K
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. anurag tewary on December 8, 2022 11:26 AM

    i am unabl to upload it in esp32 an error is comming up as “exit ststus2″ and this is the out put”/usr/local/bin/arduino-cli compile –fqbn esp32:esp32:esp32doit-devkit1 –libraries /home/builder/opt/libraries/latest –build-cache-path /tmp –output-dir /tmp/916356812/build –build-path /tmp/arduino-build-2E65C2370C665C07D5691E44416140D8 /tmp/916356812/home_dec06a

    Sketch uses 891641 bytes (68%) of program storage space. Maximum is 1310720 bytes.

    Global variables use 40524 bytes (12%) of dynamic memory, leaving 287156 bytes for local variables. Maximum is 327680 bytes.

    Upload started

    Programming with: Serial

    Flashing with command:C:/Users/at350/.arduino-create/esp32/esptool_py/4.2.1/esptool.exe –chip esp32 –port COM5 –baud 921600 –before default_reset –after hard_reset write_flash -z –flash_mode dio –flash_freq 80m –flash_size 4MB 0x1000 C:/Users/at350/AppData/Local/Temp/extrafiles586069348/home_dec06a.bootloader.bin 0x8000 C:/Users/at350/AppData/Local/Temp/extrafiles586069348/home_dec06a.partitions.bin 0xe000 C:/Users/at350/AppData/Local/Temp/extrafiles586069348/tools/partitions/boot_app0.bin 0x10000 C:/Users/at350/AppData/Local/Temp/arduino-create-agent090310105/home_dec06a.bin

    esptool.py v4.2.1

    Serial port COM5

    Connecting……

    Chip is ESP32-D0WD (revision 1)

    Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None

    Crystal is 40MHz

    MAC: 8c:4b:14:5b:51:d4

    Uploading stub…

    Running stub…

    Stub running…

    Changing baud rate to 921600

    Changed.

    WARNING: Failed to communicate with the flash chip, read/write operations will fail. Try checking the chip connections or removing any other hardware connected to IOs.

    Configuring flash size…

    Flash will be erased from 0x00001000 to 0x00005fff…

    Flash will be erased from 0x00008000 to 0x00008fff…

    Flash will be erased from 0x0000e000 to 0x0000ffff…

    Flash will be erased from 0x00010000 to 0x000ebfff…

    Flash params set to 0x022f

    Compressed 17440 bytes to 12090…

    A fatal error occurred: Packet content transfer stopped (received 8 bytes)”

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 21, 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
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 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 INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • LD2410 Sensor with ESP32 - Human Presence Detection
    LD2410 Sensor with ESP32 - Human Presence Detection
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
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.