IoT Project using ESP32 with Blynk

IoT Project using ESP32 with Blynk Automation

Make IoT project using ESP32 to control relays with Blynk + Google Assistant + IR Remote + Switches. Also, add Automation for Sensor + Timer.

In this ESP32 project, I have explained how to make a practical IoT project using ESP32 and sensors with the New Blynk Automation.

With this IoT-based project, you can set the timer and control the relays automatically with sensor readings in the Blynk IoT app.

IoT Project using ESP32

If there is no internet, still you can also control 4 home appliances with the IR remote and manual switches.

The ESP32 will automatically connect with the Blynk cloud if the WiFi is available. Then you can control the relays from anywhere in the world through the internet and monitor the real-time feedback in Blynk IoT App.

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 IoT projects

Required Components
  1. ESP32 DevKIT V1 Amazon
  2. 4-channel 5V SPDT Relay Module Amazon
  3. DHT11 Sensor Amazon
  4. TSOP1838 IR Receiver (with metallic case) Amazon
  5. Switches or Pushbuttons Amazon
  6. Any IR Remote

Circuit of the IoT Project using ESP32

Circuit of ESP32 control relay

The circuit is very simple, I have used D23, D22, D21 & D19 GPIO to control the 4-channel relay module.

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

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

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

IR remote receiver (TSOP1838) connected with D35. And the DHT11 sensor connected with RX2 (GPIO16).

If you want to use the pushbuttons instead of latched switches, then just connect the pushbuttons instead of the latched switches across GPIO pins and GND.

Circuit of ESP32 IoT projects

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

Please take proper safety precautions while connecting the AC appliances.

Tutorial video on IoT project using ESP32 & Blynk

In the Internet of things tutorial video, I have covered the following steps in detail.

  • Control appliances with Google Assistant Blynk & IR Remote
  • Controlling relays with DHT11 Sensor and Timer using Blynk Automation.
  • Circuit of the ESP32 IoT Home Automation projects.
  • How to set up Blynk IoT cloud for ESP32.
  • Source Code for the Blynk ESP32 IoT project.
  • How to add Automations in Blynk IoT (Timer and Sensor ).

Set up Blynk IoT Cloud for the IoT-based Project

You can refer to the following article to set up the new Blynk cloud account

Getting started with New Blynk 2.0 IoT platform

Create Blynk Template

During creating the template, I have selected ESP32 as hardware and the connection type as WiFi.

Create Datastreams in Blynk Cloud

esp32 iot project sensor p9

For demonstration, I have created 4 Datastreams (V1 to V4) to control 4 relays, 1 Datastream (V5) to turn off all the relays, and 2 Datastreams (V6 & V7) to get the DHT11 sensor readings.

Define Datastreams for Automations

Define Datastreams for Automation

Next, you have to define which Datastreams will be available in Automation actions and conditions.

Only Virtual Pin, Enumerable, and Location Datastreams are supported.

Create Web Dashboard

After that, click and drag Switch widgets according to the number of relays and 2 level widgets for DHT11 sensors.

Then click on “Save“.

Add Device in Blynk Cloud using Template

You can refer to the following article to add a device in the Blynk cloud.

Add Device in Blynk Cloud from Template

Program ESP32 with Arduino IDE

For this IoT-based home automation project, I have used the Arduino IDE to program NodeMcU.

First update the Preferences –> Aditional boards Manager URLs:,

  • Then install the ESP32 board from the Board manager or Click Here to download the ESP32 board.
  • After that install the Blynk library. Click Here to download the Blynk library.
  • Then install the IRremote Library (3.6.1)Click Here to download the IRremote library.
  • Then install the AceButton library. Click Here to download the AceButton library.

Source Codes for Blynk IoT Projects with ESP32

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.

ESP32 with IR receiver circuit

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

Get HEX code from IR Remote

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. For this IoT project, you need 5 HEX codes.

Modify the main code for this IoT based project

Modify the main code

In code, you have to update only the BLYNK_TEMPLATE_ID, BLYNK_DEVICE_NAME, Auth Token, WiFi Credentials and HEX codes of IR remote as shown in the video.

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.

PCB for this ESP32 Home Automation system

To make the circuit compact, I have designed a PCB for this ESP32 IoT 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.

Add Automation to the Blynk Project

Add Automation in Blynk IoT App

In the tutorial video, I have explained all the steps to create Automation in the Blynk IoT application.

In this automation project, I have controlled the 3rd relay with the DHT11 temperature reading and scheduled the turn ON and turn OFF for the 4th relay with timer.

After watching the tutorial video, you can easily define Automations as per your requirements.

Control relays with the Blynk IoT, IR Remote & Switch

IoT Project using ESP32
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.

Control relays with IR Remote
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 or pushbuttons.

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

Add Google Assistant with Blynk using IFTTT

You can also add Google Assistant with Blynk cloud using IFTTT. In the following article, I have explained all the steps to connect Blynk with Google Assistant using the FREE IFTTT account.

Set up IFTTT to connect Blynk Project with Google Assistant

URL syntax to send web requests in New Blynk IoT platform

Syntax: https://{server_address}/external/api/update?token={token}&{pin}={value}

Blynk URL for IFTTT

The server region could be found in the right bottom corner of the web interface in the Blynk account.

In the server address, the first 4 characters are the Server Region.

Following are the server addresses for different regions.

  • – Frankfurt
  • – London
  • – New York
  • – Singapore
  • – Bangalore

I have used the following Blynk URLs to send web requests from IFTTT to update the Datastreams values in the Blynk server.

Blynk URLs to send web requests
Control with Google Assistant
Control relays with Google Assistant

I hope you like this Smart home IoT projects idea with ESP32 and Blynk app.

Click Here for more such ESP32 projects.

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