Introduction: Amazon Alexa Smart Home Using Node MCU

About: ignite.innovate.ideas

UPDATE : THE UPDATE VERSION OF THIS PROJECT CAN BE FOUND HERE

One of the most common hobby projects you will come across the internet is HomeAutomation. There you will be controlling devices in your house through your smartphone via wifi/Bluetooth. But here we won't be using any smartphone. we will be using our own voice for it. No need to take phone everytime to control any device. Just say "Alexa turn on the device" and it will automatically do it for you.

Step 1: THINGS YOU NEED

Step 2: WHAT IS ALEXA? WHO IS SHE ?? 

Amazon Alexa is a virtual assistant developed by Amazon. This assistant is used in Amazon speaker(Echo, Echo dot, Plus). This virtual assistant do many things like play music, read the flash news and much more if you want to know more about it then read this article

Step 3: WATCH THE VIDEO TUTORIAL

Step 4: Creating Virtual Smart Home Devices

For interfacing NodeMCU and Amazon Alexa, we will be using an Amazon skill called Sincric

  • First of all, you need to create an account in Sinric. Sinric is a website which allows linking your development boards like RaspberryPi, ESP8226, ESP32 or Arduino with Amazon Alexa.
  • Once the account is created login into it. Then click on the Smart Home DeviceAdd button to create a new smart home device
  • Create as many devices which you want to control. In my case, I have created 4 Smart Home Devices.
  • For this project, we will be using NodeMCU wifi module. So for programming the board using Arduino IDE you need to download some additional boards. I have written a separate article showing how to do it

Step 5: Configuring the Virtual Device


  • Download the example Sinric code from Github by kakopappa
  • Download and install WebSocketsClient.h and ArduinoJson.h library
  • Now open switch_example.ino example from the downloaded file
    Do the following changes in the code.

#define MyApiKey ""
  • Enter your unique API key from the Sinric website, In my case, it was something like this db8d0309-84ce-485b-8957-xxxxxxxxxxxx
#define MySSID ""
  • Enter your wifi network name here (case sensitive), your Amazon echo device should be in this same network.
<p>#define MyWifiPassword ""</p>
  • Enter your wifi network password (case sensitive).
void turnOn(String deviceId)
{<br>  if(deviceId == "xxxxxxxxxx") // Device ID of device 1
  {<br>    Serial.print("Turn on device id: ");<br>    Serial.println(deviceId);
    digitalWrite(device1, HIGH);<br>  }
  • In the If condition enter your device 1 ID from Sinric website. In my case, it was 5b13a012870d4c3a139be009
  • Do the same for all the devices in both turnOn and turnOn function
  • Once everything is done. Select the correct board and upload the sketch.
  • The NodeMCU will automatically connect to the wifi network
  • .Make sure your wifi is turned ON and your Echo device is connected to same.

Step 6: CONFIGURING SMARTHOME IN ALEXA APP

  • Open the Alexa App in your smartphone
  • Go to the Skills & Games section and search for Sinric skill and enable it
  • Now search for devices or just ask say "Alexa, discover devices"It will show the number of available devices (In my case four).
  • You can Rename the device name to whatever you want like fan, light ...

Step 7: ELECTRONICS

The circuit is very simple, but be careful while connecting AC load to relay.

Always turn OFF the mains before opening any switchboard.



Now Almost everything is done. All you need is connect the AC loads to relay and sit back and enjoy the automation. Feel your self as Tony Stark ; )


Feel free to ask any queries.

Subscribe to blog for more DIY projects

http://igniteinnovateideas.wordpress.com