This a supplemental tutorial to our 003 tutorial. In this tutorial we're going to finish developing a UWP Application to collect the sensor data from FezHat, convert the data into JSON, and upload the payload into the Azure IoT Hub via HTTP1.
In our 003 tutorial we've been setting up two devices at the same time, each of which has its own set of sensors and its own code base. In this tutorial we'll be going over the code base used for the Raspberry Pi 2B with a FezHat connected to it.
If you're continuing from our 003 tutorial then you already have a fully functional blank UWP app loaded into your Visual Studio. If you don't, now's the time to set that up. Now, to make use of the FezHat and its sensors, we need to install a NuGet package from GHI Electronics into this application. Just search for FezHat in the NuGet manager window and install. Also, you're going to want to install the Microsoft.Azure.Devices.Client and Newtonsoft.Json NuGet packages into your applications if you haven't already. After all the packages are installed, your NuGet package manager's installed section should look like this:
After installing these NuGet packages you'll be able to import the GHIElectronics.UWP.Shields namespace. Through the classes contained in this namespace you can access the sensors and read their value. Very convenient indeed.
Implementing the programming logic
At this point your UWP application is ready to implement the programming logic provided by us in our fully functional sample code. In the code section of this tutorial we have attached code files for you to reference and for you to embed into your app.