ESP32 Home Automation System With Temperature

We come up with another Home Automation project with a temperature-sensing ability. In this project, we are going to build an ESP32 Home Automation System with the latest Blynk 2.0 and ESP32 development board. This time you can control upto four load appliances with the manual switches and Blynk app from anywhere in the world through the internet connection. You can see real-time feedback on the Blynk app or through your monitor. When you have no internet or WiFi connection, you can just use it manually.

Circuit Diagram

ESP32 Home Automation System Circuit Diagram
ESP32 Home Automation System Circuit Diagram

Components Required

  • ESP32 Development Board
  • TSOP1838 IR Sensor
  • LDR (Light Dependent Resistor)
  • DHT11 Temperature & Humidity Sensor
  • 5V Hi-Link AC-DC Converter
  • 5V Relay (x4) / 4-Channel Relay Module
  • Green LED (x4)
  • Red LED (x4)
  • 10 KOhm Resistor
  • 100 Ohm Resistor (x8)
  • 1 KOhm Resistor (x4)
  • IN4007 PN Diode (x4)
  • BC547 NPN Transistor (x4)
  • Push Switch (x4)
  • Veroboard

About Parts

ESP32 Development Board


It is a low-cost, minimal-power system on a microcontroller with integrated Wi-Fi and Bluetooth facility. ESP32 is created and developed by Espressif Systems, a Shanghai-based Chinese company, and it is manufactured by TSMC using its 40nm chip technology. In this project, we can use ESP8266 NodeMCU but there is only one analog pin that comes with it. And ESP32 have so many analog pins. So according to our needs (Voltage and Current), we choose ESP32 in spite of ESP8266 NodeMCU.

DHT11 Temperature & Humidity Sensor

dht11 temperature & humidity sensor

It is a very accurate and low-cost temperature sensor that can measure both real-time temperature and humidity of surroundings. The supply voltage of this sensor is +5V.

TSOP1838 IR Sensor

tsop1838 sensor

This is a type of IR receiver which has an inbuilt amplifier. It acts as a switch and converter. TSOP1838 has three pins, which are GND, VSS, and Output. Its operating frequency is 38 KHz. TSOP1838 is a modified version of TSOP1738, so you can use both of them.

Circuit Connection for ESP32 Home Automation System

The circuit connection of this project is very simple. We used D23, D22, D21 and D19 GPIO pins to control (ON/OFF) the relay module. Also connect D13, D12, D14 and D27 GPIO pins with the switches to control this esp32 home automation system manually.

The TSOP1838 IR receiver is connected with pin D35. We connect the DHT11 temperature & humidity sensor to the RX2 or pin16 of the ESP32. The LDR is connected to pin D34.

In this project, we use the INPUT_PULLUP function in Arduino IDE in the place of pull-up resistors with every switch. The supply voltage is +5V for this circuit.

PCB Design

For removing messy wiring and giving a clean look, I designed a PCB prototype for this project. It is also helpful for troubleshooting that runs great without any errors. To design this PCB board, I used EasyEDA as it is too easy to use. For ordering PCB for this, I prefer PCBWay.

Gerber file for ESP32 Home Automation System Gerber.

PCB View

ESP32 Home Automation System 2D View
2D View
ESP32 Home Automation System 3D View
3D View

Order PCB From PCBWay

There are so many forums or communities for electronics online in today’s technical world, and one of the famous ones for PCB manufacturing is PCBWay. PCBWay is a place that brings manufacturers and customers together. They have more than a decade of experience in this field of fabrication, prototyping and assembling PCBs. PCBWay has proved its focus on its customers’ needs in terms of cost-effectiveness, delivery, and quality.

How PCB Manufacturing Process Done in PCBWay

Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity through quality control in designing and manufacturing. At first, they ensure the accuracy, clarity, and validity of the PCB files that we sent to them.

