Tutorial: Voice Time! Amazon Alexa and OurWeather – Part 2
We are pleased to announce Version 026 of the OurWeather software and the big change is that we now support the Amazon Alexa, Echo, Echo Plus, and all other Amazon Voice systems. In this series of tutorials we will show you how to connect up the Alexa systems in your house to your OurWeather station. We will be rolling this really cool feature set into our other major kit offerings including:
- – GroveWeatherPi – Raspberry Pi Based Weather Station Kit
- – SmartPlantPi – Raspberry Pi Based Plant Watering and Environmental Kit
- – The ThunderBoard Raspberry Pi IOT Lightning Detection Kit
This is a five part instructional tutorial to get your Amazon Alexa to OurWeather Interface working. All source code is provided!
While we are focusing on OurWeather in this series, the techniques we developed are good for many projects.
- - Part 1 - Voice Time! OurWeather and Amazon Alexa - Part 1
- - Part 2 - Setting up PubNub MQTT Broker
- - Part 3 - The Alexa Skill
- - Part 4 - The AWS Lambda Serverless Function
- - Part 5 - Setting OurWeather MQTT to Alexa up and System Tests
The Alexa Voice to OurWeather Project
There are four major parts to this project.
- – PubNub – MQTT Broker between OurWeather and the AWS Lambda function
- – The Alexa Skill – Controls Alexa on Echos in your house
- – The AWS Lambda Serverless Function for brokering information from PubNub to the Alexa Skill
- – OurWeather – MQTT Publisher Weather Information to PubNub
In part 2, we address PubNub.
Connecting to and setting up PubNub
See descriptions of MQTT and JSON in Part 1.
PubNub is an MQTT broker in the same sense as Mosquitto MQTT Broker is on a Raspberry Pi Platform.
PubNub is used to provide an MQTT connection from OurWeather to the Amazon Lambda function. We use the ESP8266 OurWeather processor to publish weather information to PubNub, which is then fetched by the Amazon Lambda function and relayed to the Alexa Skill. PubNub is free for the kind of usage we are going to be doing with OurWeather. A message every 5 minutes is nothing to the PubNub system.
Setting Up PubNub
Setup a free account at pubnub.com. Make sure you write down your password. Now let’s setup the MQTT info to connect up OurWeather.
Step 1) Create a new App by clicking on “NEW APP +”.. Type in SDL2Alexa in the “enter a new app” filed and hit the “CREATE NEW APP +” button. You should see this (except SunIOT will be SDL2Alexa):
Step 2) Click on the SDL2Alexa App page. The enter “OurWeather” in the “Enter a New Keyset Name” field and hit the “CREATE NEW KEYSET +” button. That will get you a page that looks like this. Note the keys below will not work. They have all been disabled. You need to set up your own. Copy and paste the Publish and Subscribe keys to your computer. You will need these in Part 3 and Part 4. If you don’t do that, don’t worry. You can always come back to this page.
Step 3) Scroll down on the page and turn “Storage & Playback” to On. If you don’t do this, nothing will work. Leave the retention on 1 day.
Now you are set up on Pubnub. Next we put together the Alexa Skill.
Coming Next
In Part 3, we get a developers account on Amazon, and set up the Alexa Skill.
In Part 4, we set up the Lambda function, setup OurWeather and tie it all together.