ESP32 Alexa IoT Project

ESP32 Alexa IoT Project with OTA WiFi update

Make IoT-based Alexa home automation system using ESP32, Echo Dot, & relays. Also update WiFi credentials through OTA. (Circuit + Code)

In this ESP32 Alexa project, I have explained how to make an IoT-based home automation system using ESP32, Amazon Echo Dot, and relays.

esp32 alexa home automation p18

You can also update the WiFi credentials through OTA using the ESP BLE Provisioning app.

OTA the WiFi credentials

You don’t need any third-party IoT applications to make this IoT project, you just need an echo device and ESP32.

Amazon Echo Home Automation using ESP32

If the WiFi is unavailable, you can also control appliances with IR remote, and manual switches.

Amazon Echo Home Automation

So if you follow all the steps, you can easily make this home automation using ESP32 and Alexa app.

Required Components for the ESP32 project

Required Components for the ESP32 project
  1. ESP32 DEV KIT V1
  2. 4-channel 5V SPDT Relay Module
  3. TSOP1838 IR receiver (with metallic casing)
  4. Switches
  5. Amazon Echo Dot

Circuit of the ESP32 Alexa IoT Project

Circuit of the ESP32 Alexa IoT Project

In the circuit, 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.

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 Blynk ESP32 IoT Project

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

  • Update WiFi credentials to ESP32 through OTA using the ESP BLE Provisioning app.
  • Add devices to the Amazon Alexa App using the ESPAlexa library.
  • Circuit of the ESP32 home automation system.
  • Explained the source code of the ESP32 IoT project.

PCB for this ESP32 Home Automation system

To make the circuit compact, I have designed a PCB for this ESP32 Alexa IoT project.

PCB for 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.

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:,

  • 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.

Program ESP32

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.

Generate the QR code to update WiFi Details

Generate QR code

After uploading the code, open the serial monitor with Baud rate 115200. Then press the boot button of ESP32 for 5 seconds.

A QR code will appear in the serial monitor, then copy the QR code and paste in Notepad++ or any other IDE.

scan QR code using ESP BLE Provisioning

Now turn on the Bluetooth and GPS on your mobile, then scan the QR code using the ESP BLE Provisioning app.

Enter the WiFi credentials (WiFi Name and Password) and submit.

The ESP BLE Provisioning app will send the WiFi credentials to ESP32 through BLE. The ESP32 will connect to that WiFi and the inbuilt blue LED will turn on.

Add devices on the Amazon Alexa App

Add devices on the Amazon Alexa

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.

no device found in Alexa App

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”.

Control Relays with Alexa and IR Remote

esp32 alexa home automation p15

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

Control Relays with 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.