Then all the boards will go through the most stringent tests other than the basic visual check. They adopt most of the testing and inspecting equipment used in the industry, such as Flying Probe Testers, X-Ray Inspection Machines, and Automated Optical Inspection (AOI) Machines. PCBWay are having 50+ new engineers on the daily basis around the world using PCBs for their work, who trust their reliable quality. They produce high-quality pink, orange, grey, and even transparent solder mask. Moreover, according to people’s needs, they can also provide Black core PCB. Check it out for a High-Quality PCB solder mask. There are some pictures below of the new colours of solder musks.

Features of PCBWay

PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, and Flexible and Rigid-Flex boards, at a very reasonable price. Just check this Instant Quote to order premium PCBs for your hobby projects.

PCB Assembly: It not only offers PCB Prototyping but also offers PCB Assembly service. You can order a full PCB board with attached components by uploading your file. SMT & THT assembly starts from only 30$ including free stencil and worldwide shipping. The components can be sourced and provided by PCBWay, or by the clients themselves.

Open Source Community: It not only offers PCB Prototype & Assembly services but also gives opportunities to students for sponsorships. I think this is so great. They feature their projects on the website also.

3D Printing & CNC: It also produces Rapid Prototyping like 3D printing, CNC Machining, Sheet Metal Fabrication, and Injection Molding. The quality of the product is too premium and reliable. And also the best part is that you will receive your order within a minimum of 3 days.

PCBWay Store: More boutique gift modules are waiting for you to discover, giving your creativity wings. You can order all types of electronic equipment, components and many more with exciting offers. Go with the link and buy your needs, PCBWay Store.

Services: PCBWay offers great servicing of its products. It takes only 3 to 15 days according to the courier service to deliver your products. Also, it has a live support facility. Whenever you have any problems, you can always reach a live customer service person to respond to your emails or messages. They have the “Return and Refund” principle, for every unusable board caused by PCBWay, they will rebuild and refund the order soon.

How To Configure IR Remote With The Relays

  • First, you have to upload the code to ESP32 using Arduino IDE and connect the IR receiver with GPIO pin D35.
  • Then open the serial monitor and select Baud rate at 9600.
  • Now start to press all the remote buttons one by one which you want to control the keys.
  • Save all the HEX codes.
  • Now you have to update the main code with the HEX codes. You need 4 HEX codes to control 4 relays.

Hex Code for IR Remote

How to Configure Blynk 2.0 for ESP32 Home Automation System

From the below download file, you will get 9 files. Save all of them in a single folder. Now open the .ino file in the Arduino IDE, select ESP32 DEVKIT V1 board and compile the code.

In the code section, you do not need to enter WiFi credentials. You just need to update BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME. Then open the BlynkEdgent.h file and update the HEX codes in the ir_remote() function. You just need to copy and paste the HEX codes after 0x. Now go to tools and select the “ESP32 DEVKIT V1” board and “Port Address” from the Arduino IDE.

Working Principle of ESP32 Home Automation System

The working principle of this project is very easy. You can control appliances with Blynk IoT app from anywhere in the world. If the ESP32 is connected to WI-FI, you can monitor the real-time temperature in the Blynk app. You can control all the appliances using an IR remote also.

First, get the HEX codes of unused IR Remote buttons. Then update the HEX codes in the main code. When wifi is not connected you can control it with IR remote and manual switches.

The main work behind this project is when the control pins of the relay module receive the LOW signal the relay will turn on and when it receives HIGH it gets turned off.

Libraries for Compiling The Code

For compiling the code we also need the ESP32 board manager. Just click on File-Preferences-Paste the link in Additional Board Manager URLs-OK.


Then install the ESP32 board from the board manager of the tools section.
Then install all the required libraries in Arduino IDE like Blynk library, IR remote library, and DHT library. At the time of installing the Blynk library, you have to install all the dependencies.

ESP32 Code for ESP32 Home Automation System

First, download this file and change it according to your IR hex codes and WiFi credentials and upload it to ESP32.

Leave a Comment