Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Voice Based Home Automation with NodeMCU & Alexa using fauxmoESP
ESP8266 Projects IoT Projects

Voice Based Home Automation with NodeMCU & Alexa using fauxmoESP

Mamtaz AlamBy Mamtaz AlamUpdated:October 21, 202313 Comments3 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Home Automation with NodeMCU & Alexa
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Introduction:

This post is about Voice Based Home Automation with NodeMCU & Alexa using fauxmoESP. This IOT Project tutorial is based on the great open source lib & example developed by Xosé Perez (Tinkerman).

fauxmoESP is a library for ESP8266-based devices that emulates a Belkin WeMo device and thus allows you to control them using this protocol, in particular from Alexa-powered devices like the Amazon Echo or the Dot. You may use the Alexa with Espalexa library for more enhanced Home Automation Project.



But before that, you can check some of our Home Automation Projects made using ESP8266 or ESP32:
1. Home Automation with Arduino IoT Cloud using ESP32
2. Home Automation using NodeMCU & Android
3. Home Automation using ESP8266 WebServer
4. Home Automation using Blynk & NodeMCU
5. Home Automation using Google Firebase & NodeMCU
6. Industrial Automation using ESP8266 & AWS IoT Core


Alexa & Echo Dot

What is Alexa?

Alexa is capable of voice interaction, music playback, making to-do lists, setting alarms, streaming podcasts, playing audiobooks, and providing weather, traffic, and other real-time information. Alexa can also control several smart devices using itself as a home automation hub. We will use this project, the “Echo-Dot”, that allows users to activate the device using a wake-word, such as “Alexa” or “Computer”, as in “Star Trek!.

In the home automation space, Alexa can interact with several different devices as Philips Hue, Belkin Wemo, SmartThings, etc.

What is Echo Dot?

Echo Dot is a voice-controlled speaker that uses Alexa to play music, control smart home devices, make calls, answer questions, set timers and alarms, and more.

Home Automation with NodeMCU & Alexa


Features
1. Play music from Amazon Music, Spotify, Pandora, iHeartRadio, TuneIn, and SiriusXM
2. Call or message family and friends hands-free, or drop in from the Alexa App to your Echo device
3. Controls lights, locks, thermostats, and more with compatible connected devices
4. Use the built-in speaker, or for bigger sound, connect to speakers through Bluetooth or audio cable


Components Required for this Project:

The following are the list of components for designing Voice Based Home Automation with NodeMCU & Alexa Echo Dot.

Home Automation with NodeMCU & Alexa

  1. NodeMCU ESP8266-12E
  2. Echo Dot (2nd Generation)
  3. 2 X Mini BreadBoard
  4. 4-Channel Relay Module
  5. Male-Female Dupont Cables
  6. External 5V power supply or Battery

Block Diagram:

The below block diagram shows what will be developed in this project:


Circuit: Voice Based Home Automation with NodeMCU & Alexa

Assemble the hardware as shown in the figure below on your breadboard for Voice-Based Home Automation with NodeMCU & Alexa using fauxmoESP.

Home Automation with NodeMCU & Alexa



Setup for uploading Code & Libraries:

Step 1: Setup Arduino Preference for NodeMCU
Go to the file of Arduino IDE and select Preferences. Then add the following link in the “Additional Boards Manager URLs”, as shown in the figure below:

C++
1
http://arduino.esp8266.com/stable/package_esp8266com_index.json

 

Step 2: NodeMCU Board Installation
Go to Board Manager and Instal NodeMCU Board version 2.3.0 It’s very important otherwise Alexa doesn’t discover devices.

Step 3: Board Selection
Select Your NodeMCU board with the correct model as shown in the figure:

Step 4: Adding Libraries
You need to download 3 different libraries and add them to Arduino IDE Library. The libraries are:
1. fauxmoESP Library
2. ESPAsync TCP Library
3. ESPAsync Web Server Library

Download Library



Video Tutorial & Explanation:

Voice Based Home Automation with NodeMCU and Alexa | DIY IoT Project
Watch this video on YouTube.


Source Code/Program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#include <Arduino.h>
#ifdef ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include "fauxmoESP.h"
 
#define WIFI_SSID "..your wifi name.."
#define WIFI_PASS "..your wifi password.."
 
#define SERIAL_BAUDRATE 115200
#define LED 2
 
/* Set Relay Pins */
#define RELAY_1 D5
#define RELAY_2 D6
#define RELAY_3 D7
#define RELAY_4 D8
 
fauxmoESP fauxmo;
// -----------------------------------------------------------------------------
// Wifi
// -----------------------------------------------------------------------------
 
void wifiSetup() {
 
// Set WIFI module to STA mode
WiFi.mode(WIFI_STA);
 
// Connect
Serial.printf("[WIFI] Connecting to %s ", WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
 
// Wait
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}
Serial.println();
 
// Connected!
Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
 
}
 
void setup() {
 
Serial.begin(SERIAL_BAUDRATE);
//setup and wifi connection
wifiSetup();
 
//Set relay pins to outputs
pinMode(RELAY_1, OUTPUT);
pinMode(RELAY_2, OUTPUT);
pinMode(RELAY_3, OUTPUT);
pinMode(RELAY_4, OUTPUT);
 
//Set each relay pin to HIGH ====== NOTE THAT THE RELAYS USE INVERSE LOGIC =====
digitalWrite(RELAY_1, HIGH);
delay(500);
digitalWrite(RELAY_2, HIGH);
delay(500);
digitalWrite(RELAY_3, HIGH);
delay(500);
digitalWrite(RELAY_4, HIGH);
delay(500);
 
// You have to call enable(true) once you have a WiFi connection
// You can enable or disable the library at any moment
// Disabling it will prevent the devices from being discovered and switched
fauxmo.enable(true);
fauxmo.enable(false);
fauxmo.enable(true);
 
// Device Names for Simulated Wemo switches
fauxmo.addDevice("Light One");
fauxmo.addDevice("Light Two");
fauxmo.addDevice("Outlet One");
fauxmo.addDevice("Outlet Two");
fauxmo.addDevice("Bed Room");
fauxmo.addDevice("Living Room");
fauxmo.addDevice("All Devices");
 
// fauxmoESP 2.0.0 has changed the callback signature to add the device_id,
// this way it's easier to match devices to action without having to compare strings.
fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
Serial.printf("[MAIN] Device #%d (%s) state: %s value: %d\n", device_id, device_name, state ? "ON" : "OFF", value);
digitalWrite(LED, !state);
 
//Switching action on detection of device name
 
if ( (strcmp(device_name, "Light One") == 0) )
{
if (!state)
{
digitalWrite(RELAY_1, HIGH);
}
else
{
digitalWrite(RELAY_1, LOW);
}
}
 
if ( (strcmp(device_name, "Light Two") == 0) )
{
if (!state)
{
digitalWrite(RELAY_3, HIGH);
}
else
{
digitalWrite(RELAY_3, LOW);
}
}
 
if ( (strcmp(device_name, "Outlet One") == 0) )
{
if (!state)
{
digitalWrite(RELAY_2, HIGH);
}
else
{
digitalWrite(RELAY_2, LOW);
}
}
 
if ( (strcmp(device_name, "Outlet Two") == 0) )
{
if (!state)
{
digitalWrite(RELAY_4, HIGH);
}
else
{
digitalWrite(RELAY_4, LOW);
}
}
 
if ( (strcmp(device_name, "Bed Room") == 0) )
{
if (!state)
{
digitalWrite(RELAY_3, HIGH);
digitalWrite(RELAY_4, HIGH);
}
else
{
digitalWrite(RELAY_3, LOW);
digitalWrite(RELAY_4, LOW);
}
}
 
if ( (strcmp(device_name, "Living Room") == 0) )
{
if (!state)
{
digitalWrite(RELAY_1, HIGH);
digitalWrite(RELAY_2, HIGH);
}
else
{
digitalWrite(RELAY_1, LOW);
digitalWrite(RELAY_2, LOW);
}
}
 
if ( (strcmp(device_name, "All Devices") == 0) )
{
if (!state)
{
digitalWrite(RELAY_1, HIGH);
digitalWrite(RELAY_2, HIGH);
digitalWrite(RELAY_3, HIGH);
digitalWrite(RELAY_4, HIGH);
}
else
{
digitalWrite(RELAY_1, LOW);
digitalWrite(RELAY_2, LOW);
digitalWrite(RELAY_3, LOW);
digitalWrite(RELAY_4, LOW);
}
}
 
});
 
}
 
