ESP32 home automation using IoT

Home Automation using IoT with Blynk ESP32 and sensors

Make Home Automation using IoT with new Blynk 2.0 ESP32, DHT11 sensor, LDR with real-time feedback, No WiFi control with IR remote & Switch.

In this ESP32 project, I have explained how to make home automation using IoT with the new Blynk 2.0 ESP32, DHT11 sensor, and LDR. with real-time feedback. With this IoT-based project, you can control 8 home appliances with the manual switches, IR remote, and Blynk IoT app from anywhere in the world through the internet and monitor the real-time feedback in Blynk IoT App or Blynk cloud web dashboard. You can also control the appliances from manual switches and IR remote without Wi-Fi.

Home automation using IoT with Blynk ESP32

I have used all the FREE tools for this ESP32 home automation project using Blynk IoT.

So if you follow all the steps, you can easily make this Smart Home System with ESP32 and Blynk app.

Required Components for the ESP32 projects

components ESP32 home automation projects P2
  • ESP32 DEV KIT V1
  • 8-channel 5V SPDT Relay Module
  • TSOP1838 IR receiver (with metallic casing)
  • DHT11 sensor
  • LDR
  • Switches or Push Buttons
  • Any IR Remote

Circuit of the ESP32 Home Automation using IoT

Circuit of ESP32 Home Automation projects

The circuit is very simple, I have used D23, D22, D21, D19, D18, D5, D25 & D26 GPIO to control the 8-channel relay module.

And the GPIO D13, D12, D14, D27, D33, D32, D15 & D4 are connected with switches to control the relay module manually.

The output pin of the IR receiver is connected with GPIO D35.

And the output pin of the DHT11 sensor is connected with the RX2 (GPIO16) pin, and the LDR is connected with GPIO D34 of the ESP32.

I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors with each switch.

As per the source code, when the control pins of the relay module receive the LOW signal the relay will turn on and the relay will turn off for the HIGH signal in the control pin.

I have used a 5V 5Amp mobile charger to supply the circuit.

Tutorial video on ESP32 Blynk IoT Home Automation project

In the tutorial video, I have covered the following topics in detail.

  • Create an account at Blynk IoT Cloud.
  • Create a template for ESP32 in Blynk IoT Cloud.
  • Set up Blynk Cloud Web Dashboard.
  • Install and set up Blynk IoT App in mobile.
  • Program the ESP32 with Arduino IDE
  • Update the Wi-Fi credentials to ESP32 through OTA.
  • Control relays with Blynk IoT app, IR Remote, and switches.

Control relays with the New Blynk IoT, IR Remote & Switch

control relays with New Blynk IoT
control relays with Blynk IoT app

You can control appliances with the New Blynk IoT app from anywhere in the world through the internet.

If the ESP32 is connected with WiFi, then you can also monitor the real-time feedback and room temperature in the Blynk IoT app.

IR remote control relays
Control relays with IR Remote

You can use any IR remote to control the appliances.

First, get the HEX codes of unused IR Remote buttons, then update the HEX codes in the code.

If the Wi-Fi is not connected, still you can control relays with the IR remote.

Control relays with switches
Control relays with switches

You can also control the appliances from manual switches.

If the ESP32 is connected to Wi-Fi then it will send real-time feedback to the Blynk IoT server.

Blynk IoT Cloud setup for ESP32

Please refer to the following article for the Blynk IoT Cloud account setup.

Getting started with New Blynk 2.0 IoT platform

Program ESP32 with Arduino IDE

In the Tutorial video, I explained all the steps to program the ESP32 using Arduino IDE.

  1. Update the Preferences –> Aditional boards Manager URLs: https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
  2. Then install the ESP32 board from the Board manager or Click Here to download the ESP32 board.
  3. Install all the required libraries in Arduino IDE:
    • Install the Blynk Library (1.0.1) from Include Library or Click Here to download it.
    • Install the IRremote Library (3.3.0) from Include Library or Click Here to download.
    • Install the DHT Library (1.4.2) from Include Library or Click Here to download it.

You can also install the libraries from the following path in Arduino IDE:
Sketch -> Include Libraries -> Manage Libraries.

When you try to install the Blynk library, it may ask you to install all the dependencies. Then Click on Install All.

Code for Blynk IoT Cloud ESP32 home automation

Click on the following buttons to download the source codes for this ESP32 project.

First, you have to upload the Code for Getting HEX codes to ESP32 and connect the IR receiver with GPIO D35.

Get HEX code from IR Remote

After that, open the serial monitor, select the Baud Rate at 9600.

Now, you have to press all the remote buttons (one by one) which you want to use to control the relays.

Now, save all the HEX codes. You have to update the main code with these HEX codes. You need 8 HEX codes to control 8 relays.

Modify the main code for this IoT based project

code of new Blynk ESP32 projects

After downloading the code, you will get total 9 files. ( 1 .ino & 8 .h files). You have to keep all these files in the same folder.

Then open the .ino file in Arduino IDE, select the DOIT ESP32 DEVKIT V1 board then compile the code. If you have downloaded all the required libraries then you should not get any error.

update BLYNK_TEMPLATE_ID

In code, you have to update only the BLYNK_TEMPLATE_ID & BLYNK_DEVICE_NAME as shown in the video. You don’t have to enter the W-Fi credentials in the code.

Open the BlynkEdgent.h file, then update the HEX codes in the ir_remote() function.

ESP32 Blynk 2 Home automation pic 11

Copy paste the HEX code after 0x [Ex: 0x[your HEX code]].

After doing these changes, go to Tools and select the board as “DOIT ESP32 DEVKIT V1” and the proper PORT in Arduino IDE.

Then click on the upload button to program the ESP32 board.

In the tutorial video, I have explained, how to update Wi-Fi credentials from Blynk IoT app.

PCB for this ESP32 Home Automation system

Solder the Components on PCB

To make the circuit compact, I have designed a PCB for this ESP32 project.

If you want, you can also use this PCB to make the circuit compact and give the project a professional look. This PCB can be used for any ESP32 Home Automation project.

PCBWay 750x161 Banner

About PCBWay and their services

PCBWay not only produce FR-4 and Aluminum boards, but also advanced PCB like Rogers, HDI, Flexible and Rigid-Flex boards, with very reasonable price.
For the online instant quote page please visit – pcbway.com/orderonline
Inspect your Gerber file before placing the order – OnlineGerberViewer

You may order as small as 5pcs of PCB from PCBWay. You can place an order as per your requirement.

You can explore different useful PCB projects from PCBWay Open-source community – pcbway.com/project

For more details please visit the following articles.
Why PCBway
PCB Capabilities
High-Quality PCB

Connect Home Appliances with Relay Module

ESP32 PCB connections

Connect the home appliances with the relay module as per the circuit diagram.

Now, turn on the 5V DC supply and 110V/220V AC supply.

Our ESP32 Blynk Home Automation system is now ready

ESP32 Blynk Home Automation system

Now you can control the appliances from your smarphone, IR remote and manual switches.

Please share your feedback on this ESP32 home automation system.

Click Here for more such ESP32 projects.

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