Smart Voice Controlled Home
Create New

Smart Voice Controlled Home



Smart Voice Controlled Home
Smart Voice Controlled Home

Project Rating

Overall Rating
2
0
0
0
0

Nowadays Automation plays 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 acts as an important role in the economy and in day to day life. Slowly automation has 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.

Download:
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> //  https://github.com/kakopappa/sinric/wiki/How-to-add-dependency-libraries
#include <ArduinoJson.h> // https://github.com/kakopappa/sinric/wiki/How-to-add-dependency-libraries (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 sinric.com 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 sinric.com 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: ");
    Serial.println(deviceId);
    digitalWrite(device_1, LOW);
  } 
  
  
  else {
    Serial.print("Turn on for unknown device id: ");
    Serial.println(deviceId);    
  }     
}

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

void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
  switch(type) {
    case WStype_DISCONNECTED:
      isConnected = false;    
      Serial.printf("[WSc] Webservice disconnected from sinric.com!\n");
      break;
    case WStype_CONNECTED: {
      isConnected = true;
      Serial.printf("[WSc] Service connected to sinric.com at url: %s\n", payload);
      Serial.printf("Waiting for commands from sinric.com ...\n");        
      }
      break;
    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"} // https://developer.amazon.com/docs/device-apis/alexa-powercontroller.html

        // 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") {
                turnOn(deviceId);
            } else {
                turnOff(deviceId);
            }
        }
        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 sinric.com");
        }
      }
      break;
    case WStype_BIN:
      Serial.printf("[WSc] get binary length: %u\n", length);
      break;
  }
}

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

  // Waiting for Wifi connect
  while(WiFiMulti.run() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  if(WiFiMulti.run() == WL_CONNECTED) {
    Serial.println("");
    Serial.print("WiFi connected. ");
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
  }

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

  // event handler
  webSocket.onEvent(webSocketEvent);
  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() {
  webSocket.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;
          webSocket.sendTXT("H");          
      }
  }   
}

// If you want a push button: https://github.com/kakopappa/sinric/blob/master/arduino_examples/switch_with_push_button.ino  

Comments

Leave a Comment

Post a Comment

About This Project

Project period

10/21/2019 - 11/18/2019

Views

19

Team Members

Courses

Get trained in Learny Technologies and develop your own applications.

New batch starts from Nov 13th.