In this project I integrate an old development of home automation (air conditioning and appliances control ) using an Arduino Uno and the Ethernet Shelf with the platform of Amazon's Alexa Skill Kit, using the Raspberry Pi with Flask-Ask: A New Python Framework for Rapid Alexa Skills Kit Development.
Initially I wanted to integrate my Arduino Uno with some sdk library that would support AWS IoT, but after an arduous search without any success and having found in the forums the following "Unfortunately, Arduino Uno and its library does not have a crypto library, or enough runtime memory capable of passing through the authentication process. You might need a more powerful device to transmit/receive data through AWS IoT."
And because I did not have the possibility of acquiring an Arduino Yun compatible with the AWS IoT Arduino Yun SDK, to present it in this project, I decided to communicate my old development of home automation with the Raspberry Pi through a UDP (User Datagram Protocol).
It was not necessary to have an Echo to develop this project, instead install on my device the Reverb, application that allows you to interact with Alexa from anywhere.
Let's see how I get this job:
Configuring the Arduino Uno- Load the code MyRemoteHome.ino annexed in this project to the Arduino One, I use the version Arduino IDE 1.0.4 .
- Testing the communication UDP with the Arduino with the Hercules Software:
Configuring the Raspberry Pi
- Install Raspbian from https://www.raspberrypi.org/downloads/:
- You'll need Python and pip installed,
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install python2.7-dev python-dev python-pip
- Once Python and pip are installed, open a terminal, and type the below command to install Flask-Ask. Note: You might need to precede it with sudo on Unix if you get permission errors.
sudo pip install Flask flask-ask
- Install ngrok from the link https://ngrok.com/download and get the latest Linux ARM release as a zip and unzip inside the home directory, it allows you to expose a web server running on your local machine to the internet. Just tell ngrok what port your web server is listening on.
unzip /home/pi/ngrok-stable-linux-arm.zip
- To start a HTTP tunnel on port 500, run this next:
sudo ./ngrok http 5000
- Open the Python 2(IDLE) and select New File and copy the code MyRemoteHome.py, then Run Module
- Sing in in the https://developer.amazon.com/ and select Alexa Skills Kit:
- Add a New Skill
- Set the Name and the Invocation Name and click Next:
- Now you are into the Interaction Model Builder, and copy the next code in the Code Editor:
{
"languageModel": {
"types": [
{
"name": "CONTROLS",
"values": [
{
"id": null,
"name": {
"value": "up",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "down",
"synonyms": []
}
}
]
},
{
"name": "DEVICES",
"values": [
{
"id": null,
"name": {
"value": "fan",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "lamp",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "ac",
"synonyms": [
"air conditioner",
"air conditioning"
]
}
}
]
},
{
"name": "FOOD",
"values": [
{
"id": null,
"name": {
"value": "water",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "feed",
"synonyms": [
"meal"
]
}
}
]
},
{
"name": "LOCATIONS",
"values": [
{
"id": null,
"name": {
"value": "living room",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "kitchen",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "balcony",
"synonyms": []
}
}
]
},
{
"name": "STATUS",
"values": [
{
"id": null,
"name": {
"value": "on",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "off",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "auto",
"synonyms": []
}
}
]
},
{
"name": "VARIABLES",
"values": [
{
"id": null,
"name": {
"value": "temperature",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "humidity",
"synonyms": []
}
},
{
"id": null,
"name": {
"value": "setting",
"synonyms": []
}
}
]
}
],
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "EnvironmentIntent",
"samples": [
"to turn the {device} {status}",
"what is the {variable} of the {location}",
"{control} the temperature of the air conditioning",
"{control} the temperature of the ac",
"what is the {variable} of the of the ac",
"which is the {variable} of ac",
"which is the {variable} of the air conditioning"
],
"slots": [
{
"name": "device",
"type": "DEVICES"
},
{
"name": "status",
"type": "STATUS"
},
{
"name": "variable",
"type": "VARIABLES"
},
{
"name": "location",
"type": "LOCATIONS"
},
{
"name": "control",
"type": "CONTROLS"
}
]
},
{
"name": "IluminationIntent",
"samples": [
"to turn {status} the {device} in the {location}"
],
"slots": [
{
"name": "status",
"type": "STATUS"
},
{
"name": "device",
"type": "DEVICES"
},
{
"name": "location",
"type": "LOCATIONS"
}
]
},
{
"name": "MydogIntent",
"samples": [
"to {food} Buddy",
"to give Buddy {food}"
],
"slots": [
{
"name": "food",
"type": "FOOD"
}
]
}
],
"invocationName": "my home"
}
}
- Now you can see the Intents, Slot Types of the model:
- Now go to the configuration, and copy from the Server ngrok running on the Raspberry Pi the URL following:
- No paste this URL in the default field, and click Next:
- Select "My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority" in the SSL Certificate:
- Testing the Model using the Service Simulator:
- Now install the Reverb for Amazon Alexa App to test the project.
- Use this link https://alexa.amazon.com/spa/index.html#cards to enable your skill
- The following are the videos showing each test:
- Testing: "Alexa, ask My Home to turn on/off the lamp in the living room"
- Testing: "Alexa, ask My Home what is the temperature of the living room"
- Testing: "Alexa, ask My Home which is the setting of the air conditioning "
- Testing: "Alexa, ask My Home down the temperature of the air conditioning"
- Testing: "Alexa, ask My Home to turn the air conditioner on"
- Testing the Air Conditioner:
- Testing: "Alexa, ask My Home up the temperature of the air conditioning"
- Testing: "Alexa, ask My Home to turn the air conditioner off"
- Testing: "Alexa, ask My Home to feed Buddy"
Comments