In this post we will discuss Garage Door powered by Win10, AllJoyn and Raspberry Pi: Operate ad get statistics about your garage door using a Raspberry Pi with Win 10 IoT.
In my opinion two of the biggest features that Windows 10 has going for it is: Win 10 IoT Core and Alljoyn. As a long time .Net developer and a hardware geek I can combine my two favorite hobbies to build really cool connected things. If you haven't looked at Alljoyn yet then head on over to https://allseenalliance.org/ and read about why this communication framework can provide the backbone of your connected devices.
In this project I used the Alljoyn framework to connect two Universal Windows applications to get the current status of my garage door as well as open or close it. In addition to controlling the door I wanted to be able to measure the temperature of the garage.
There are many other projects like this but one of the things I wanted to do is measure how long in time (milliseconds) it is taking to open or close the door. I want to be able to use this information to determine if the door is in need of maintenance.
Garage Door powered by Win10, AllJoyn and Raspberry Pi: High Level Design
The design consists of a Raspberry Pi 2 that resides in the Garage of my Home connected over wifi. The Raspberry Pi is running Windows 10 IoT Core. There is also a temperature sensor connected to the Raspberry Pi via an Analog to Digital Converter over SPI. A Universal Windows Application runs on this Raspberry PI. The goal is not to have a UI on this device as it exposes it's capabilities over the Alljoyn framework.
A second Universal Windows Application is used to control the garage door as well as display the current temperature of the garage.
The following diagram shows the overall vision which includes some future capabilities.
If you are like me and you want to just get right down to looking at the code head on over to my Github Repository for this project. I have created 2 solutions: GarageDoorDevice and GarageDoorConsumer. The GarageDoorDevice solution targets the Raspberry PI.
The GarageDoorConsumer is a Universal Windows app that is designed to remotely connect to the device. If you have Visual Studio 2015 you should be able to clone the Github repository and open up the solutions, compile the code and run it. You can skip all the way down to the Wiring up the Simulated Hardware step.
Step 1 – Define the Communications
First you need to establish what the interface is between the device and the application that will be controlling and monitoring the device. With the Alljoyn framework this is done by building the Introspection XML document. There is a great article on Channel 9 that provides some awesome detail on authoring the Introspection xml. Since my device consists of a way to control the garage door as well as measuring the temperature of the garage it was real apparent to me that I needed two interfaces.
Check out the full Garage Door Introspection XML on my Github repository. There are methods defined in the XML for opening and closing the door. There are events (or signals) defined so that other applications can get notifications about the state of the garage door changing.
Check out the full Temperature Introspection XML on my Github repository. This interface definition is a lot simpler since all it really does is allow someone to subscribe to the temperature changing.