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


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.

PCB Design

For removing messy wiring and giving a clean look, I designed a PCB prototype for this project. It is also helpful for troubleshooting that runs great without any errors. To design this PCB board, I used EasyEDA as it is too easy to use. For ordering PCB for this, I prefer PCBWay.

Gerber file for Alexa Home Automation System Gerber.

PCB View

Alexa Home Automation System 2d
2D View
Alexa Home Automation System 3d
3D View

Order PCB From PCBWay

PCBs are the neatest and most professional-looking among the assembled circuit types. Any electronic circuit that needs to be professional looking uses PCB boards. But soldering is still required on the copper area on the PCB. In the early 1900s, the only way to make circuits for electrical or electronic components was by wiring them point-to-point on a chassis. These chassis were either pan or sheet. These methods made circuits very fragile and large or bulky, and expensive.

There are so many forums or communities for electronics online in today’s technical world, and one of the famous ones for PCB manufacturing is PCBWay. PCBWay is a place that brings manufacturers and customers together. They have more than a decade of experience in the field of fabrication and prototyping and assembling of PCBs. PCBWay has proved its focus on its customers’ needs in terms of cost-effectiveness, delivery, and quality. And this can be proved by their outstanding customer reviews. Not only has this PCBWay provided a platform for students and electronic hobbyists to display their projects to the community but also given sponsorships if their work is attractive. Check out the large pool of sponsored projects here.

How PCB Manufacturing Process Done in PCBWay

Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity through quality control in designing and manufacturing. At first, they ensure the accuracy, clarity, and validity of the PCB files that we sent to them.

Then all the boards will go through the most stringent tests other than the basic visual check. They adopt most of the testing and inspecting equipment used in the industry, such as Flying Probe Testers, X-Ray Inspection machines, and Automated Optical Inspection (AOI) Machines. PCBWay are having 50+ new engineers on the daily basis around the world using PCBs for their work, who trust their reliable quality. They produce high-quality pink, orange, grey, and even transparent solder mask. Moreover, according to people’s needs, they can also provide Black core PCB. Check it out for a High-Quality PCB solder mask. There are some pictures below of the new colours of solder musks.

Features of PCBWay

PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, and Flexible and Rigid-Flex boards, at a very reasonable price. Just check this Instant Quote to order premium PCBs for your hobby projects.

PCB Assembly: It not only offers PCB Prototyping but also offers PCB Assembly service. You can order a full PCB board with attached components by uploading your file. SMT & THT assembly starts from only 30$ including free stencil and worldwide shipping. The components can be sourced and provided by PCBWay, or by the clients themselves.

Open Source Community: It not only offers PCB Prototype & Assembly services but also gives opportunities to students for sponsorships. I think this is so great. They feature their projects on the website also.

3D Printing & CNC: It also produces Rapid Prototyping like 3D printing, CNC Machining, Sheet Metal Fabrication, and Injection Molding. The quality of the product is too premium and reliable. And also the best part is that you will receive your order within a minimum of 3 days.

Services: PCBWay offers great servicing of its products. It takes only 3 to 15 days according to the courier service to deliver your products. Also, it has a live support facility. Whenever you have any problems, you can always reach a live customer service person to respond to your emails or messages. They have the “Return and Refund” principle, for every unusable board caused by PCBWay, they will rebuild and refund the order soon.

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