This project is about surfacing information from a Raspberry Pi through an Microsoft Azure infrastructure to an Amazon Alexa Skill. This could be an architecture that would support telemetry data collection over time by automating the collection, transport and storage of data from a Raspberry Pi. Maybe the most obvious example of a system like this would be a weather station that cyclically collects data from sensors.
Goals and Intentions- Use Windows 10 IoT Core on Raspberry Pi 3 to produce data.
- Use Visual Studio and C# for all coding.
- Use Microsoft Azure PaaS Infrastructure.
- Surface information through Amazon Alexa Skill.
This project contains many detailed steps which will not be completely outlined step-by-step in this story. I will try to pull together all the resources necessary to replicate the project and point out details that took me hours to track down solutions.
The order in which to execute these steps can vary. You can perform the steps in any order which interests you or meets your goals. I can provide the sequence of steps that I went through to complete the project.
- Setup Amazon Echo (Dot/Tap whatever) and practice using the built in features, admin website/app, and skills available in the Amazon store.
- Setup Raspberry Pi with Windows 10 IoT Core and install the Windows 10 IoT Core Dashboard on your computer. Connect your Raspberry Pi to your WiFi network and setup administration of the Pi using the Dashboard.
- Learn how to build Windows IoT Core Background Application and deploy it to the Raspberry Pi and execute.
- Learn how to build a simple Amazon Alexa Skill and deploy the skill to an Azure Api App.
- Publish the Alexa Skill to Amazon Developer Portal then test it to ensure it is working.
- Setup the Azure IoT Hub, Azure functions and DocumentDB database.
- Change the Alexa Skill to pull information from DocumentDB database.
- Change the Windows IoT Core Background Application to simulate (or use sensors to pull) data and push messages to the IoT Hub.
- Write the Azure Function to receive IoT Hub messages and write documents to DocumentDB database for Alexa Skill consumption.
- Change Alexa Skill to query DocumentDB and respond to utterances related to the data you are collecting with your Raspberry Pi.
You will need to setup your Amazon Echo going through the Setup Instructions provided by Amazon. The Amazon Echo Support page has links to many other support documents describing how to use and troubleshoot your device.
Setup Raspberry PiInstall the Windows 10 IoT Core on your Raspberry Pi.
https://developer.microsoft.com/en-us/windows/iot/GetStarted
Install Windows 10 IoT Core Dashboard
https://developer.microsoft.com/en-us/windows/iot/Downloads
Setup and get familiar with Managing a Windows IoT device using the IoT Dashboard and Device Portal apps.
https://developer.microsoft.com/en-us/windows/iot/docs/iotdashboard
Build Windows IoT Core > Background Application (IoT)
Here is a sample IoT background application for generating a random number, build a IoT message and sending the message to the IoT Hub. You can comment out the IoT code until we get to that step below. The sample solution also contains a sample IoT client console application to view the IoT messages as they are sent by the Raspberry Pi. More on this once we get the IoT Hub created.
Deploy your background application to the Raspberry Pi
https://developer.microsoft.com/en-us/windows/iot/docs/appdeployment
Build the Amazon Alexa Skill Visual Studio SolutionUse Visual Studio to create a ASP.NET Web API Project hosted in Azure App Service. Of course you will need an Azure account if you don't already have one.
Use NuGET Manager to Update the Api project to the latest versions.
It doesn't make sense to list the versions I see as that will continuously change. I simply updated the project to the latest versions and resolved any conflicts until I had an updated and stable build.
Use NuGET Manager to install project dependencies
AlexaSkillsKit.NET and Microsoft.Azure.DocumentDB are the two NuGet packages that need to be installed.
https://github.com/AreYouFreeBusy/AlexaSkillsKit.NET.git
Create an AlexaController, DocumentDbClient, a model class to represent your data, Alexa Speechlet Class and Supporting files as seen in the following screenshot.
You can go to the repository and see the contents of these files. Build the project once you have all the code arranged.
Publish the Amazon Alexa Skill to Azure Api App Service
Setup the Alexa Skill in Amazon Developer Portal
Build the Azure InfrastructureCreate the Azure IoT Hub
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-create-through-portal
Connect Raspberry Pi to Azure IoT Hub
https://developer.microsoft.com/en-us/windows/iot/docs
Create the Azure Function to process the Azure IoT Hub
- Understand how Azure Function bindings work and configure the bindings
- Construct the event hub connection string for IoT Hub and update the Azure Function app settings with connection string.
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messaging
Run and Test the SampleDeploy and Test the Raspberry Pi Connection to IoT Hub
Publish and test the Alexa Speechlet
Comments
Please log in or sign up to comment.