Monday, June 24, 2024

Voice Based Home Automation System

efy testThis project presents a voice based home automation system that can be used by differently abled people, geriatrics, and the others to control home appliances and thus convert a non-smart home into a smart home. To achieve this in a simple way, Amazon Echo is used to communicate with the circuit to control the appliances.The controller used for the automation in this project is NodeMCU. When a command is given by the user to Alexa, NodeMCU gets the information through Wi-Fi and decides the switching action to be taken with respect to the electrical appliances connected to it through relays.

NodeMCU controller board
Fig. 1: NodeMCU controller board

Main components used in the project are shown in Fig. 1 through Fig. 3, while circuit diagram of the home automation system using Alexa is shown in Fig. 4. NodeMCU used as the controller board is pre-programmed to connect with the Wi-Fi network and then take the commands from Alexa to perform the tasks as per instructions in the code, like turning on or turning off the lights or fans.

Alexa Echo Dot
Fig. 2: Alexa Echo Dot

Connect input pins IN1 and IN2 of the 2-channel relay to digital pins of the NodeMCU as per the code. If you are controlling pins D2 and D3 of NodeMCU using Alexa, then the relay IN pins should be connected to the same D2 and D3 pins.

Two-relay module
Fig. 3: Two-relay module

The ground pin in NodeMCU and the relay are connected similarly; the Vcc pin of relay is connected to Vin of NodeMCU. Vcc and GND pins of NodeMCU are connected to external 5V DC supply. One terminal of the appliance is connected directly to the relay (normally open) and the other is in series with 220V AC supply and the relay pin (common).

Circuit diagram of the home automation system
Fig. 4: Circuit diagram of the home automation system
Bill of Material
Components Description Quantity
Amazon Alexa Eco Dot Alexa based smart speaker 1
NodeMCU Microcontroller board 1
5V, 2-relay module (R1, R2) 1A, 110V-220V AC relays 1
B1, B2 230V AC, 60W bulbs 2
Wires Female to female jumper wires 4
Flow chart of the project
Fig. 5: Flow chart of the project


The software used for this project is Arduino for the microcontroller and Sinric from Alexa app to interface with the hardware. Install the Arduino software and then install the necessary boards required for NodeMCU, as shown in Fig. 6.

- Advertisement -
Installing the boards
Fig. 6: Installing the boards

Next, copy the below link and paste it in Boards Manager: Link

Click OK to close the preference tab. Go to Tools and Board, select Board Manager, and navigate to ‘esp8266 by esp8266 community’ and install the software for Arduino from there.

We are now ready to program our NodeMCU with Arduino IDE. So, now we need to set the Sinric to get our Alexa and NodeMCU connected to each other.

- Advertisement -

Install Alexa app in your Android or iOS and complete the setup of Amazon Alexa. Open Chrome or Firefox and copy the link, which on clicking appears as shown in Fig. 7.

Sinric webpage
Fig. 7: Sinric webpage

Register for a free account and login into this account. There you can find your API key, which is unique, and options to generate smart home devices.

Create the code for NodeMCU. Open the .ino code file (check and then configure the Wi-Fi SSID and password of your home network. In the code, select the NodeMCU board and upload the code to the board. Image of the code snippet setting Wi-Fi and password is shown in Fig. 8.

Code snippet setting Wi-Fi and password
Fig. 8: Code snippet setting Wi-Fi and password

Construction and testing

Next step is to interface the NodeMCU with Amazon Alexa Eco. Start discovering the devices by saying “Alexa discover devices.” The discovered devices will get displayed in the app, as shown in Fig. 9. Please ensure that the Wi-Fi SSID and password for NodeMCU and Wi-Fi to which Alexa is connected are the same.

Discovered devices
Fig. 9: Discovered devices

Now, we can send commands to Amazon Echo. Alexa will respond to the following commands:

Working of the project
Fig. 10: Working of the project

“Alexa, turn on light 1”
“Alexa, turn off light 1”
“Alexa, turn on light 2”
“Alexa, turn on light 2”
“Alexa, turn on light 3”
“Alexa, turn off light 3”
“Alexa, turn on fan”
“Alexa, turn off fan”

Echo Dot ready to receive commands
Fig. 11: Echo Dot ready to receive commands

When you say “Alexa, turn on light 1,” the esp8266 will trigger a relay to turn on light 1. When you say “Alexa, turn off light 1,” the esp8266 will send a signal to the relay to turn off light 1, as shown in Fig. 10. This works similarly for light 2, light 3, and the fan.

Light in off state before the command
Fig. 12: Light in off state before the command

Fig. 11 shows how to give command to Echo Dot, Fig. 12 and Fig. 13 show the light’s status (off and on) before and after giving the commands to Alexa.

Light in on state after the command
Fig. 13: Light in on state after the command


Download Source Code

N.M. Sai Krishna, Assistant Professor at BVRIT Hyderabad College of Engineering for Women, is an IoT and Embedded Systems enthusiast. R. Priyakanth, Associate Professor at the same college is an IoT, Embedded Systems, and Signal Processing enthusiast. A. Pranava is final year student at the college.


Unique DIY Projects

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components