Arduino IoT Cloud ESP32 Alexa based voice controlled smart home
Update Time: 2021-09-29 14:33:59
In this IoT project, I show how to use Arduino IoT Cloud and Alexa to implement IoT based home automation and use ESP32 to control 4 home appliances by voice commands. Jotrin shows all the steps to make this smart home system.
This IoT based home automation system has the following features.
Control devices using Alexa and Arduino IoT Cloud Dashboard.
Control relays with an infrared remote control.
Manually control appliances with switches.
Manually control home appliances without the need for the Internet.
Monitor real-time feedback and room temperature in the Amazon Alexa app.
All of the resources used in this project are free.
So, you can easily complete this home automation project at home using only the ESP32, DHT11 sensor, 1838 IR receiver and relay module. Or, you can use a custom designed PCB for this project.
You can complete this project using only the ESP32, DHT11 sensor, 1838 IR receiver, and 4-channel relay module. However, if you are using a PCB, then you will need the following components.
ESP32 Development Kit V1
1838 IR Receiver (with metal housing)
Relay 5v (SPDT) (4 no)
BC547 Transistors (4 no)
PC817 Optocuplors (4 no)
510 Ohm 0.25 Watt Resistors (4 no) (R1 - R4)
1k 0.25 Watt Resistors (6 no) (R5 - R10)
10k 0.25 Watt Resistors (1 no) (R11)
LED 5 mm (6 None)
1N4007 Diode (4 pcs) (D1 - D4)
Pushbuttons (4 none)
5V DC Power Supply
Step 1: Circuit diagram for ESP32 home automation project
The circuit is very simple, I use GPIO pins D23, D22, D21 and D19 to control the 4 relays.
GPIO pins D13, D12, D14, and D27 are connected to switches to manually control the 4 relays.
I used the INPUT_PULLUP function in the Arduino IDE instead of using pull-up resistors.
The IR remote receiver (TSOP1838) is connected to D35. And the DHT11 sensor is connected to RX2.
I use 5V cell phone charger to power the smart relay module.
Please take proper safety precautions when working under high voltage.
Step 2: Using the ESP32's Alexa Control Relay
If the ESP32 is connected to Wi-Fi, you can control your home appliances through the Amazon Alexa App and also monitor the room temperature.
You can also ask Alexa to turn devices on and off from anywhere in the world.
For this home automation project, you don't need any Echo DOTs or other Alexa devices.
Step 3: ESP32 Control Relay with Arduino IoT Cloud Dashboard
If the ESP32 is connected to WiFi, you can also monitor the room and control home appliances via the Arduino IoT Cloud web dashboard and the Arduino IoT Cloud Remote mobile app.
For this project, I used the free plan of Arduino IoT Cloud. In the free plan, you can control up to 5 relays or sensors.
When you control a relay from the Arduino IoT Cloud Remote mobile app, the current status of the relay is also updated in the Amazon Alexa app.
Step 4: Infrared Remote Control of Relays with ESP32
You can always control the relay from any IR remote control.
I will explain how to get the IR code (HEX code) from any remote control in the following steps.
If the ESP32 is connected to Wi-Fi, then you can also monitor real-time feedback in the Amazon Alexa App and the Arduino Cloud Dashboard.
Step 5: Manually control relays via buttons
If WiFi is not available, you can control the relay via the push button.
When WiFi is available, the ESP32 will automatically reconnect to WiFi.
Please refer to the wiring diagram to connect the button.
Step 6: Design the PCB for this smart home system
To make the circuit compact and professional looking, I designed the PCB after testing all the functions of the smart relay module.
Step 7: Order the PCB
Step 8: Upload Gerber file and set parameters
Step 9: Solder all components on the PCB
After that, I soldered all the components according to the circuit diagram.
Then I connected the ESP32, DHT11 sensor and IR receiver to the PCB.
Step 10: Create an Arduino IoT Cloud Free Account
Step 11: Add the ESP32 device to the Arduino IoT Cloud
Step 12: Adding Variables to the Arduino IoT Cloud
Now to control the 4 relays and read data from the DHT11 sensor, you must add 5 variables.
Click the Add Variable button.
Enter a name and select the Alexa compatible switch type. The variable permissions will be "Read and Write" and the variable update policy will be "On Change".
In a similar way, you must add the next 3 variables.
For Room Temperature, Read selects the Alexa compatible temperature sensor. The variable update policy will be "Periodic" and will mention the interval time.
Step 13: Set up the Arduino IoT Cloud Dashboard
Now click on the dashboard at the top to set up the Arduino Cloud Dashboard.
Then click on Build Dashboard. after that click on the Edit icon.
Then click ADD and select Switch.
Name the Switch and then link a variable to the Switch widget.
Then click Finish.
In a similar manner, you must add a total of 4 Switch widgets to control 4 relays.
For Temperature, select the Gauge widget and link the temperature variable. You can also set MIN and MAX limits.
Step 14: Get IR codes (HEX codes) from remote
Step 15: Program the ESP32 using the Arduino IDE
Step 16: Configure the Alexa Application for the Arduino IoT Cloud
Step 17: Connecting Arduino Cloud Devices to Alexa
Log in with your Arduino Cloud credentials.
Click Discover Devices. It takes a minute to add a device.
Click on Devices and then click on Switch to see all devices.
As a result, all devices from the Arduino IoT Cloud will be added to the Amazon Alexa app.
Step 18: Set up the Arduino IoT Cloud remote application
You can also control devices from the Arduino IoT Cloud remote app.
Download and install the Arduino IoT Cloud Remote App from the Google Play Store or App Store.
Click Sign In.
Then log in to your Arduino IoT Cloud account.
Click on the thing you created to open the dashboard.
Now you can also control relays from this Arduino IoT Cloud Remote App.
Step 19: Connecting Home Appliances
Step 20: The Arduino Cloud Smart Home System is ready to go
Now you can control your home appliances in a smart way.
Previous: AI chip memory issues in 2021