In this IoT project, I have shown how to make an IoT-based Smart Home with Arduino IoT Cloud & Alexa using ESP8266 Arduino to control 4 home appliances with voice commands, IR remote, and manual switches.

If the internet is unavailable, you can control the home appliances from IR remote & manual switches. In the article, I have shown all the steps to make this smart home system.

Tutorial video on Arduino IoT Cloud Project

This Arduino Home Automation system has the following features:

So if you follow all the steps, you can easily make this IoT project just by using Arduino UNO, NodeMCU, and relay module.

Although the PCB is not mandatory, I have used PCB to make the circuit compact and give the project a professional look.

How Does This Arduino IoT Cloud Project Works?

This Arduino ESP8266 Home Automation works in the following steps.

Required Components for this IoT Project (without PCB)

Required Components for the Arduino control Relay PCB:

Circuit Diagram of the ESP8266 Arduino Control Relays

The circuit is very simple, I have used the digital pins D4, D5, D6 & D7 to control the 4 relays.

And the digital pins D10, D11, D12 & D13 are connected with switches to control the 4 relays manually.

The output pin of the IR receiver is connected with A0 and the DHT11 sensor is connected with A1.

I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors.

I have used D2 as RX and D3 as TX for the serial communication with the NodeMCU module.

If you use the latched switches then just connect the pushbutton across the digital pins and GND instead of the pushbuttons.

I have used a 5V mobile charger to supply the smart relay module.

Please take proper safety precautions while working with high voltage.

Alexa Control Relay Using ESP8266 NodeMCU

You can control the home appliances from Amazon Alexa App if the NodeMCU is connected to the WiFi.

You can also ask Alexa to turn on and off the appliances from anywhere in the world.

You don't need any Echo DOT or other Alexa devices for this home automation project.

You can also control the home appliances from the Arduino IoT Cloud web dashboard and Arduino IoT Cloud Remote mobile app if the NodeMCU is connected with WiFi.

Control Relays With IR Remote & Manual Switches

You can always control the relays with IR remote and manual switches.

I will explain how to get the IR codes (HEX codes) from any remote in the following steps.

And if the NodeMCU is connected to Wi-Fi, you can monitor the real-time feedback in the Amazon Alexa App & Arduino cloud dashboard.

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

When the WiFi is available, the NodeMCU will automatically reconnect with the WiFi.

Design the PCB for This Smart Home System

To make the circuit compact and give a professional look, I have designed the PCB after testing all the features of the smart relay module.

You can download the PCB Gerber file of this home automation project from the following link:

GitHub link to Download PCB Gerber File

Why you should use JLC SMT Service?

On JLCPCB's one-stop online platform, customers enjoy low-cost & high-quality & fast SMT service at an $8.00 setup fee($0.0017 per joint).

$27 New User coupon & $24 SMT coupons every month.

Visit https://jlcpcb.com

JLCPCB SMT Parts Library 200k+ in-stock components (689 Basic components and 200k+ Extended components)

Parts Pre-Order service https://support.jlcpcb.com/article/164-what-is-jlcpcb-parts-pre-order-service

Build a Personal library Inventory, save parts for now or the future

Assembly will support 10M+ parts from Digikey, mouser.

Steps to Order the PCB Assembly from JLCPCB

1. Visit https://jlcpcb.comand Sign in / Sign up.

2. Click on the QUOTE NOW button.

3. Click on the "Add your Gerber file" button. Then browse and select the Gerber file you have downloaded.

4. Set the required parameter like Quantity, PCB masking color, etc.

5. Select the Assemble side and SMT Quantity.

6. Now upload the BOM and PickAndPlace files.

7. Now confirm all the components which you want to be soldered by SMT services.

8. Click on SAVE TO CART button.

Select Shipping Address and Payment Mode

6. Type the Shipping Address.

7. Select the Shipping Method suitable for you.

8. Submit the order and proceed with the payment.

You can also track your order from the JLCPCB

My PCBs took 3 days to get manufactured and arrived within a week using the DHL delivery option.

PCBs were well packed and the quality was really good at this affordable price.

Create Arduino IoT Cloud FREE Account

For this smart house project, I have used the Arduino Cloud Free plan.

Click on the following link to create an Arduino IoT Cloud account.

https://store.arduino.cc/digital/create

Add NodeMCU ESP8266 Device in the Arduino IoT Cloud

You can see, the device added.

Add Variable in Arduino IoT Cloud

Now to control 4 relays, you have to add 4 variables.

Click on the "ADD VARIABLE" button.

Enter a name, then select Alexa compatible switch type. Variable Permission will be "Read & Write" and Variable Update Policy will be "On Change".

In a similar way, you have to add the next 3 variables.

For the room temperature reading, select Alexa compatible Temperature Sensor. Variable Update Policy will be "Periodically", and mention the interval time.

Set Up Arduino IoT Cloud Dashboard

In a similar way, you have to add total 4 Switch widgets to control 4 relays.

For the temperature, select Gauge widgets and link the Temperature variable. You can also set the MIN and MAX limits.

Get the IR Codes (HEX Code) From Remote

Now, to get the HEX codes from the remote, first, we have to connect the IR receiver output pin with the A0 pin of Arduino UNO.And give the 5V across the VCC and GND. The IR receiver must have a metallic casing, otherwise, you may face issues.

Then follow the following steps to get the HEX codes:

Program the ESP8266 NodeMCU With Arduino IDE

To program the NodeMCU, I have used Arduino IDE.

Download the attached code.

First, you have to install the ArduinoIoTCloud library. During installation, it may ask to install other dependencies. Then click on Install All.

In the code, enter the following details.

const char DEVICE_LOGIN_NAME[] = ""; //Enter DEVICE IDconst char SSID[]        = "";  //Enter WiFi SSID (name)const char PASS[]        = "";  //Enter WiFi passwordconst char DEVICE_KEY[]     = "";  //Enter Secret device password (Secret Key)

the DEVICE_LOGIN_NAME[] and DEVICE_KEY[] from the PDF which you have downloaded during adding the device to the Arduino IoT cloud.

I have shown all the steps in the tutorial video. After doing all these changes, you can upload the code to NodeMCU.

Program the Arduino UNO or ATmega328P With Arduino IDE

In the PCB I have used an ATmega328P microcontroller, so I have used FTDI232 USB to TTL board to program the microcontroller (Refer to tutorial video).

But if you don't use PCB then you can directly connect the Arduino UNO with the laptop.

For the main sketch, you need to install the following libraries

Then you have to update the HEX code in the sketch for IR remote control.

For momentary switch use the code: Code_ArduinoUNO_EEPROM_WiFi_IR_Button_4Relay.ino

and for latched switch use the code: Code_ArduinoUNO_EEPROM_WiFi_IR_Switch_4Relay.ino

Configure the Alexa App for Arduino IoT Cloud

Download and install the Amazon Alexa App from the Google play store or App Store.

Connecting Arduino Cloud Devices With Alexa

Log in with the Arduino Cloud credentials.

Thus, all the devices from Arduino IoT Cloud will be added to Amazon Alexa App.

Connect the Home Appliances

Connect the 4 home appliances with the relay module as per the circuit diagram.

Please take proper safety precautions while working with high voltage.

Connect the 110V/230V supply with the PCB.

Finally!! the Arduino Cloud Smart Home System Is Ready

Now you can control your home appliances in a smart way.

I hope you have liked this Arduino IoT and Alexa control home automation project. I have shared all the required information for this project.

I will really appreciate it if you share your valuable feedback. Also if you have any queries please write in the comment section.

Thank you & Happy Learning.