How to Control Light/Home Lights Using Arduino and Amazon Alexa

by Kishor Prajapati in Circuits > Arduino

2905 Views, 42 Favorites, 0 Comments

How to Control Light/Home Lights Using Arduino and Amazon Alexa

ECHO-DOT.png

I have explained how to control light which is connected to UNO and controlled by Alexa.

Components Used

HARDWARE USED

  1. Arduino UNO & Genuino UNO
  2. Resistor 221 ohm
  3. LED (generic)
  4. Raspberry Pi 3 Model B

SOFTWARE REQUIRED

  1. Arduino IDE
  2. Amazon Alexa Alexa Skills Kit

Setting Up Raspberry Pi & Arduino IDE

1.First install binaries

sudo apt-get install python-pip

pip install flask

pip install flask-ask

sudo apt-get install pyserial

sudo apt-get intall libpython2.7-dev

2. Installing Arduino IDE on RPi

To install Arduino in RPi

1. Go to official site and download previous release. https://www.arduino.cc/en/Main/OldSoftwareRelease...

After that unzip it and go to directory of arduino and start it with ./arduino

Upload Program

Program to be used in arduino.PNG

After uploading program,open serial terminal.

When you write N led will turn on.

When you write F led will turn off.

Downloads

Make a Python Script

python script.PNG
puthon script 2.PNG

Run it using python lighcontrol.py

Download Ngrok

nagrok.PNG

Ngrok is secure tunneling platform to make your device online. With this platform you can make your web application or any application goes online with a very simple way. For download go to official site and download for ARM.

https://ngrok.com/

Unzip it and go to directory where you extract it. Run it using command

./ngrok http 5000

Setting Up Alexa

Go to developer console.jpg

1. Login to Amazon account.If you have an account then login it, if not signup there and login.

https://developer.amazon.com/

2. Go to Developer Console on top right side.

Go to Alexa ==> Alexa Skill Kit ==> Add New Skill

go to alexa.jpg

You will see page like this. On this page it will ask skill type,

name, language and invocation name .You can give any name, in invocation name you have to give name which you say while giving command to Alexa.

Please note select appropriate language which is used in you country if you select different language while creating skill. It will not work.

At the end update it ,save it and press next.

at end update.jpg

error see in red color.jpg

On next page, it will ask intents.An intent represents an action that fulfills a user’s spoken request. For more information

https://developer.amazon.com/docs/custom-skills/de...

If there is any error you will see in red color.

Write below code in the box

{
"intents": [

{

"intent": "LightOn"

},

{

"intent": "LightOff"

} ]

}

save it and move to next page.

On Next Page It Will Ask Two Option for End Point One Is AWS and HTTPS

using https.jpg

Select HTTPS & save it and move to next page.

For SSL Certificate Choose Second Option. Save It and Move to Next Page.

ssl certificate.jpg

Checking Service "on"

server requests.jpg

To test whether service is working or not . Make sure your Ngrok server is working and Python script also running otherwise it will not work.

You can see servers are getting request and post it.

Servers Getting Requests

server requests.jpg

Requested Are Posted

server requests1.jpg

Schematics Arduino

rpi-arduino_ICPzVxTA0a.png

Schematics LED

arduinoled_gZk5TQ1XBf.png

Hope you all like it.