Things used in this project

Schematics

Connecting GPS Breakboard with Raspberry Pi 3
Connect u-Blox NEO-6M GPS module board to Raspberry Pi 3 via UART. Connect TX pin from moudle to RPi RX pin (pin 10/GPIO 15) and RX pin on module to RPi TX pin (pin 08/GPIO 14). Connect 3.3 V RPi pin (pin 01) to VCC of the module board and also the ground to RPi (pin 06).
Raspi%20with%20gps

Code

MainPage.xaml.csC#
Example on how to use the library on your application
/* The MIT License (MIT)
 * MainPage.xaml.cs
 * Copyright (c) 2016 Gilang M. Hamidy (gilang.hamidy@gmail.com)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

using System;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Enumeration;
using Windows.Devices.SerialCommunication;
using Windows.Foundation;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Maps;



// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace Heliosky.IoT.GPS.SampleApp
{
  /// <summary>
  /// An empty page that can be used on its own or navigated to within a Frame.
  /// </summary>
  public sealed partial class MainPage : Page
  {
    private UBXSerialGPS gps;
    private MapIcon myLocation;
    private RandomAccessStreamReference mapIconStreamReference;

    public MainPage()
    {
      this.InitializeComponent();
      mapIconStreamReference = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/MapPin.png"));
    }

    private async void Page_Loaded(object sender, RoutedEventArgs e)
    {
      // Get serial device
      string aqs = SerialDevice.GetDeviceSelector();
      var dis = await DeviceInformation.FindAllAsync(aqs);

      // Create configuration object
      Configuration.Port cfg_prt = new Configuration.Port()
      {
        PortID = 1,
        StopBit = Configuration.Port.StopBitType.OneStop,
        Parity = Configuration.Port.ParityType.NoParity,
        CharacterLength = Configuration.Port.CharacterLengthType.Bit8,
        BaudRate = 115200,
        InputProtocol = Configuration.Port.Protocol.UBX,
        OutputProtocol = Configuration.Port.Protocol.UBX
      };
  
      // Instantiate UBXSerialGPS
      gps = new UBXSerialGPS(dis[0], cfg_prt);
              
      // Register event handler for periodic data
      gps.MessageReceived += Gps_MessageReceived;
      statusTextBox.Text = "GPS Started";
              
      // Start the GPS
      await gps.Start();
  
      // When the code reach here, the GPS is up and running
      statusTextBox.Text = "GPS init completed";
  
      // Configure GPS to send geoposition data periodically
      Configuration.Message cfg_msg = Configuration.Message.GetConfigurationForType<Navigation.GeodeticPosition>();
  
      // Write the config to GPS
      bool res = await gps.WriteConfigAsync(cfg_msg);
  
      if(res)
      {
        statusTextBox.Text = "Success configuring message";
        await Task.Delay(5000);
      }
      else
      {
        statusTextBox.Text = "Failed configuring message";
        await Task.Delay(5000);
      }
  
      statusTextBox.Text = "Polling message Monitor Receiver Status";
              
      // Poll a data of specified type from the GPS module
      Navigation.Clock resp = await gps.PollMessageAsync<Navigation.Clock>();
  
      if(resp != null)
      {
        statusTextBox.Text = "Poll message success: " + resp.TimeMillisOfWeek;
      }
      else
      {
        statusTextBox.Text = "Poll message failed";
      }
    }
  
    private void Gps_MessageReceived(object sender, MessageReceivedEventArgs e)
    {
      // Message is received, try to cast to our desired data
      Navigation.GeodeticPosition pos = e.ReceivedMessage as Navigation.GeodeticPosition;
  
      // If it is correct casting, process data
      if(pos != null)
      {
        statusTextBox.Text = "GPS Data Received at " + DateTime.Now.ToString();
  
        StringBuilder bldr = new StringBuilder();
        bldr.AppendLine("GPS Information");
        bldr.AppendLine("Latitude: " + pos.Latitude);
        bldr.AppendLine("Longitude: " + pos.Longitude);
        bldr.AppendLine("Time: " + pos.TimeMillisOfWeek);
        bldr.AppendLine("MSL: " + pos.HeightAboveSeaLevel);
  
        contentTextBox.Text = bldr.ToString();
  
        if(myLocation == null)
        {
          mapView.Center = new Windows.Devices.Geolocation.Geopoint(pos.GetGeoposition());
          mapView.ZoomLevel = 18;
  
          myLocation = new MapIcon();
          myLocation.Location = mapView.Center;
          myLocation.NormalizedAnchorPoint = new Point(0.5, 1.0);
          myLocation.Image = mapIconStreamReference;
          myLocation.ZIndex = 0;
          mapView.MapElements.Add(myLocation);
        }
        else
        {
          myLocation.Location = new Windows.Devices.Geolocation.Geopoint(pos.GetGeoposition());
        }
      }
    }
  }
}
Heliosky.IoT.GPS Library Project
The GPS library project which also includes sample application to showcase how to use the library. The library itself is licensed under GNU Lesser General Public License.

Credits

Photo
Gilang Mentari Hamidy

Just another geek playing around

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Chicken Coop Livestream
Easy
  • 2,711
  • 10

Full instructions

We have two chickens, and their coop is located at the back of the garden. I decided to build a Pi-based streaming device to check on them.

Test Your Internet Speed Using a Raspberry Pi + Ubidots
Easy
  • 371
  • 5

Protip

Use your Raspberry Pi to measure any internet connection speed with Ubidots.

Raspberry Pi Shutdown / Restart Button
Easy
  • 5,306
  • 20

Full instructions

Building an installation project? Shut down or reboot your project safely, without a keyboard or SSH!

DIY Raspberry Pi Indoor Outdoor Webcam
Easy
  • 1,560
  • 6

Full instructions

Ever want to monitor your home but don't want to buy a $100 1080p webcam? Well I did, and you can too!

3D Printed Case for a RaspPi 3, an Arduino and a 5" Display
Easy
  • 332
  • 4

Full instructions

A simple and compact frame to mount a 5" monitor, a Raspberry Pi, an Arduino, and a battery, which is extensible for other sensors.

Single Device to Control Many Arduinos with NRF24L01+ Sensor
Easy
  • 1,489
  • 8

Turns your fan on and off by sensing the temperature.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog