003a – Raspberry Pi 3B with GPS Module and Azure IoT Hub

Introduction

This tutorial is a supplementary tutorial to 003 – How to Stream Device Data to Azure IoT Hub. If you've been following along then you know that we have been setting up two devices at the same time. Both of these devices have their own set of sensors and their own code base. This tutorial will explain the code base used by the Raspberry Pi 3B with the GPS module attached to it. We started off as one tutorial because it concerns one IoT Hub which we'll be streaming our data into from both of our devices.

003a-raspberry-pi-3b-with-gps-module-and-azure-iot-hub

Getting started

By this point our blank UWP application that we have been enabling with numerous exciting features is almost ready to employ some programming logic. There is this thing in UWP called Capabilities. This feature is pretty awesome but very easily overlooked. Let's provide our UWP application some Serial Communication Capability. Right click your Package.appmanifest file from the solution explorer and select ‘View Code'. At the end of the file, within the Package tag, add this code snippet:

Now our UWP application is ready to roll.

In the code section of this tutorial we've attached code for a working example application. The code is very well commented and we hope it will be easy for you to embed it into your own application. We also recommend that you check out our other tutorial on How to setup GPS module and collect GPS data in Windows IoT.

If you looked into that tutorial you should now have a good grasp of how the data was collected from the GPS module using a serial port. So in this tutorial all we have to do is somehow package the GPSData into JSON and stream it to Azure IoT Hub via HTTP1.

Our Application

Please note that we have employed a DispatcherTimer into our application because we wanted to limit our IoT Hub bandwidth. As you might have seen in the code, our timer ticks every 30 seconds. This way we send 2880 messages from one device in 24 hours. In total, we send about 5760 messages to our IoT Hub. As you know, with our developer benefits we are allowed to send only 8000 messages per day. This is the reason that even this 30 second beat feels pretty fast when the whole system is operational.

The finished application has a visual interface like this:

Read More:  003a – Raspberry Pi 3B with GPS Module and Azure IoT Hub


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top