void loop() {
 
// Since fauxmoESP 2.0 the library uses the "compatibility" mode by
// default, this means that it uses WiFiUdp class instead of AsyncUDP.
// The later requires the Arduino Core for ESP8266 staging version
// whilst the former works fine with current stable 2.3.0 version.
// But, since it's not "async" anymore we have to manually poll for UDP
// packets
fauxmo.handle();
 
static unsigned long last = millis();
if (millis() - last > 5000) {
last = millis();
Serial.printf("[MAIN] Free heap: %d bytes\n", ESP.getFreeHeap());
}
 
}

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleTemperature Meter using DS18B20 OLED Display & Arduino
Next Article Measure Tilt Angle Using MPU6050 Gyro/Accelerometer & Arduino

Related Posts

IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20261K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

Updated:February 1, 20261K
View 13 Comments

13 Comments

  1. Suryateja on December 1, 2018 7:52 AM

    After complete uploading code how to connect alexa.

    Reply
    • Alex Newton on December 1, 2018 2:19 PM

      edit the code. set your wifi password and wifi ssid. then open serial monitor, alexa will automatically get conected.

      Reply
      • lencho on December 11, 2018 3:35 PM

        no sir alexa is not connecting.. please help me….

  2. Manu on January 31, 2019 11:08 PM

    not getting discovered on Echo Version 3,
    on Serial output I am getting only this

    [MAIN] Free heap: 50712 bytes
    [MAIN] Free heap: 50712 bytes
    [MAIN] Free heap: 50712 bytes

    Reply
  3. Ajay Siswal on February 3, 2019 12:47 AM

    Alexa is not discovered my NODE MCU , plz help me , i used your code only…

    Reply
    • DHARAM PAWAR on September 30, 2019 10:01 AM

      Sir,
      First of all thanks to you,because i try to run lot of node micro controller based project, out of these your project is running in first attempt.
      I am very glad to run this project but last few days ago my node mcu device is not discovered by alexa.
      Programme downloaded successfully.

      i make lot of efforts to run this but still i am zero.

      efforts by me are as:-
      i reset the alexa dot 3rd generation.
      i reinstall the alexa app.
      using arduino ide 1.8.10 version.
      now i m using esp8266 community 2.3.0 version.
      Three libraries – ESPAsyncTCP-master,
      ESPAsyncUDP-master,
      xoseperez-fauxmoesp-f60c46d80f9b

      At location-C:\Users\dharam\Documents\libraries

      Serial monitor message is –
      [MAIN] Free heap: 46512 bytes
      [MAIN] Free heap: 46512 bytes
      [MAIN] Free heap: 46512 bytes
      [MAIN] Free heap: 46512 bytes
      [MAIN] Free heap: 46512 bytes

      Sir please help me to resolve this issue(Alexa does not discover any device )

      Regards,
      D.M.Pawar

      Reply
  4. DHARAM PAWAR on October 15, 2019 11:03 AM

    sir still i am not receiving any response .

    Reply
  5. DHARAM PAWAR on January 30, 2020 6:20 PM

    sir as i think your code for is not for your follower
    you have made this only for your self
    so can we run this project.

    Reply
    • Alex on January 30, 2020 6:22 PM

      Hey, whatever device I make I post it on the website for the public. And definitely you can run the project.

      Reply
      • DHARAM PAWAR on January 30, 2020 7:00 PM

        Sir please help me to resolve this issue(Alexa does not discover any device )

  6. Philippe Van Gastel on February 15, 2020 10:23 PM

    Dear,

    I follwed your instructions, but once the compiler loads the program in the NodeMCU, I see that it connects to the internet, gets an IP address, and then I only get ^MAIN] Free heap: 50640 bytes.
    I tried to use the smartphone Alexa app to add devices, but although I’m on the same WiFi spot on my LAN, it cannot discover the NodeMCU (I tried with “other” at the very bottom of the list).

    Any idea what I can check ?

    Thks in advance for your support.

    Reply
  7. Techtron on September 5, 2020 7:31 PM

    Not a single review show successful project. Sir could you please respond to that issue. There is nothing in description showing device authorization or account credentials. It does not connect to alexa. Keeps printing “[MAIN] Free heap: 50616 bytes
    ” How come it connect to Alexa automatically? To whose account it connects? Needs additional info here @Mr.Alam (Author.)

    Reply
  8. Miguel de Castro Borreg on December 13, 2022 6:57 PM

    Buenas noches, problemas con su código, no genera paguina WEB ni se conecta con Alexa…… Alguna solución

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • IoT Based Electricity Energy Meter using ESP32 & Blynk
    IoT Based Electricity Energy Meter using ESP32 & Blynk
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.