Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Adafruit Netduino GPS shield

GPS C# data

  • Please log in to reply
4 replies to this topic

#1 miltonkbenjamin

miltonkbenjamin

    Member

  • Members
  • PipPip
  • 22 posts

Posted 20 December 2013 - 04:23 PM

All,

 

Where can I get the C# class for accessing the GPS data (lat, lon, elev?) from an Adafruit Netduino GPS shield?

 

Thanks,

 

Milt



#2 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 23 December 2013 - 04:48 AM

Hi,

 

Have a look at the NetMF Toolbox GPS driver I have used it for a couple of projects

 

netmftoolbox.codeplex.com

 

Bryn



#3 miltonkbenjamin

miltonkbenjamin

    Member

  • Members
  • PipPip
  • 22 posts

Posted 23 December 2013 - 09:41 PM

Bryn,

 

I copied the code into a MicroFramework  Microsoft C# 2010 project, see below, and it complained that namespace NmeaGps was not found.

Any Ideas?

 

Thanks,

Milt

 

"using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace NetduinoApplication1 {   public class Program {   public static NmeaGps Gps = new NmeaGps();   public static OutputPort Led = new OutputPort(Pins.ONBOARD_LED, false);   // ***********************************************************************   public static void Main() {   // Binds all events to the GPS device   Gps.GotFix += new NativeEventHandler(Gps_GotFix);   Gps.LostFix += new NativeEventHandler(Gps_LostFix);   Gps.PositionChanged += new NativeEventHandler(Gps_PositionChanged);   // Starts the GPS device   Debug.Print("Trying to get a fix...");   Gps.Start();   // Nice blinking LED effect when we have a fix   while (true) {   Led.Write(Gps.Fix);   Thread.Sleep(450);   Led.Write(!Gps.Fix);   Thread.Sleep(50);   }   }   // ***********************************************************************   static void Gps_PositionChanged(uint Unused, uint FixType, DateTime GPSTime)   {   string Outp = "";   Outp += "3D-Fix: " + Gps.Fix3D.ToString();   Outp += ", Sattellites: " + Gps.Satellites.ToString();   Outp += ", Time: " + Gps.GPSTime.ToString();   Outp += ", Latitude: " + Gps.SLatitude;   Outp += ", Longitude: " + Gps.SLongitude;   Outp += ", Altitude: " + Gps.SAltitude;   Outp += ", Knots: " + Gps.Knots.ToString() + " (" + Gps.Kmh.ToString() + " km/h)";   Debug.Print(Outp);   // If you want to translate this to a Bing Maps URL, try this:   Debug.Print("http://www.bing.com/maps/?q=" + Tools.RawUrlEncode(Gps.Latitude.ToString() + " " + Gps.Longitude.ToString()));   }   // ***********************************************************************   static void Gps_GotFix(uint Unused, uint FixType, DateTime GPSTime) {   Debug.Print("We got a fix, yay!!");   }   // ***********************************************************************   static void Gps_LostFix(uint Unused, uint FixType, DateTime GPSTime) {   Debug.Print("We lost our GPS fix :(");   }   // ***********************************************************************   } } "



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 December 2013 - 02:27 AM

Hi Milt, The NmeaGps class in that toolbox is located inside a namespace, so you'll need a "using" statement at the top of your code so that Visual Studio knows which class you're using in your code. Chris

#5 wendo

wendo

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts

Posted 25 December 2013 - 09:33 AM

Specifically you'll need these two

 

using Toolbox.NETMF;using Toolbox.NETMF.Hardware;

You'll likely also want to add to the 

public static NmeaGps Gps = new NmeaGps();

to add a com port and speed, something like the below

public static NmeaGps Gps = new NmeaGps("COM1", 9600);

Also be aware, the first power up of a GPS can take a LONG time to start returning data (5 mins is common) and unless it has a battery on it it will take that amount of time every time it's powered up. If it does have a battery, and has been powered up recently it should be much faster






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.