ESP32 Home Automation Project Using IR Remote Control and Blynk IoT Platform

by AhmadLogs in Circuits > Arduino

1022 Views, 4 Favorites, 0 Comments

ESP32 Home Automation Project Using IR Remote Control and Blynk IoT Platform

reg-remote (2).png

Home automation is becoming increasingly popular, and with good reason. With the use of technology, you can easily control your home appliances with the touch of a button or even with your voice. In this blog post, we will discuss a home automation project that can be controlled using an IR remote control and the Blynk IoT platform. Additionally, we will talk about the custom PCB designed for this project and how to register a new remote control.


Features of the Project.

  1. Register any IR Remote withou coding
  2. Control relays with switch buttons
  3. Control relays with IR Remote
  4. Project works with or without the internet
  5. Monitor realtime status on Blynk App
  6. Monitor temperature and humidity data on Blynk App
  7. Control upto 4 appliances


Supplies

wiring (2).png
wiring (4).png

To build this project on a breadboard, you will need the following main components:

  1. ESP32 Espressif
  2. Relay Module 4 channel
  3. 38kHz VS1838 IR Receiver
  4. Switch Buttons
  5. DHT11 Sensor


To build this project on a breadboard, you will need the following main components:

  1. 3mm LED X 4
  2. Secrew Terminal 3 pins X 4
  3. 5v relay X 4
  4. DHT11 Sensor
  5. 38kHz VS1838 IR Receiver
  6. 3mm LDR
  7. 10K Resistor X 1
  8. 1K Resistor X 8
  9. BC547 Transistor X 4
  10. Diode 1N4007 X 4
  11. ESP32
  12. Switch Buttons X 4
  13. 5v Supply

Modes of the Project

1 - register remote.png

This project works on two modes.

  1. Normal Mode
  2. Config Mode


Normal Mode: In normal mode, you can control your appliances manually using IR remote, and switch buttons without the internet. Additionally, this project supports blynk IoT platform, so you can control your home appliances from anywhere in the world, while connected to the internet. You can also monitor the real time room temperature and humidity using Blynk App.


Config Mode: In config mode, you can register a new remote control without making any change in the code. To enter the Config Mode, press and hold the boot button for more than 2 seconds and then release the button. The blue LED will start blinking very fast, indicating that the project is now in Config Mode.

Wiring the Components

reg-remote.png

Above is the wiring diagram for this project.

Safety Precautions:

The AC bulbs are connected to the relays, which involves high voltages. Take proper precautions and ensure your safety before working with high voltages.

PCBWay PCB Prototyping

PCB_PCB_Video_2023-05-14 (3).png
Schematic_home automation 1_2023-05-14.png

In order to make my project more compact and professional-looking, I utilized the EasyEDA free online circuit design software to create a custom PCB. The PCB was designed to be 95mm x 70mm in size, and the resulting design is both sleek and functional. I chose to utilize PCBWay's prototyping services to fabricate the PCB due to their excellent reputation as a high-quality PCB manufacturer.


PCBWay is a company that specializes in providing high-quality printed circuit board (PCB) manufacturing and assembly services. With more than a decade of experience in the industry, PCBWay offers a wide range of services including PCB prototyping, PCB assembly, and PCB design. The company prides itself on its advanced production capabilities, state-of-the-art equipment, and highly skilled workforce that allows it to produce top-quality PCBs for various industries such as automotive, medical, consumer electronics, and aerospace. PCBWay is also committed to providing excellent customer service and support, ensuring that each customer's unique needs are met with professionalism and efficiency.

Ordering PCB on PCBWay

1 - order (2).png
1 - order (3).png
1 - order (4).png
1 - order (5).png
1 - order (6).png
1 - order (7).png
1 - order (8).png
1 - order.png
pcb (2).png
pcb (3).png
pcb (5).png
pcb (6).png
pcb (7).png

Ordering a custom PCB from them is a breeze

First go to the PCBWay webiste: https://www.pcbway.com/

On the website input your PCB's dimensions, select your desired quantity and color on their website, and then upload the gerber file. and you're good to go. You can acquire five to ten pieces of two-layer high-quality PCBs for as little as $5, with fast delivery times of 3 to 5 days, depending on your location and shipping preferences.


Download Gerber File

Register a New Remote Control

1 - register remote (2).png
1 - register remote (3).png
1 - register remote (4).png
1 - register remote.png

You can follow these steps to register a new remote control with the project.

  1. Press and hold the boot button on the project for more than 2 seconds.
  2. Release the button. The blue LED will start blinking very fast, indicating that the project is now in config mode and ready to register the remote control.
  3. Press the button on your remote that you want to register with the project.
  4. Look at the blue LED, which is now turned OFF. This means the first key has been registered.
  5. Wait for 2 seconds, and the LED will start blinking very fast again, indicating that you can now register the second key of your remote control.
  6. Repeat steps 3-5 until you have registered all six keys of your remote control.
  7. Once all keys are registered, the project will automatically enter into normal mode, and you can use your new remote control to operate your relays.
  8. If you want to register more than six keys, you can easily modify the code. More details on this will be discussed in the coding section later on.


Blynk 2.0 Account Setup

