Announcing TinyGPS++
Today we’re happy to announce TinyGPS++, a completely new rethinking of TinyGPS, our popular Arduino NMEA (GPS) parsing library.
NMEA defines how most GPS receivers talk. When GPS is properly connected to a host controller like Arduino, it sends a never-ending stream of characters, grouped into human-readable clumps called “sentences”:
$GPRMC,045103.000,A,3014.1984,N,09749.2872,W,0.67,161.46,030913,,,A*7C $GPGGA,045104.000,3014.1985,N,09749.2873,W,1,09,1.2,211.6,M,-22.5,M,,0000*62
Obviously, when I say “human readable”, I mean only in the loosest sense. It takes a bit of skill and parsing savvy to identify the stream above as fix taken in a parking lot in Austin, Texas, USA on the evening of 2 September. That’s where TinyGPS and TinyGPS++ come in.
Both libraries help the Arduino programmer decode NMEA into readily usable position, date, time, speed, and course information–the basics of GPS. TinyGPS is a very resource-stingy library that has been on the scene for over four years now. TinyGPS++ has a larger footprint than its venerable sibling, but improves on it in two key ways:
Convenient new object model
As illustrated at the top of this page, TinyGPS++ gives your sketch instant access to a number of built-in GPS data points, using an intuitive and easy-to-use syntax. Want to know your altitude? That’s gps.altitude.value(). Latitude? Try gps.location.lat(). Speed in knots? That’s just gps.speed.knots().
TinyGPS extracts data from just two of the many NMEA-defined sentence types: $GPRMC and $GPGGA. TinyGPS++ does the same, but in the more convenient format.
Custom sentence extraction with TinyGPSCustom
But unlike its sibling, TinyGPS++ can also extract arbitrary data from any of the myriad other NMEA sentence types out there–even proprietary ones. Interested in how many GPS satellites are in view? Just create a TinyGPSCustom object that extracts the 3rd field (“11”) of the $GPGSV sentence:
$GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74
TinyGPSCustom sats(gps, "GPGSV", 3); ... Serial.println(sats.value());
Magnetic variation? That’s the 10th field of a $GPRMC sentence (020.3 degrees):
$GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68
TinyGPSCustom sats(gps, "GPRMC", 10); ... Serial.println(sats.value());
TinyGPS++ is in late pre-release now. Try it out. We could use the feedback.
April 1st, 2014 → 11:45 am
[…] http://arduiniana.org/2013/09/tinygps-a-new-view-of-global-positioning/ http://opencpn.org/ocpn/node/272 http://navigatrix.net/nxdoc/04_applications.html […]