ESP32 IoT Project using ESP RainMaker

ESP32 IoT Project using Alexa Google Home app

Make practical ESP32 IoT project using ESP RainMaker, Sensors to control relays & Fan Speed with Alexa, Google Home, IR remote, & switches.

In this ESP32 project, I have explained how to make a practical ESP32 IoT project using ESP RainMaker with ESP32, sensors. to control relays and fan speed from Alexa, Google Home, IR remote, and manual switches.

With this IoT project, you can also control appliances, and fan speed without internet from IR remote and manual switches.

esp32 iot smart home p10

The ESP32 will automatically connect with the ESP RainMaker IoT cloud if the WiFi is available. Then you can control the lights and fan speed from anywhere in the world through the internet and monitor the real-time feedback in Amazon Alexa, Google Home, and ESP RainMaker App.

I have used all the FREE tools for this ESP32 home automation project using ESP RainMaker.

So if you follow all the steps, you can easily make this IoT-based Home Automation System with ESP32 and Sensors.

Required Components for ESP32 IoT project (without PCB)

Required Components for the ESP32 project
  • ESP32 DevKIT V1 Amazon
  • 4-channel 5V SPDT Relay Module Amazon
  • DHT11 Sensor Amazon
  • TSOP1838 IR Receiver (with metallic case) Amazon
  • Switches or Pushbuttons Amazon
  • Any IR Remote
  • 4-step Fan Regulator OR (2.2uf & 3.3uf 250V Capacitor, 2.2-ohm 1/2W Resistors, 220k 1/4W Resistors, and 4-step selector switch)

Circuit of the ESP32 Home Automation System

Circuit of the ESP32 IoT Project

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, and GPIO D33, D32, D15 & D4 are connected with a 4-step selector switch to control the relay module manually.

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.

IR remote receiver (TSOP1838) connected with D35. And the DHT11 sensor is connected to RX2 (GPIO16).

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 IoT Project with ESP32 Alexa Google Home

In the ESP RainMaker tutorial video, I have covered the following steps in detail.

  • Control relays and fan speed with Alexa, Google Assitant, and ESP RainMaker app
  • Control appliances with IR Remote & Manual Switch.
  • Circuit of the ESP32 IoT Project with Fan Dimmer
  • Source Code for this ESP RainMaker IoT Project.
  • Add devices with Amazon Alexa and Google Home.

Program ESP32 with Arduino IDE

In the Tutorial video, I explained all the steps to program the ESP32 using Arduino IDE.

  • Update the Preferences –> Additional boards Manager URLs: http://arduino.esp8266.com/stable/package_esp8266com_index.json,https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
ESP32 board version 2.0.5
  • Then install the ESP32 board (Version: 2.0.5) from the Board manager or Click Here to download the ESP32 board.
  • Download the required libraries from the following links:
  • In Arduino IDE, select Board as ‘ESP32 DEV Module‘, and the Partition scheme as ‘RainMaker‘.

Source Codes for ESP RainMaker IoT Project

Click on the following buttons to download the source codes for this ESP32 project.

This code is provided free for project purpose and fair use only.
Please do mail us to [email protected] if you want to use it commercially.
Copyrighted © by Tech StudyCell

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 9 HEX codes for this IoT Project.

In the main sketch, 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   0x80BF49B6
#define IR_Button_2   0x80BFC936
#define IR_Button_3   0x80BF33CC
#define IR_Button_4   0x80BF718E
#define IR_Button_5   0x80BFF10E
#define IR_Fan_Up     0x80BF53AC
#define IR_Fan_Down   0x80BF4BB4
#define IR_All_On     0x80BF3BC5
#define IR_All_Off    0x80BF3BC4

And if you want you can also change the device names. Google and Alexa will identify the devices with these names.

// define the Device Names
char deviceName_1[] = "Switch1";
char deviceName_2[] = "Switch2";
char deviceName_3[] = "Switch3";
char deviceName_4[] = "Switch4";
char deviceName_5[] = "Fan";

In the code, I have used Preferences.h library to remember the last states of all the GPIO connected with relays. Please refer to the following article on the ESP32 Preferences library.

After uploading the code to ESP32, please refer to the following article to add the devices with the ESP RainMaker app.

Add Devices in ESP RainMaker App

After programming, please press and hold the BOOT button for 4 seconds.

Then turn ON the mobile Bluetooth and GPS.

Scan the following QR code with your ESP RainMaker app.

QR code for ESP RainMaker

Please refer to the following article to add the devices with the ESP RainMaker app.

Now, please refer to the following articles to connect the ESP RainMaker with Amazon Alexa and Google Home App.

After doing all these steps, now you control the appliances with Google Assistant and Alexa.

PCB for this ESP32 Home Automation system

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

If you want to buy this complete project (Rs: 3399/), then please send an email to [email protected] with your address.
(Including pre-programmed ESP32, DHT11 sensor, IR receiver, 1 selector Switch, IR remote)

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

You can order any custom design PCBs from PCBWay at very reasonable prices.

This image has an empty alt attribute; its file name is PCBWay-750x161-Banner.jpg

PCBWay not only produces FR-4 and Aluminum boards but also advanced PCBs like Rogers, HDI, and Flexible and Rigid-Flex boards, at very affordable prices.
For the online instant quote page please visit – pcbway.com/orderonline

You can also explore different PCB projects from their Open-source community pcbway.com/project/.

For more details please visit the following articles.
Why PCBway
PCB Capabilities
High-Quality PCB

Required components for the PCB

Required components for the PCB

Connect Appliances and switches with the PCB

Connect Appliances and switches

Please refer to the above circuit diagram to connect all the AC appliances and switches with the PCB.

Please take proper safety precautions while connecting the AC appliances.

Control Fan Speed with Alexa and ESP RainMaker app

Control the speed of the ceiling fan from anywhere in the world from the Blynk IoT App. If the WiFi is connected, you can also monitor the real-time feedback in the Blynk.

Control Fan Speed with IR Remote & Selector Switch

You can use any IR remote to control the fan speed. I have used 2 buttons to increase and decrease the fan speed from the IR remote.

You can also use a selector switch to control the fan speed manually if the WiFi is not connected.

Control relays with the Google Assistant, IR Remote & Switch

Control relays with the Google Assistant
Control relays with the Google Assistant

You can control appliances with Google Assistant, and Alexa from anywhere in the world through the internet.

If the ESP32 is connected to WiFi, you can monitor the real-time feedback and room temperature in the Amazon Alexa, and Google Home apps.

Control relays with IR Remote
Control relays with IR Remote

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.

If the Wi-Fi is not connected, still you can control relays with the IR remote.

Control relays with switches
Control relays with switches

You can also control the appliances with manual switches and control fan speed with the rotary selector switch.

If the ESP32 is connected to Wi-Fi then it will send real-time feedback to the ESP RainMaker IoT server.

I hope you like this IoT-based home automation system idea with ESP32 and ESP RainMaker app.

Click Here for more such ESP32 projects.

Please do share your feedback on this IoT project. Thank you for your time.