In this Alexa ESP32 project, I have explained how to make an IoT-based home automation system with Bluetooth control using Amazon Echo Dot and ESP32.
With this ESP32 project, you can also control appliances without internet from the Bluetooth app, IR remote, and manual switches.
The ESP32 will automatically connect with Amazon Alexa 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 on the Alexa App.
I have used all the FREE tools for this ESP32 Alexa project.
So if you follow all the steps, you can easily make this ESP32 home automation system.
Table of Contents
- ESP32 DevKIT V1 Amazon
- 4-channel 5V SPDT (Active LOW) Relay Module
- TSOP1838 IR Receiver (with metallic case) Amazon
- Any IR Remote
- Amazon Echo Dot
Circuit of the ESP32 Alexa IoT Project
In the circuit, I have not used any external Bluetooth module, so the circuit is very simple.
I have used D23, D22, D21 & D19 GPIO to control the 4-channel relay module.
GPIO D13, D12, D14 & D27 are connected with switches.
IR remote receiver (TSOP1838) connected with D35.
For the 8 relays, please refer to the following circuit.
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.
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 Alexa ESP32 IoT Project
In the Internet of Things tutorial video, I have covered the following steps in detail.
- Circuit of ESP32 IoT-based home automation system.
- Explained the source code for the ESP32 Bluetooth project.
- Steps to connect the ESP32 with the Amazon Alexa app.
- Steps to connect the Bluetooth app with the ESP32.
PCB for this ESP32 Home Automation system
To make the circuit compact, I have designed a PCB for this ESP32 Alexa 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.
You can order any custom-designed PCBs from PCBWay at very reasonable prices.
You can also explore different PCB projects from their Open-source community pcbway.com/project/.
PCBWay Design Contest has always encouraged participants to engage in open-source and innovative projects, aiming to inspire more individuals to become a member of the electronics community.
In the contest, you have the opportunity to enter a wide range of submissions related to electronic design, spanning FPGA, IoT projects, wearables, embedded electronics, and also encompassing mechanical design, product design, or 3D design.
For more details please click here.
Program ESP32 with Arduino IDE
For this IoT-based home automation project, I have used the Arduino IDE to program ESP32.
First update the Preferences –> Aditional boards Manager URLs: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_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.
- Download the required libraries from the following links:
Source Codes for IoT Project using 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.
After that, open the serial monitor, and select the Baud Rate at 115200.
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 6 HEX codes for this ESP32 project.
In the main sketch, enter the device names (Alexa will identify the device with these names)
// device names String Device_1_Name = "Night Lamp"; String Device_2_Name = "Room Light"; String Device_3_Name = "Studio Light"; String Device_4_Name = "Toilet Light";
Update the HEX code of the IR Remote buttons (as shown in the tutorial video).
//Update the HEX code of IR Remote buttons 0x<HEX CODE> #define IR_Button_1 0x1FEE01F #define IR_Button_2 0x1FE10EF #define IR_Button_3 0x1FE906F #define IR_Button_4 0x1FE50AF #define IR_All_On 0x1FE807F #define IR_All_Off 0x1FE48B7
In the code, I have used WiFiProv.h library to reset the WiFi credentials from mobile using the ESP BLE Provisioning app.
After doing these changes, go to Tools and select the board as “ESP32 Dev Module”, Partition Scheme as “Huge APP (3MB…)” and the proper PORT in Arduino IDE.
Then click on the upload button to program the ESP32 board.
Add devices on the Amazon Alexa App
In the tutorial video, I have explained all the steps to add devices to the Amazon Alexa App.
While configuring the Amazon Alexa App, the ESP32, Amazon Echo Dot and the smartphone should be connected to same the WiFi network.
Once the Alexa App finds all the devices, you can control those devices with voice commands using the Alexa Echo Dot.
You may face No new devices found error while adding the devices with Alexa.
Then restart the echo dot, after restarting, once the echo dot connects with the same WiFi, tap on “Try discovery again”.
Connect ESP32 with Bluetooth App
I have made a Bluetooth app in MIT app inventor for this IoT-based home automation project.
I have explained the steps to connect the ESP32 with the Bluetooth app in the tutorial video.
Control Relays with Alexa & Bluetooth App
Now you can control the relays with voice commands using Alexa. Or if the WiFi is not available, you can control the relays with the Bluetooth App and IR remote.
**After adding the devices to the Amazon Alexa app, only the Echo Dot and ESP32 must be connected with the same WiFi. Your mobile can be connected to any different network.
Control Relays with Manual switch
You can also control the relays with manual switches.
If the WiFi is available, you can monitor the real-time feedback on the Amazon Alexa app.
I hope you like this IoT-based home automation system idea with ESP32 and Amazon Echo Dot.
Click Here for more such ESP32 projects.
Please do share your feedback on this IoT project. Thank you for your time.