Light Control Using Arduino and Amazon Alexa

972

14

3

Published

Introduction: Light Control Using Arduino and Amazon Alexa

About: Keen to know latest technologies

The main aim of the project is to control a light using Alexa.LED light is connected to Arduino and Arduino is connected serially with RPi.The server is running on RPi.

List of the materials

1.Arduino Uno ==> $8

2.Raspberry Pi 3 ==> $35

3.Resistor 221 ohm ==> $0.2

4.LED light ==> $0.2

5. Breadboard ==> $2.2

6. Jumper Wires ==> $ 2.5

Total cost of project is about $ 48 dollars.

I have explained how to control light which is connected to UNO and controlled by Alexa . There are many ways to use Alexa service . First we are going to install dependencies on RPi and then we create Alexa skill .

Step 1: Raspberry Pi

1. Install the required libraries

  • 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.Install Arduino IDE on RPi or you can program using your pc and then connect it serially with RPi.

To install Arduino in RPi

  • Go to official site and download previous release.

Arduino Website

After that unzip it and go to directory of arduino and start it with ./arduino as shown in image i1.

Program to be used in IDE

int led = 13;
void setup() { // put your setup code here, to run once:

pinMode(led, OUTPUT);

Serial.begin(9600);

}

void loop() {

if (Serial.read() == 'N')

{

digitalWrite(led, HIGH);

}

else if(Serial.read() == 'F')

{

digitalWrite(led, LOW);

}

}

After uploading program,open serial terminal when you write N led will turn on. When you write F led will turn off.It just for checking whether its working or not.

3. Python Script

Now,we have to make a script name it as you like (example.py) as shown in image i2 and run it using python example.py. You can download script from program section.

4. Download Ngrok

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.

Ngrok Website

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

./ngrok http 5000 as shown in image i3.

Step 2: Amazon

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

Amazon Developer

2. Go to Developer Console on top right side as shown in image i4.

3. Go to Alexa ==> Alexa skill kit ==> Add new skill as shown in image i5.

4. You will see page as shown in image i6. On this page it will ask skill type,name, language and invocation name .

  • skill type ==> custom
  • Name ==> Any name you like
  • Language ==> According to your country.
  • Invocation name ==> Any
  • click save and then next.

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.

5. Interaction Model (as shown in image i7 and i8)

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

More Info

Intent Schema

{
"intents": [

{

"intent": "LightOn"

},

{

"intent": "LightOff"

}

]

}

Sample Utterances

LightOn say on

LightOn say light on

LightOff say off

LightOff say light off

save it and move to next page.

6. On next page it will ask two option for end point one is AWS and HTTPS.
Here i am using HTTPS . The secure link is generated in Ngrok server use that your link is different than mine. Save it and move to next page as shown in image i9.

7. For SSL certificate choose second option. Save it and move to next page as shown in image i10.

8. To test whether our 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 as shown in image i11,i12,i13 and i14.

Step 3: Schematic

Step 4: Program

Step 5: Demo

Share

    Recommendations

    • Creative Misuse Contest

      Creative Misuse Contest
    • Clocks Contest

      Clocks Contest
    • Water Contest

      Water Contest

    3 Discussions

    Nice!
    You could use the RPI onboard GPIO pins and spare the arduino for another project

    That's a neat control system :) You should enter this in the Arduino contest too!

    1 reply

    Thanks man. I already posted another project have a look