The "Internet of things" (IoT) is becoming an increasingly growing topic of attention. The concept basically consist of connecting any physical device to the Internet and exchange information.
Issue to solveMy 9 year youngest son has a little plant and he takes care of it all the time. Whenever we are not at home for some days he worries about his plant, so we have to plan our weekends, holidays and of course we cannot take the plant wherever we go, so why don't ask Alexa to help him to water his plant? no matter where we are.
Here are the necessary steps to complete the project:First of all this is the system diagram
1. Arduino IDE and libraries.
2. AWS Amazon (free account).
3. Amazon Developer Services (free account).
4. IO.Adafruit (free account).
5. Ifttt (free account) extra step.
Lets go and start installing and creating the solution.
1. Download and Install Arduino IDE and libraries (open source).If you don’t have Arduino IDE installed on your computer, download it from official site:
https://www.arduino.cc/en/Main/Software
Choose according to your OS and install it.
In order to program the ESP8266 from Arduino IDE you have to install additional components:
Open Arduino IDE go to File > Preferences and enter the following URL into the Additional Boards Manager URLS
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Click OK.
Now go to Tools > Boards > Boards Manager and install the ESP8288 package.
Now you need to install Arduino library for MQTT support, go to https://github.com/adafruit/Adafruit_MQTT_Library and download it in zip file to your computer.
Now in Arduino IDE, go to Sketch > Include Library > Add .ZIP Library...
Now you are able to program ESP8266 using Arduino IDE and communicate with io.adafruit using MQTT.
2. Create a free account in AWS AmazonGo to the following URL https://aws.amazon.com/
Go to https://developer.amazon.com/
Go to https://io.adafruit.com/
This is not needed, but I recommend to do it. Go to https://ifttt.com/ and create a free account.
Now we have all software and accounts needed!
Building the solutionIn order to be able to Turn On/Off a device using Alexa we need to:
1.Programming ESP8266Lets start programming the ESP8266, connect it to Arduino.
How to wire ESP8266 and Arduino?
In order to be able to program the ESP8266 you have to wire both devices, follow the instructions:
ESP8266 wires to breadboard:
RX, VCC, GPIO0, RST, CH_PD, GND and TX
Use jump wires between VCC and CHPD and between GPIO0 and GND (see below diagram).
Arduino to ESP8266
3.3V to VCC
GND to GND
TX to TX
RX to RX
The full code for the ESP8266 is available in the project, you have to change the following according to your information. Remember this is a prototype, it's not recommended to hardecoded user/password in production environments.
Go to Arduino IDE, make sure to select Tools > Board > Generic ESP8266 Module
and select the COM port used by Arduino in your computer.
Upload the code to ESP8266 and wait, it may take a while.
2. Create Feeds in io.adafruitFeeds are the core of the Adafruit IO system. The feed holds metadata about the data you push to Adafruit IO.
Go to Feeds
Create a New Feed.
Give it a Name, for my case I used OnOff and select Create.
Once created you can monitor values in real time.
This step is optional, the System diagram for this solution is the following:
Alexa supports IFTTT, or "IF This, Then That," a third-party service that automates how your devices, apps, and websites work with each other through rules (or "Applets"). After you activate an Applet through the IFTTT website, Alexa can then trigger that IFTTT Applet when you interact with your Alexa device.
Go to My Applets > New Applet
Click on +
Choose a service > Amazon Alexa
Choose trigger > Say a specific phrase
What Phrase? my switch turn on, create a specific phrase for turn on and another for turn off.
Click on +
Choose action service > Adafruit
For turn on select the feed OnOff created in the previous step and set 1 to Data to save and click on Create action.
Repeat steps for turn off, (step 2 of 6) type my switch turn off and (step 5 of 6) set 0 for Data to save.
Test Alexa and ESP8266 using IFTTT.For testing purposes if you decide to follow instructions on step 3 and create the Applet:
-disconnect wires from Arduino to ESP8266,
-connect jump wire from GPIO02 to breadboard,
-connect the longer leg (anode pin) of LED to GPIO2
-connect the shorter leg (cathode pin) to GND in the breadboard .
The way to invoke Alexa is adding the word trigger:
Time to test
4. Create Lambda functionYou can use AWS Lambda to execute code in response to triggers such as changes in data, shifts in system state, or actions by users. Lambda can be directly triggered by AWS services.
You are going to be working steps 4 and 5 at the same time.
Go to https://aws.amazon.com/console/ and select Lambda
Select Create function.
An excellent starting point to begin learning is Blueprints.
Select alexa-skills-kit-color-expert-python
Type a name for your function and chose lambda_basic_execution for Existing role*
Here recommended is to keep the default option (Enable) but before continue we have to create an alexa-skills-kit and get the Skill ID. You have to go for a moment to step 5 and come back.
After you got you Skill ID (in step 5), continue your Lambda function.
Go to the end of the page and select Create function.
You have successfully created a Lambda function!.
Important: make changes in the Lamda function according to your information in io.adafruit.
go to Alexa in the menu options and select Add a New Skill.
Type a Name and Invocation Name, and click on Save button at the end of the page.
Once you click on Save you have the skill ID, that's the one we are going to use for our lambda function we are creating in step 4.
Go back to the AWS Amazon console and fill theSkill ID information.
For the Interaction Model create it like this:
Sample Utterances.
Configuration > Default you have the (Amazon Resource Name).
This is the diagram of the final project.
Yes I know! what about the water pump? well until now this project contains basically all components of the system diagram, but I don't have the water pump yet!. so in theory I just have to exchange the LED for the water pump when it arrives.
Comments