1 - create new template.png
2 - create new template (2).png
3 create test data stream.png
4 create test data stream.png
5 create test data stream.png

Here is the step-by-step procedure on setting up the Blynk Account on your computer or laptop:

  1. Log in to your Blynk account and go to the template section.
  2. Click on the "Create New Template" button to open the template window.
  3. Give your template a name, such as "esp home".
  4. Select the hardware as ESP32 and set the connection type to WIFI.
  5. Click on the "Done" button to create the template.
  6. Navigate to the "Datastream" tab in the template.
  7. Create one datastream, even though it won't be used in the project. This datastream is necessary to simplify the configuration of the Blynk app.
  8. Click on save button to save the template.


Setting Up Blynk App

1 - blynk app.png
2 - developers mode.png
3 - select template.png
4 - mobile dashboard.png
1 - add device.png
2 - manually from template.png
4 - create device.png
5 - device ready.png

You can follow the step-by-step instructions to create a mobile dashboard for the Blynk app:

  1. Open the Blynk app on your phone and select "Developer Mode" option.
  2. Select the template "esp home" that we created earlier to create the mobile dashboard.
  3. Click on the Plus icon to add a new widget and select the "Button" widget.
  4. Tap on the newly added button to open its properties.
  5. Choose "Choose Datastream" option to create a new data stream and tap on "Create New".
  6. Set the virtual pin to V1, data type to integer, and the maximum value to 1. Then, click on the "Done" button.
  7. Set the mode from "Push" to "Switch" for the button.
  8. Repeat the same steps to add three more buttons to control the remaining three relays. Remember to change the virtual pins for each button accordingly, which are V1, V2, V3 and V4.
  9. Add two gauge widgets to display the temperature and humidity data.
  10. Tap on the first gauge widget to access its properties.
  11. Choose "Choose Datastream" option and create a new data stream with virtual pin V5, data type integer, and maximum value 100. Then, click on the "Done" button.
  12. Set the properties of the second gauge widget to display the humidity data.
  13. The mobile dashboard is now ready. To add a device to the template, go back to the main screen and tap on "Add New Device".
  14. Select "Manually from Template" and choose the template "esp home". Then, click on the "Create" button to create the new device.
  15. You can now use the button widgets on the mobile dashboard to turn ON and off the relays connected to the esp32.


Programming Using Arduino IDE

Install Required Libraries:


For this project you need following libraries:

  1. Blynk Library - version 1.2.0
  2. AceButton Library version 1.9.2
  3. IRremote Library Version 4.1.2

You can install the above libraries directly from the Arduino IDE using Tools > Manage Libraries


Install EP32 Core:


URL: Preferences--> Aditional boards Manager URLs

  1. Paste the above URL in File > Preferences > Aditional boards Manager URLs
  2. Then install the ESP32 core from Tools > Boards > Board Manager
  3. Install the version 2.0.4


Add Blynk Credentials in the Code

1 - blynk credentials.png
2 - blynk credentials.png
3 - blynk credentials.png
4 - blynk credentials.png
5 - blynk credentials.png

Here you need to add your Blynk account credential in the code.

#define BLYNK_TEMPLATE_ID "ENTER_BLYNK_TEMPLATE_ID"
#define BLYNK_TEMPLATE_NAME "ENTER_BLYNK_TEMPLATE_NAME"
#define BLYNK_AUTH_TOKEN "ENTER_BLYNK_AUTH_TOKEN"


Here is the step by step procedure to get the Blynk credentials.

  1. Go to your Blynk account and navigate to the devices section.
  2. Find the device that you have previously created using the Blynk App and click on it.
  3. Click on the Device Info tab to access your Blynk credentials.
  4. Copy the Blynk credentials from the Device Info tab.
  5. Open the Arduino IDE and open the sketch that you are working on.
  6. Look for the section of the sketch where Blynk credentials are required.
  7. Paste the copied Blynk credentials into the above fields in the sketch.
  8. Save your changes to the sketch.
  9. Upload the modified sketch to your ESP32 device.
  10. You are now ready to use Blynk to communicate with your ESP32 device.


#define BLYNK_TEMPLATE_ID "TMPL3cAQV1gij"
#define BLYNK_TEMPLATE_NAME "ESP HOME"
#define BLYNK_AUTH_TOKEN "yOD3Hyfsz34R6um4Ah5vvpI1PPzTyr7k"



Enter WiFi Credentials

5 - wifi.png

Here you need to enter your WiFi credentials

// Your WiFi credentials.
char ssid[] = "ENTER_YOUR_WIFI_SSID";
char pass[] = "ENTER_YOUR_WIFI_PASS";


Upload the Code

6 - upload code.png

Before uploading the code, make sure you have already installed the esp32 core. Also, ensure that you have selected the correct board and the com port. Finally, click on the upload button, to upload the code onto your esp32.

You can download the complete code by clicking below

Demo

1 - pcb (2).png
1 - pcb .png
1 - pcb.png
vlcsnap-2023-05-14-12h55m27s895.png
vlcsnap-2023-05-14-12h55m44s082.png

Video Tutorial

Home Automation Using ESP32 IR Remote and Blynk

Download Code and Related Files

You can download the code and related files for this project by clicking on the link below

Download