IoT Alexa Home Automation System
Here how to control home appliances using Amazon Echo Dot Speaker with voice command. It is not that we are super lazy to toggle loads with switches, but in the age of IoT where everything is becoming “Smart”, we should also build a Smart Home Automation System. IoT based Home automation is very popular Arduino Uno and ESP8266 to build an IoT based Home automation System and nowadays different controllers like Raspberry Pi, ESP8266, Arduino.
Materials Required
1. Arduino Uno
2. Amazon Alexa dot speaker
3. ESP8266-01

For invoking Alexa in this method need some extra phrase like to turn on the bulb, we have to say that “Alexa, Alexa trigger turn on the bulb”. As you can see we have to say “Alexa trigger” on every invocation, this sounds very odd. So because of this much complexity we will use our previous method i.e. by using fauxmoESP library.
FauxmoESP library is available only for ESP boards and it doesn’t support Arduino boards.

Now, how to implement it in Arduino?. Here we will not use the ESP8266 module in AT mode but will use it in programming mode. So, we will upload the fauxmoESP code in this module and send a different character using serial communication whenever there is a change in state received (0 or 1) from Alexa. These characters will be received on Arduino board just like it receives data from Bluetooth module when it is interfaced with Arduino.

Installing Libraries for IoT Alexa Home automation
As we will create multiple virtual connections environment on ESP so we need to install fauxmoESP along with Asynchronous TCP library.
1. For ESP8266 download the Asynchronous TCP library from this link and for ESP32 download it from this link.
2. Then download fauxmoESP library from this link .
3. Now, unzip these files in libraries folder in your Arduino directory which can be found in Documents folder. Also, rename these folders as oseperez-fauxmoesp-50cbcf3087f to xoseperez_fauxmoesp and ESPAsyncTCP-master to ESPAsyncTCP.
4. There is an example code in fauxmoESP for controlling appliances we have to modify this example. Open Arduino IDE and go to Examples -> FauxmoESp -> fauxmoESP_Basic.

just remove Rx Tx wires from Arduino and upload the Arduino part code.
Then make the connection again but with slight changes.
Connect Rx of ESP8266 -> Tx of Arduino
Connect Tx of ESP8266 -> Rx of Arduino
Remove GPIO 0 of Esp8266 from the GND.

All connections remains same except above changes.
Now, we are done with the coding and hardware part. Its time to test our Home automation system. Also, note that the Wi-Fi network should remain same for both the ESP8266 and Amazon echo dot i.e. they have to share same Wi-

Testing the Arduino based Alexa Home Automation System
Now, try saying Alexa, Discover Devices. Alexa will respond like Starting discovering… I found two devices, try saying “Alexa, turn on Bedroom light”.

Now we are ready to test our IoT Alexa Home Automation System. So just try saying Alexa, turn on Bedroom light and the Relay one should be turned on.

Now say Alexa, turn off Bedroom light and relay one should turned off. Try giving commands to turn on/off the TV.

Arduino UNO code:

//Arduino Code:
char data;
void setup()
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
void loop()
if(Serial.available() > 0)
data =;
if(data == 'a')
digitalWrite(4, HIGH);
else if(data == 'b')
digitalWrite(4, LOW);
else if(data == 'c')
digitalWrite(5, LOW);
else if(data == 'd')
digitalWrite(5, HIGH);


#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
#define SERIAL_BAUDRATE 115200
#define WIFI_SSID "androiderode"
#define WIFI_PASS "22334455"
#define app1 "bedroom light"
#define app2 "tv"
fauxmoESP fauxmo; 
void wifiSetup() 
  while (WiFi.status() != WL_CONNECTED)
WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
void setup() 
  fauxmo.createServer(true); // not needed, this is the default value
  fauxmo.setPort(80); // This is required for gen3 devices
  fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
  device_id, device_name, state ? "ON" : "OFF", value);
if ((strcmp(device_name, app1) == 0))
      if (state)
if ((strcmp(device_name, app2) == 0)) 
      if (state) 

void loop() 
  static unsigned long last = millis();
  if (millis() - last > 5000)
    last = millis();

About the Author


Hello! My Dear Friends. I am Subramanian. I am writing posts on androiderode about Electronics testing and equipments.

View All Articles