Smart Voice Controlled Home Using Alexa
Data science projects in pondicherry
Create New

Smart Voice Controlled Home Using Alexa

Project period

10/21/2019 - 11/18/2019




Project Category


Smart Voice Controlled Home Using Alexa
Smart Voice Controlled Home Using Alexa

Nowadays Automation tools play a very important role in our day to day life. It provides home security and alerts us at times of emergency. Home automation is a system of interconnected things of hardware, communication, and electronic interfaces that work to desegregated our home devices with one another via common network. Every device is connected through Wi-Fi so that we can manage or control them through voice commands using ALEXA sitting away. This project is about home automation which means we process or control our home appliances such as fan, lights, air conditioners etc through ALEXA. Home automation helps to reduce human efforts; it saves energy and its time efficiency. Whatever your smart home can perform can now be controlled by your voice. Yes, it's Alexa's home automation!

Why: Problem statement

People wish to better their lifestyle and finding different ways to make things easy and simple, they wish to upgrade to the latest technology. Customers are attracted more by the latest or new upgrading technologies that make their lifestyle easier and simple. Automation tools act as an important role in the economy and in day to day life. Slowly automation tools have been implemented in our homes. Its uses and benefits can be applied in the TV remote controls, fire alarm systems, water tank management systems, and also in security systems. People have started to depend on Automation to make their works easy, simple and secure. Automating Home also helps in saving electricity, minimizes manual labor, and increases awareness in handling security. The objective of this project is to help old aged people and handicapped people who will be able to control all home appliances from a place. It would also play a major role in everyone’s part of life as it could reduce their effort and energy.

How: Solution description

This project clearly explains the method and design implemented for home automation.

How is it different from competition

The home automation system can minimize electricity usage and automatically turn off lights and fans when they aren’t in use. Controlling all our home appliances from one place would be more convenient. The convenience factor here is very large. Connecting all devices or technologies in the home through one system is a huge step towards technology or home management. Home automation is something that the entire family can feel and enjoy.  It can decrease the chance of tripping.  Some works are tiresome which can be solved automatically. There are no monthly subscriptions to use ALEXA home automation, its completely free after installment. It helps us to automate a bulk of electronic devices at home. This is wireless home automation. It helps to maximize security. Future technology of home automation systems involves making homes even smarter or easier. Homes can be connected with sensors which include motion sensors, light sensors, and temperature sensors and provide automated switching of devices based on conditions.

Block Diagram:


Who are your customers

The general public, offices, industries and hospitals.

Project Phases and Schedule

Phase 1: Circuit design.

Phase 2: Programming Node MCU.

Phase 3: Interfacing Alexa.

Resources Required

Software Required:

  • Arduino IDE.

Hardware required:

  • Amazon Alexa.
  • Node MCU.
  • 5v Relay.
  • Connecting Cables.
  • LED Tube light.

Project Code Code copy
/* Your file Name : alexa-node-sinric (1).ino */
/* Your coding Language : arduino */
/* Your code snippet start here */
 Version 0.4 - April 26 2019

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WebSocketsClient.h> //
#include <ArduinoJson.h> // (use the correct version)
#include <StreamString.h>

int device_1 = 5;

ESP8266WiFiMulti WiFiMulti;
WebSocketsClient webSocket;
WiFiClient client;

#define MyApiKey "09884be7-7193-4bf9-ac2a-12223bc38780" // TODO: Change to your sinric API Key. Your API Key is displayed on dashboard
#define MySSID "vivo Y21L" // TODO: Change to your Wifi network SSID
#define MyWifiPassword "thalapathy" // TODO: Change to your Wifi network password

#define HEARTBEAT_INTERVAL 300000 // 5 Minutes 

uint64_t heartbeatTimestamp = 0;
bool isConnected = false;

// deviceId is the ID assgined to your smart-home-device in dashboard. Copy it from dashboard and paste it here

void turnOn(String deviceId) {
  if (deviceId == "5d7f7cebf4f913303e594d35") // Device ID of first device
    Serial.print("Turn on device id: ");
    digitalWrite(device_1, LOW);
  else {
    Serial.print("Turn on for unknown device id: ");

void turnOff(String deviceId) {
   if (deviceId == "5d7f7cebf4f913303e594d35") // Device ID of first device
     Serial.print("Turn off Device ID: ");
     digitalWrite(device_1, HIGH);
  else {
     Serial.print("Turn off for unknown device id: ");

void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
  switch(type) {
    case WStype_DISCONNECTED:
      isConnected = false;    
      Serial.printf("[WSc] Webservice disconnected from!\n");
    case WStype_CONNECTED: {
      isConnected = true;
      Serial.printf("[WSc] Service connected to at url: %s\n", payload);
      Serial.printf("Waiting for commands from ...\n");        
    case WStype_TEXT: {
        Serial.printf("[WSc] get text: %s\n", payload);
        // Example payloads

        // For Switch or Light device types
        // {"deviceId": xxxx, "action": "setPowerState", value: "ON"} //

        // For Light device type
        // Look at the light example in github
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject((char*)payload); 
        String deviceId = json ["deviceId"];     
        String action = json ["action"];
        if(action == "setPowerState") { // Switch or Light
            String value = json ["value"];
            if(value == "ON") {
            } else {
        else if (action == "SetTargetTemperature") {
            String deviceId = json ["deviceId"];     
            String action = json ["action"];
            String value = json ["value"];
        else if (action == "test") {
            Serial.println("[WSc] received test command from");
    case WStype_BIN:
      Serial.printf("[WSc] get binary length: %u\n", length);

void setup() {
  pinMode(device_1, OUTPUT);
  WiFiMulti.addAP(MySSID, MyWifiPassword);
  Serial.print("Connecting to Wifi: ");

  // Waiting for Wifi connect
  while( != WL_CONNECTED) {
  if( == WL_CONNECTED) {
    Serial.print("WiFi connected. ");
    Serial.print("IP address: ");

  // server address, port and URL
  webSocket.begin("", 80, "/");

  // event handler
  webSocket.setAuthorization("apikey", MyApiKey);
  // try again every 5000ms if connection has failed
  webSocket.setReconnectInterval(5000);   // If you see 'class WebSocketsClient' has no member named 'setReconnectInterval' error update arduinoWebSockets

void loop() {
  if(isConnected) {
      uint64_t now = millis();
      // Send heartbeat in order to avoid disconnections during ISP resetting IPs over night. Thanks @MacSass
      if((now - heartbeatTimestamp) > HEARTBEAT_INTERVAL) {
          heartbeatTimestamp = now;

// If you want a push button:  


Leave a Comment

Post a Comment

Are you Interested in this project?

Do you need help with a similar project? We can guide you. Please Click the Contact Us button.

Contact Us

Social Sharing