In this ESP32 project, I have explained how to make the ESP32 Bluetooth and IR Remote control smart house system to control 8 relays from mobile, IR remote, and manual switches. You don’t need any WiFi for this home automation project, just connect the Bluetooth app with ESP32, and control the appliances from the smartphone.
In this article, I have explained all the steps to make this smart home system using ESP32, relay module, and IR receiver.
Table of Contents
Required Components for the ESP32 projects
- ESP32 DEV KIT V1
- 8-channel 5V SPDT Relay Module
- TSOP1838 IR receiver (with metallic casing)
- Switches or Push Buttons
- Any IR Remote
Circuit of the ESP32 Bluetooth IR Remote control relay
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 D35.
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.
If you want to use push buttons instead of switches (latched), then you have to connect the push buttons across the GPIO pins and GND pin as shown in the above circuit.
Tutorial video on ESP32 Bluetooth IR Remote control appliances
In the tutorial video, I have covered the following topics in detail.
- Control the relay module from Bluetooth, IR Remote, and Switches.
- How to make the circuit for the ESP32 IoT projects.
- Program the ESP32 with the Arduino IDE.
- Connect home appliances with the relay module.
Control appliances with Bluetooth, IR Remote & Switch
To control the relays from mobile, you have to turn on the Bluetooth and connect ESP32.
After connecting the Bluetooth you can easily control the appliances from the Bluetooth app.
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.
You can also control the appliances from manual switches.
There is no specific ON/OFF position, so whenever you press the switch, it will change the current state of that respective relay.
Program ESP32 with Arduino IDE
In the Tutorial video, I have explained all the steps to program the ESP32 DEV KIT V1 using Arduino IDE.
- 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
- Then install the ESP32 board from the Board manager or Click Here to download the ESP32 board.
- Install the IRremote library from Include Library or Click Here to download.
- Install the AceButton library from Include Library or Click Here to download.
Download the Codes for this ESP32 Bluetooth Projects
Click on the following buttons to download the source codes for this ESP32 project.
First, we have to upload the Code for Getting HEX codes to ESP32 and connect the IR receiver with GPIO-35
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.
Modify the main code for this Smart House project
Now, open the source code in Arduino IDE.
For this ESP32 project, you need 10 HEX codes.
case 0x80BF49B6: relayOnOff(1); break;
case 0x80BFC936: relayOnOff(2); break;
case 0x80BF33CC: relayOnOff(3); break;
case 0x80BF718E: relayOnOff(4); break;
case 0x80BFF10E: relayOnOff(5); break;
case 0x80BF13EC: relayOnOff(6); break;
case 0x80BF51AE: relayOnOff(7); break;
case 0x80BFD12E: relayOnOff(8); break;
case 0x80BF3BC4: all_Switch_OFF(); break;
case 0x80BF23DC: all_Switch_ON(); break;
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.
PCB for this ESP32 Home Automation system
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.
About PCBWay and their services
PCBWay not only produce FR-4 and Aluminum boards, but also advanced PCBs like Rogers, HDI, Flexible and Rigid-Flex boards, at 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 the PCBWay. You can place an order as per your requirement.
You can explore different useful PCB projects from the PCBWay Open-source community – pcbway.com/project
Connect Home Appliances with Relay Module
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.
Steps to connect the Bluetooth App with ESP32
To control the ESP32 with Bluetooth, I have designed a Bluetooth App in MIT App Inventor.
Download the Bluetooth Switch App and install it. I have not submitted the App to Google Play Store. So you may get an alert while installing the App.
Now, you can connect the Bluetooth App with ESP32.
- Turn ON mobile Bluetooth and Pair the ESP32.
- Open the Bluetooth Switch App and tap on “Tap to Connect“.
- Select the “ESP32_BT” from the list.
- Now, you can control the relay from mobile with Bluetooth.
Our ESP32 Home Automation system is now ready
Now you can control the appliances from your smartphone, 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.