To get started, download the GPSDemo solution from github and save it in your favorite Windows IoT project folder.

On the github page, you'll see a green button labeled 'Clone or Download'.  Click that and select 'Download Zip'.  Extract the downloaded zip file to your projects folder.

Now, open the GPSDemoApp solution file in Visual Studio (you'll need to use VS 2015 or later).

GPSDemoApp is a Headed application. That means it has a user interface (Headless applications run in the background and don't have a user interface).

Our user interface is very simple, but it shows important updates from the GPS in real-time:

When Visual Studio comes up with the GPSDemoApp solution, you'll see MainPage.xaml in Solution Explorer. This is the user interface designer file. If you click on the line that says MainPage.xaml, MainPage.xaml.cs will drop down.  This is the C# code that goes with the user interface, and this is where the GPSDemoApp code lives.

In MainPage.xaml, we've requested a Page_Loaded event to occur when the GUI has been fully initialized.  We'll use the Page_Loaded event to create a new GPS object.  We'll also set up a couple of events that will notify us when a new GPS NMEA sentence has been received. Finally, we'll call StartGPS to begin reading NMEA sentences from the GPS HAT.

StartGPS is an asynchronous task in MainPage.xaml.cs.  We don't want to block the main UI thread (where Page_Loaded was called from), so we'll do our GPS inisialization from a separate task.

First thing is to call the GPS library function ConnectToUart.  The GPS Hat communicates with the Pi over the Pi's serial port.  So, we need to attach and open that port to talk to the GPS.

Once the serial port is connected, we tell the GOS which NMEA sentences we're interested in receiving, and how often we'd like those sentences to be updated. For these operations, we call the librry functions SetSentencesReporting and SetUpdateFrequency.

Finally, we start yet another asynchronous task.  This is the task that reads the GPS and parses the NMEA sentences for us. the startReading function takes care of that for us.

At this point, the GPS Library is reading and parsing sentences from the Hat.  But we want to be notified when a new sentence comes in.  That's what the events are for.  

Each event is given a data structure that contains all the data parsed from the sentence. The GPS library will fire an event with each sentence received, complete with the latest data.

We set up event functions to capture those events and display the parsed GPS data on our GUI.

There's one other thing we need to do, and that's to add a reference to the AdafruitClassLibrary.  This is a special library package containing Windows IoT Core driver software for a variety of Adafruit products.

The Adafruit Class Library contains the GPS class that we've been using here in the demo app. The GPS class takes care of reading and parsing sentence data from the GPS, and is responsible for firing the events that provide the app with sentence information.

Details on installing the Adafruit Class Library are on the next page. For details on the GPS class itself, see the Adafruit Class Library documentation.

But wait .. there's still one other thing.  The GPS Hat uses Serial communications. We have to configure the app for serial capability. This is done in the Package.appxmanifest file.  You can open the package manifest editor by double-clicking on the file in Solution Explorer. You can set all sorts of capabilities for the app in the editor.

One thing you can't set in the editor is the serial capability. For that, we have to use a regular text editor.  Right-click on Package.appxmanifest in Solution Explorer and select 'Open With...'.  In the popup list, select 'Source Code (Text) Editor'. The editor will open with the raw XML contents of the package manifest. Look for this section near the bottom:

Download: file
    <Capability Name="internetClient" />

We need to add our serial capability to this <Capabilities> block. Edit the block so that it looks like this:

Download: file
    <Capability Name="internetClient" />
    <DeviceCapability Name="serialcommunication">
      <Device Id="any">
        <Function Type="name:serialPort" />
This guide was first published on Nov 22, 2016. It was last updated on Nov 22, 2016. This page (GPSDemoApp) was last updated on Nov 12, 2019.