Alexa Home Automation System Using Arduino IoT & ESP8266

In this project, we are going to build an Alexa Home Automation System with Arduino IoT cloud. Here we use the ESP8266 NodeMCU module. With the help of this project, we can operate 4 home appliances (Can be modified according to your needs) through Arduino IoT Cloud dashboard, Alexa and mechanical switches. We can also operate this system by controlling the relays from the Alexa app from any place in the world. Internet issue is very common in rural areas. So if there is no internet you can operate those appliances by manual switches.

In this project, we do not need to buy any Alexa devices or Amazon Echo Dot for this home automation system. Because I made this project using all free tools.

You just need to follow all the steps carefully. After this, you can easily make an Alexa Smart Home System with Arduino IoT Cloud and Amazon Alexa to control the appliances with your voice commands.

Must Read Home Automation Projects

Project

Alexa home automation system
Alexa Home Automation System

Circuit Diagram

Alexa Home Automation System
Alexa Home Automation System Circuit Diagram

Components Required

  • ESP8266 NodeMCU (ESP32)
  • 5V Relay (x4)
  • BC547 Transistor (x4)
  • 1N4007 PN Diode (x4)
  • Green LED (x4)
  • Red LED (x4)
  • 1K Resistor (x4)
  • 100 Ohm Resistor (x8)
  • Push Button (x4)
  • Bulb (x4)
  • 5V DC Source
  • 220V AC Source

Circuit Connection

This circuit connection is very easy for this project. We used D1, D2, D5 and D6 GPIO pins to control the 4-channel relay module. The SD3, D3, D7, and RX are connected with the push buttons to control this project manually.

The INPUT_PULLUP function in Arduino IDE is used here instead of using pull-up resistors with each switch. From the source code, when the control pins of the relay modules receive a LOW signal, the relay will turn on and for the HIGH signal it will turn off.

Here supply is a 5V 2Amp adopter.

Steps to Build Alexa Home Automation System

  • First, create an account in Arduino IoT Cloud.
  • Make all set up for Dashboard.
  • Set up Arduino IoT Cloud for ESP8266.
  • Program NodeMCU with Arduino IDE.
  • Connection of IoT Cloud and Alexa application.

Sign Up for Arduino IoT Cloud Free account

For this home automation project, I explained to you how to set up a free Arduino IoT Cloud account. This setup connects ESP8266 to control appliances with Alexa.

Create An Arduino IoT Cloud

  1. In this step, I explained to you how to create an Arduino IoT Cloud account. First, you have to go to the following link
    https://create.arduino.cc/iot/things.
  2. Click on Create One.
  3. Enter all the required details it wants. Then click Next.
  4. On the next page, it requires an email, username and password for your
    Arduino IoT Cloud account. After filling in all of these, you have to agree to all terms and conditions.
  5. Now click on the Sign Up button.
  6. Then check your email. The verification email will be sent to your account. Click the link in the email and verify it.
  7. Then return to the Arduino IoT Cloud and refresh the page.
  8. At last click on the IoT Cloud.

Steps to Add Device

  1. Click on select device.
  2. Then click on set up a Third Party Device.
  3. Now select the device (ESP8266) and select the model (NodeMCU 1.0).
  4. There you can see all Arduino Cloud-compatible boards in the menu.
  5. Click on Continue.
  6. Enter a name for your device and click on Next.
  7. After that, you get the ID and secret key for your device. You can save details by clicking on download the PDF.
  8. At last, click Continue and your device will be added.

Steps to Add Variable in Arduino IoT Cloud Projects

To control sensors or relays, you have to get data from these. This data can be captured by variables. In this project, we need four variables. For a free plan, you can add upto five variables.

  1. Click on Add Variables.
  2. Name the variable and select the type as Alexa compatible switch.
  3. Click on Variable Permission as Read and Write and update policy as On Change
  4. Click Add Variables.
  5. In this process, you can add all types of Variables.

Creating Web Dashboard for Arduino IoT Cloud

  1. First, click on Dashboard and then ‘Build Dashboard’.
  2. Click on the edit button. Then click Add and there you can select the switch widget.
  3. Then came the switch and click the Link Variable button which is visible on the right.
  4. As we already create a variable in the previous step. Link this with the widget.
  5. Now click on Link Variable. Then click Done.
  6. Now you can add all the required widgets. In this project, we need four Switch widgets. After adding this, click on Things to exit the dashboard.

Sketch for Arduino IoT Cloud

After adding any variable to this, it will automatically be saved in the sketch tab. If you want to edit this further. You can open a full editor. From there you can download the sketch of the program for the microcontroller. For this project, the downloaded sketch is opened in Arduino IDE.

Installing Libraries

  1. In this step, we are going to install all libraries and other dependencies. In this project, we need a library for ESP8266.
  2. First, go to the sketch button.
  3. Then click include Libraries.
  4. Click manage libraries in Arduino IDE.
  5. There it will ask to install all dependencies. Click on Install All.

How to Update Project Sketch

To update the Sketch, open the .ino file in Arduino IDE. There you can enter the Thing ID, Device ID, WiFi credentials and Secret Key.

You can copy the Thing ID from the right corner of this window. Now paste the Thing ID and Device ID in the thingProperties.h file in Arduino IDE. Then paste WiFi credentials and the Secret key in the arduino_secrets.h file.
Now upload the code for ESP8266 in Arduino IDE.

How to Use Arduino Cloud Remote

First, install the ‘Arduino IoT Cloud Remote’ from Google Play Store. Then sign In to the app with the email which you use in the Arduino IoT Cloud account. Enter the Thing name to open the dashboard.

Program ESP8266 NodeMCU

  1. At first, Update the Preferences –> Aditional boards Manager URLs: https://dl.espressif.com/dl/package_esp32_index.json, and http://arduino.esp8266.com/stable/package_esp8266com_index.json
  2. Then install the ESP8266 board from the Board manager.
  3. Then install all required libraries and dependencies.

NodeMCU Code Alexa Home Automation System

When you upload the code to ESP8266, you can connect the Alexa app with it. The steps to connect Arduino IoT Cloud account with Amazon Alexa app in the following.

How to connect the Amazon Alexa app With ESP8266

  1. At first, click on More in the Amazon Alexa app.
  2. Then select Skills and Games.
  3. In the search option, you can find Arduino.
  4. Click Enable To Use.

How to Add Device to Alexa App

  1. In the Alexa app, sign in with the email and password which you used to log in to your Arduino IoT Cloud Account.
  2. Then Close it.
  3. Click on Discover Devices. Your device name is visible there in a few seconds.
  4. Then click on your device. Then select all the switches.
  5. If ESP8266 is connected to your WiFi, you can control all appliances from the Alexa app.
  6. Now you just need to say “Alexa, Turn On the light”. The light is on. With this voice command, you can control appliances with your voice.

How to Use This Project Manually

You can control appliances with push buttons. If you have no WiFi or internet connection, you can control it manually using this method.

Features of This Project

  • You can On/Off switches and smart plugs using your voice.
  • Increase or decrease the brightness of your room lights.
  • You can also change the colour of the lights.
  • You can check the room temperature with sensors.
  • See motion activity from sensors in your room.

2 thoughts on “Alexa Home Automation System Using Arduino IoT & ESP8266”

Leave a Comment