TinyGPS

A Compact Arduino GPS/NMEA Parser

TinyGPS is designed to provide most of the NMEA GPS functionality I imagine an Arduino user would want – position, date, time, altitude, speed and course – without the large size that seems to accompany similar bodies of code.  To keep resource consumption low, the library avoids any mandatory floating point dependency and ignores all but a few key GPS fields.

Usage

To use, simply create an instance of an object like this:

#include "TinyGPS.h"
TinyGPS gps;

Feed the object serial NMEA data one character at a time using the encode() method. (TinyGPS does not handle retrieving serial data from a GPS unit.) When encode() returns “true”, a valid sentence has just changed the TinyGPS object’s internal state. For example:

#define RXPIN 3
#define TXPIN 2
SoftwareSerial nss(RXPIN, TXPIN);
void loop()
{
  while (nss.available())
  {
    int c = nss.read();
    if (gps.encode(c))
    {
      // process new gps info here
    }
  }
}

You can then query the object to get various tidbits of data. To test whether the data returned is stale, examine the (optional) parameter “fix_age” which returns the number of milliseconds since the data was encoded.

long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;

// retrieves +/- lat/long in 100000ths of a degree
gps.get_position(&lat, &lon, &fix_age);

// time in hhmmsscc, date in ddmmyy
gps.get_datetime(&date, &time, &fix_age);

// returns speed in 100ths of a knot
speed = gps.speed();

// course in 100ths of a degree
course = gps.course();

Statistics

The stats method provides a clue whether you are getting good data or not. It provides statistics that help with troubleshooting.

// statistics
gps.stats(&chars, &sentences, &failed_checksum);
  • chars – the number of characters fed to the object
  • sentences – the number of valid $GPGGA and $GPRMC sentences processed
  • failed_checksum – the number of sentences that failed the checksum test

Integral values

Values returned by the core TinyGPS methods are integral. Angular latitude and longitude measurements, for example, are provided in units of millionths of a degree, so instead of 90°30’00″, get_position() returns a longitude value of 90,500,000, or 90.5 degrees. But…

Using Floating Point

…for applications which are not resource constrained, it may be more convenient to use floating-point numbers. For these, TinyGPS offers several inline functions that return more easily-managed data. Don’t use these unless you can afford to link the floating-point libraries. Doing so may add 2000 or more bytes to the size of your application.

float flat, flon;

// returns +/- latitude/longitude in degrees
gps.f_get_position(&flat, &flon, &fix_age);
float falt = gps.f_altitude(); // +/- altitude in meters
float fc = gps.f_course(); // course in degrees
float fk = gps.f_speed_knots(); // speed in knots
float fmph = gps.f_speed_mph(); // speed in miles/hr
float fmps = gps.f_speed_mps(); // speed in m/sec
float fkmph = gps.f_speed_kmph(); // speed in km/hr

Date/time cracking

For more convenient access to date/time use this:

int year;
byte month, day, hour, minutes, second, hundredths;
unsigned long fix_age;

gps.crack_datetime(&year, &month, &day,
  &hour, &minute, &second, &hundredths, &fix_age);

Establishing a fix

TinyGPS objects depend on an external source, i.e. its host program, to feed valid and up-to-date NMEA GPS data. This is the only way to make sure that TinyGPS’s notion of the “fix” is current. Three things must happen to get valid position and time/date:

  1. You must feed the object serial NMEA data.
  2. The NMEA sentences must pass the checksum test.
  3. The NMEA sentences must report valid data. If the $GPRMC sentence reports a validity of “V” (void) instead of “A” (active), or if the $GPGGA sentence reports fix type “0″ (no fix) then those sentences are discarded.

To test whether the TinyGPS object contains valid fix data, pass the address of an unsigned long variable for the “fix_age” parameter in the methods that support it. If the returned value is TinyGPS::GPS_INVALID_AGE, then you know the object has never received a valid fix. If not, then fix_age is the number of milliseconds since the last valid fix. If you are “feeding” the object regularly, fix_age should probably never get much over 1000. If fix_age starts getting large, that may be a sign that you once had a fix, but have lost it.

float flat, flon;
unsigned long fix_age; // returns +- latitude/longitude in degrees
gps.f_get_position(&flat, &flon, &fix_age);
if (fix_age == TinyGPS::GPS_INVALID_AGE)
  Serial.println("No fix detected");
else if (fix_age > 5000)
  Serial.println("Warning: possible stale data!");
else
  Serial.println("Data is current.");

Interfacing with Serial GPS

To get valid and timely GPS fixes, you must provide a reliable NMEA sentence feed. If your NMEA data is coming from a serial GPS unit, connect it to Arduino’s hardware serial port, or, if using a “soft” serial port, make sure that you are using a reliable SoftSerial library. As of this writing (Arduino 0013), the SoftwareSerial library provided with the IDE is inadequate. It’s best to use my NewSoftSerial library, which builds upon the fine work ladyada did with the AFSoftSerial library.

Library Version

You can retrieve the version of the TinyGPS library by calling the static member library_version().

int ver = TinyGPS::library_version();

Resource Consumption

Linking the TinyGPS library to your application adds approximately 2500 bytes to its size, unless you are invoking any of the f_* methods. These require the floating point libraries, which might add another 600+ bytes.

Download

The latest version of TinyGPS is available here: TinyGPS13.zip

Change Log

  1. initial version
  2. << streaming, supports $GPGGA for altitude, floating point inline functions
  3. also extract lat/long/time from $GPGGA for compatibility with devices with no $GPRMC
  4. bug fixes
  5. API re-org, attach separate fix_age’s to date/time and position.
  6. Prefer encode() over operator<<. Encode() returns boolean indicating whether TinyGPS object has changed state.
  7. Changed examples to use NewSoftSerial in lieu of AFSoftSerial; rearranged the distribution package.
  8. Greater precision in latitude and longitude.  Angles measured in 10-5 degrees instead of 10-4 as previously.  Some constants redefined.
  9. Minor bug fix release: the fix_age parameter of get_datetime() was not being set correctly.
  10. Added Maarten Lamers’ distance_to() as a static function.
  11. Arduino 1.0 compatibility
  12. Added satellites(), hdop(), course_to(), and cardinal()
  13. Improved precision in latitude and longitude rendering. get_position() now returns angles in millionths of a degree.

Acknowledgements

Many thanks to Arduino forum users mem and Brad Burleson for outstanding help in alpha testing this code. Thanks also to Maarten Lamers, who wrote the wiring library that originally gave me the idea of how to organize TinyGPS.  Thanks also to Dan P. for suggesting that I increase the lat/long precision in version 8.  Thanks to many people who suggested new useful features for TinyGPS, especially Matt Monson, who wrote some nice sample code to do so.

All input is appreciated.

Mikal Hart

Page last updated on August 31, 2013 at 7:00 pm
701 Responses → “TinyGPS”

  1. Jack

    10 years ago

    Hi Mikal. I’m using a GPS simulator that outputs GGA strings. The fix in the GGA sentence is 1. But gps.encode just returns 0… Do i nid RMC strings for it to work too? All i wanted was to retrieve the lat/lon frm the GGA.


  2. Mikal

    10 years ago

    @Christian,

    1. gps.satellites();
    2. Latitudes greater than 0 are north of the equator.
    3. If you are concerned about signal quality, check the “horizontal dilution of precision”: gps.hdop();


  3. Mikal

    10 years ago

    @Geoff,

    Sure:

    Serial.print(lat / 100000);
    Serial.print(".");
    Serial.print(lat % 100000);
    
    // This won't work quite right when lat % 100000 begins with 0
    // but you can figure it out... :)
    

  4. Mikal

    10 years ago

    @Albarra,

    The best way to diagnose a problem like this is to print out the raw stream you are getting from the GPS module. Print out each character with Serial.write() before you send it to gps.encode();


  5. Mikal

    10 years ago

    @mike, I haven’t tried TinyGPS on the Raspberry Pi, but I would expect it to almost work as is–except for the small dependency on the Arduino millis() function to measure time. If you substitute the equivalent on a different OS, I think it would be easy to port.


  6. Mikal

    10 years ago

    @Alexander,

    encode() returns true when the final character of a valid sentence is processed. That means the sentence passed the checksum test and, if GPRMC, that it contained valid data.


  7. Mikal

    10 years ago

    @Jack,

    Can you possibly post the GGA sentence? gps.encode only returns true when it reaches the CR or LF at the end of sentence.


  8. Jack

    10 years ago

    Thnx for the reply Mikal. Here u go.

    $GPGGA,090000.00,0117.81300741,N,10348.09117993,E,1,05,2.87,160.00,M,-21.3213,M,,*7B
    $GPGGA,090000.05,0117.81300741,N,10348.09117993,E,1,05,2.87,160.00,M,-21.3213,M,,*7E
    $GPGGA,090000.10,0117.81300741,N,10348.09117993,E,1,05,2.87,160.00,M,-21.3213,M,,*7A
    $GPGGA,090000.15,0117.81300741,N,10348.09117993,E,1,05,2.87,160.00,M,-21.3213,M,,*7F
    $GPGGA,090000.20,0117.81300741,N,10348.09117993,E,1,05,2.87,160.00,M,-21.3213,M,,*79
    $GPGGA,090000.25,0117.81300741,N,10348.09117993,E,1,05,2.87,160.00,M,-21.3213,M,,*7C
    $GPGGA,090000.30,0117.81300741,N,10348.09117993,E,1,05,2.87,160.00,M,-21.3213,M,,*78

    I’ve pasted the first 2 lines above into the GGA string in the static test. Checksum seems fine and flat/flon was returned quite accurately. Hw’d i knw if there’s CR or LF at the end of each sentence? Thnx again!


  9. Mikal

    10 years ago

    @Jack, I was able to easily generate valid lat/long data using (just) your GPGGA strings. If your encode() is NEVER returning “true”, then your simulator must not be generating the CR or LF that is supposed to terminate these strings. How are you getting them from the simulator? As a workaround, if you know that you’ve reached the end of a sentence, you could simply add the line:

    bool success = gps.encode(‘\r’);

    That should return “true”.


  10. Jack

    10 years ago

    i’m usin a copy of Free SatGen NMEA software from: http://www.labsat.co.uk
    output frm the software is then passed thru a FTDI breakout board to the arduino.

    so i’m supposed to add the line “bool success = gps.encode(‘\r’);” into the data simulated?

    THANKS for the help!!


  11. king_zul97

    10 years ago

    why my arduino ide uno cannot receive any data from gps when serialmonitor . but i can get data when using mini gps . ?


  12. Victor

    10 years ago

    Hi, am using a GPS shield with the arduino uno. I uploaded the code above but all I get is strange characters in my serial monitor. what could be the reason?


  13. Mikal

    10 years ago

    @Victor, Perhaps a baud rate mismatch between the sketch and the monitor?


  14. M00se

    10 years ago

    Hi ,
    I am using this with the mediatek v12 from diydrones.
    I have managed to get the baud and pins right and I am getting data in serial when running, test_with_gps_device.
    My problem is that I am getting a checksum fail on every new line of data,

    this is a typical line from the serial
    5 138 42.89535 -8.52799 873 00/00/2000 19:26:23 879 315.80 ****** ***** *** 1147 30.51 NNE 4568 31 32

    I am inside with poor coverage, but this doesnt change when outside, I also have no date returned, although the time is correct.

    Do you have any idea what is going on ?
    thanks for the ace library


  15. Mikal

    10 years ago

    @M00se,

    Just a clarification that it doesn’t matter how good or poor your fix or signal is. Even if you can see NO satellites, the GPS module should continue to send sentences with valid checksums. They may not contain a lot of useful data, but they will be correctly formatted.

    Now, about those checksums, my best guess is either (a) that you are doing something to slow down the processing of the NMEA stream, (b) the baud rate is too high for SoftwareSerial to process reliably (>= 38.4K), or perhaps the sentence rate is too high to process. Have you modified the sample code in any way? What is the baud rate? How many sentences per second is it sending anyway?

    It looks like about half of the sentences are getting through (31 “good” and 32 “failed checksum”).


  16. Josh

    10 years ago

    Hey Mikal, I really love your library! I have a question about it, however. It usually takes about 1 second to actually encode the data coming from the GPS. This is, unfortunately, much too long for my needs. I need to be able to receive at least 5 GPS points per second, preferably more. The code I’m using is simple enough, so I’m not really sure where it’s hanging up. Any help would be greatly appreciated. I am using an Arduino Mega2560 with a Seeedstudio uBlox GPS Bee connected on Serial1 at a baud rate of 9600.

    void loop()
    {
    while(Serial1.available())
    {
    if(gps.encode(Serial1.read()))
    {
    getCurrentPoint(gps);
    }
    }
    }

    void getCurrentPoint(TinyGPS &gps)
    {
    gps.f_get_position(&lat, &lon);
    gps.get_datetime(&date, &time, &age);
    }


  17. Christopher

    10 years ago

    Mikal, I am new to Arduino and programming in general. I am having great difficulty using TinyGPS. I am able to connect my GPS to my Arduino and get NEMA sentences to display on my IDE Serial Monitor using my own basic code. However, I have been unsuccessful at parsing the information using TinyGPS. Can you, or anyone here, provide a full sample code for displaying the basics (position, date, time, altitude, speed and course)? My goal is to output this info to an LCD.


  18. Mikal

    10 years ago

    @Josh,

    The bottleneck that is limiting your device to one update per second is not your code or TinyGPS or the Arduino: it’s the GPS Bee. I studied some of the documentation, and as you can see from this image, the GPS bee only transmits useful position and date/time information once per second, i.e. one $GPRMC and one $GPGLL sentence per second. This is actually quite common with less expensive GPS modules.


  19. Mikal

    10 years ago

    @Christopher,

    There are some pretty useful samples that are bundled with TinyGPS. If you look at File/Examples/TinyGPS, try modifying the test_with_gps_device to your setup. Let me know if that helps.


  20. Josh

    10 years ago

    Oh wow, I can’t believe I never considered that as an option. Thanks so much for your help!


  21. Christopher

    10 years ago

    Mikal, I am using a Ublox LEA-5M-0-002 but am getting a strange reading. I have included a sample of the NEMA sentences that I am seeing. I personally can’t determine what is going on but it does not seem correct at all. I may try another module as I have access to dozens. Any help would be appreciated.

    $GPGGA,002552.00,4426.03219,N,09308.79763,W1,06,1.69,303.7,M,-31.0,M,,*6D
    $GPRMC,002552.00,A,4426.03219,N,09308.79763,W,0.264,115.07,100713,,,A*79

  22. Mikal

    10 years ago

    @Christopher, can you clarify what you mean? What “does not seem correct”?

    Did you copy those two NMEA sentences correctly? The second one is good, but the first one seems to have a comma missing after the W.


  23. Mike McCauley

    10 years ago

    Hi Mikal,
    love your TinyGPS

    I have it working on Maple and Flymaple now.
    Only one change to your library is required to make it compatible with both Arduino and Maple:

    In TinyGPS.cpp Add:

    #include <stdlib.h>

    before

    #include "TinyGPS.h"

    else get a compile error concerning atoi()

    I have tested this change on both Maple and Arduino. It is necessary for Maple and innocuous for Arduino.

    Can you add it to future release?

    Cheers.


  24. Mikal

    10 years ago

    @Mike,

    Hey! Thanks for the suggestion. I’ll put it on the todo list.


  25. jsfak

    10 years ago

    Thanks for sharing your library. It is feeding my enjoyment of learning to use various sensors.

    I’m curious why I get different lat/long reads from the same $GPGGA sentences whether I am using your TinyGPS library or just the Arduino RX pin. Without your library, there is an offset of several miles from my true location. Though, the DOP’s and satellites accessed are the same (and date and time differ in only the seconds that it takes to upload the sketches). The altitude is fairly close, but at my desk in the SF Bay Area, the read varies from 10 meters under to 20 meters high, regardless of the sketch (possibly influenced by economic factors).

    At least, I am getting consistent numbers from multiple fixes and do not think that the difference is in the serials. Rather, I think that the differences is in the offset values that the SKM53 does not transmit ($GPDTM).

    Since the GPS module does not receive data from the Arduino, I am assuming that you are using a different correction for the values. Can you tell me what you are using? Is it a constant?

    Thanks again for all of your work!!


  26. Juan Pablo

    10 years ago

    Hi Mikal!
    How can I check if the GPRMC reports a correct status “A” or incorrect “V”?. Thanks so much and Regards!


  27. Mikal

    10 years ago

    @jsfak,

    My suspicion is that you are misunderstanding the GPGGA and GPRMC lat/long format. When you see a latitude of this format

    4124.8963, N

    that doesn’t mean 41.248963 degrees. It means 41 degrees and 24.8963 minutes, which is reasonably nearby but not at all the same place.

    Of course the format 41.248963 degrees is much more useful for computers, so that’s the format that TinyGPS returns.


  28. Mikal

    10 years ago

    @Juan Pablo,

    TinyGPS doesn’t provide a direct way to test this, though you can see it indirectly. encode() only returns “true” on a GPRMC sentence when the status is ‘A’. I’ve got a new library in the works called TinyGPS++. It allows you to look at any field in any string you want. Want to test it? :)


  29. Dhanushka

    10 years ago

    HI Mikal, There is protocol calls SiRF. What is the different between SiRF, UART, . could I use your library to send NMEA 0183 stranded commands via SiRF protocol. I will be glad to hear from you. Thank You Very Much.


  30. Saurabh

    10 years ago

    Is this library compatible with all the gps modules/shields??


  31. Ylrahcs

    10 years ago

    Hi,

    I try to put the code in my Arduino, and get the GPS data, but this is actually what I get:

    Ň`zI |1Aˆ


  32. Lensdigital

    10 years ago

    Is there any way to get latitude/longitude seconds precision to 2 decimal places via this library?
    I’ve tried both gps.f_get_position and gps.get_position but both of them omit last digit. It basically returns coordinate like this: 41N 12′ 48.3″ instead of 41N 12′ 48.32″
    In other words gps.get_position returns 7 digit number instead of 8 digit number for &lat, &lon…

    Thanks! :)


  33. Mikal

    10 years ago

    @Dhanushka,

    SiRF is a binary protocol. It is roughly the equivalent of the NMEA protocol, but, um, binary. (NMEA is a text-based human-readable protocol.) I’m afraid TinyGPS doesn’t understand SiRF, and it can’t send NMEA, only receive it.

    @Saurabh,

    TinyGPS is hardware agnostic. If your module transmits position or time data via the NMEA 0183 $GPGGA or $GPRMC strings, it will work.


  34. Mikal

    10 years ago

    @Yirahcs,

    You probably either are connecting at the wrong baud rate or your device is set to transmit using a binary protocol.


  35. Mikal

    10 years ago

    @Lensdigital,

    Yes, this is something that I need to fix. Stay tuned. The parsing algorithm loses a tiny bit of accuracy.


  36. Ben

    10 years ago

    Hi Mikal,

    How can we add the GPRMB sentence to the library ?
    I would like to use the L and R information for my rudder project.

    Thanks,
    Ben


  37. Mikal

    10 years ago

    @Ben,

    I’ve got a new library in the works called TinyGPS++ that will allow you to look at any field you want in any NMEA sentence type. Wanna try it out?


  38. Baptiste

    10 years ago

    @Mikal,
    Hi, I am interested by tinyGPS++, where can we find it?
    Thanks !


  39. Mikal

    10 years ago

    @Baptiste,

    I am just writing my first TinyGPS++ post right now, but I’d welcome a preliminary look at the first rev of the library: https://github.com/mikalhart/TinyGPSPlus.


  40. Daniel

    10 years ago

    Hi Mikal, first of all thanks for the wonderful TinyGPS library.
    I have one problem getting the altitude. It shows as 1000000. I am using the seeeduino stalker, with xbee GPS. I get the altitude and save in the SD card.
    Below follows the code, anyone have some clue about what is happening?

    float altitude_float = gps.f_altitude();

    char altitude_char[25];
    dtostrf(altitude_float,1,2,altitude_char);
    String my_altitude_as_string = String(altitude_char);

    Then I save “my_altitude_as_string” in my SD card.

    I do the same for latitude and longitude, and the data is coming with no problem. Any hint would help.
    Thank you!


  41. Mikal

    10 years ago

    Daniel, I’m guessing that your GPS doesn’t generate the altitude field–or at least not in a way that TinyGPS understands. It would be easy to prove this by looking at the raw NMEA stream. Could you post a few seconds worth of raw data from your module? You could use code something like this:

    while (true)
      if (ss.available())
        Serial.write(ss.read());
    

  42. Daniel

    10 years ago

    Thank you for your response Mikal,

    After some tests I could realize that the problem is in the NMEA that my GPS is creating.

    Below follows one example of a NMEA generated (I do not have my arduino here to get more NMEA examples):

    $GPVTG,,T,,M,0.064,N,0.1K581N9147,1098.AA451222476235.,,20$G,,$GPRMC,020231.00,A,4458.82317,N,09311.14624,W,0.034,,100913,,,D*65

    I realized something weird. When I turn on the arduino with the GPS, in the first 30 seconds it shows $GPGGA, and after starting to get valid fixes, it does not show $GPGGA anymore, just a NMEA like the one above.

    To get the NMEA above I used the code example you posted.

    I also tested the same code with another seeeduino stalker and another GPS. But the same thing happened.

    What is really weird is that once the NMEA was with the GPGGA rightly and after restarting the arduino I could not see it anymore. I got it just once, even after several tests. =(

    Have you ever experienced something like this before?

    Thank you!


  43. Mikal

    10 years ago

    @Daniel,

    The presence of the $G and the $GPRMC is the middle of that line tells me that you are dropping characters. Make sure the baud rate that you are connecting your serial monitor is greater than GPS module.

    Also, I think what must be happening is that you are doing too much processing of the data (delay()?) when encode() returns true. Call the stats() function and check the checksum value.


  44. Mikal

    10 years ago

    @Daniel–

    Rereading your earlier post, I remember know that you are using the SD library. Try disabling the SD write temporarily and see if that fixes your problem. SD can be notoriously slow.


  45. Daniel

    10 years ago

    Thank you for your fast response.
    I changed my strategy and I am not using the SD card anymore. I got my arduino again and have just performed a new test:

    I connected my GPS bee directly in the ports 2 and 3 of my arduino, and then I am using SoftwareSerial library. Then, I use the arduino serial to print in the serial monitor (I did this because my arduino uses the port 0 and 1 to connect in the xbee socket, and when I use the socket I cannot print in the Serial at the same time because they share the same ports).
    Below follows my code:

    #include
    #include “TinyGPS.h”
    TinyGPS gps;

    #define RXPIN 2
    #define TXPIN 3

    SoftwareSerial nss(RXPIN, TXPIN);

    void setup() {
    Serial.begin(57600);
    nss.begin(9600);
    }

    void loop()
    {
    unsigned short sentences = 0, failed = 0;
    unsigned long chars = 0;

    gps.stats(&chars, &sentences, &failed);

    while (nss.available())
    {
    char input = nss.read();
    Serial.print(input);
    if (gps.encode(input))
    {
    float lat, lon;
    unsigned long age;
    gps.f_get_position(&lat, &lon, &age);

    Serial.print(“\nLatitude.: “);
    Serial.println(lat);
    Serial.print(“Longitude: “);
    Serial.println(lon);
    Serial.print(“Altitude.: “);
    Serial.println(gps.f_altitude());
    Serial.print(“Satellites: “);
    Serial.println(gps.satellites());
    Serial.print(“Age……: “);
    Serial.println(age);

    Serial.print(“Chars….: “);
    Serial.println(chars);
    Serial.print(“Sentences: “);
    Serial.println(sentences);
    Serial.print(“Failed…: “);
    Serial.println(failed);

    }
    }
    }

    And below is part of the content of the serial monitor. Note that after I get valid fixes, the NMEA changes and shows just $GPVTG and $GPRMC:

    $GPVTG,,,,,,,,,N*30
    $GPGGA,042115.00,,,,,0,00,99.9,,6
    A,,,,,9999993
    P,155,1,91,,,37$GV,02,*BGG,,410V
    $GPRMC,042116.00,V,,,,,,,100913,,,N*77
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042116.00,,,,,0,00,99.9,,*
    SA,,,,,99999*
    GV,01,,,32,32,7
    PS2,,,57$PL,01.,
    $GPRMC,042117.00,V,,,,,,,100913,,,N*76
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042117.00,,,,,0,00,99.,,,
    $,1,,,,9,.,9*0$G2,,,16,,,42,4
    $S,262,2,4A
    PL,01,N
    $GPRMC,042118.00,V,,,,,,,100913,,,N*79
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042118.00,,,,,0,00,99.9,,6
    SA,,,,9999993
    PV155,,,11,,,37
    PV,02,68$G,,410V

    [snip]

    PV,02,*
    $G,,420V
    $GPRMC,042121.00,V,,,,,,,100913,,,N*73
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042121.00,,,,,0,00,99.9,,*
    SA,,,,,99999*
    GV,01,,,32,62,7
    PS,,,,47$PL,01.,E$GPRMC,042122.00,V,,,,,,,100913,,,N*70
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042122.00,,,,,0,00,99.9,,6
    S,,,,,9999993
    P,155,1,81,,,37
    PV,02,*A$G,,420V
    $GPRMC,042123.00,V,,,,,,,100913,,,N*71
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042123.00,,,,,0,00,99.9,,6$A,,,,,9999990$P,15,21,9132,3A$G,202,*
    GG,,420V
    $GPRMC,042124.00,V,,,,,,,100913,,,N*76
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042124.00,,,,,0,00,99.9,,6
    S,,,,,,999993
    PV,55,,,91,,,,7
    PV,0,,68$G,,02.,
    $GPRMC,042125.00,V,,,,,,,100913,,,N*77
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042125.00,,,,,0,00,99.9,,6
    A,,,,,9999993
    P,155,1,91,,,37$GV,02,*9$G,,420V
    $GPRMC,042126.00,V,,,,,,,100913,,,N*74
    $GPVTG,,,,,,,,,N*30
    $GPGGA,042126.00,,,,,0,00,99.9,,6
    SA,,,,9999993
    PV,05,,,39,,,,7
    PV,02,24,*
    $L,,40,4$GPRMC,042127.00,A,4458.79572,N,09311.14975,W,0.881,,100913,,,A*6C
    Latitude.: 44.98
    Longitude: -93.19
    Altitude.: 1000000.00
    Satellites: 255
    Age……: 145
    Chars….: 7642
    Sentences: 0
    Failed…: 58

    [snip]


  46. Mikal

    10 years ago

    @Daniel,

    What happens if you just put this code in your loop?

    void loop()
    {
      while (nss.available())
      {
        char input = nss.read();
        Serial.print(input);
      }
    }
    

  47. Abhishek Nandwana

    10 years ago

    Hi MIkal, I am interested in reading the definitions of the functions in the TinyGPS library. Can you help me with this? Nice work by the way, thanks a lot for your great work.


  48. Mikal

    10 years ago

    @Abhishek,

    I think I would look at some of the example code that is bundled with TinyGPS. Can you start there?


  49. Bernhard K

    10 years ago

    Hi,
    I am working with Leica DGPS Receivers that give accurate results in the cm range. The NMEA sequences are the same as usual, but GGA and RMC have more digits, like

    $GPGGA,102644.00,4813.7943164,N,01621.5693035,E,2,05,2.3,215.472,M,,,0.00,0000*2B

    TinyGPS++ can parse the sequences OK, but the transformation to floats is not accurate to the last significant digit:

    4813.7943164 (NMEA) should Output 48.229905273 (degree)

    TinyGPS++ converts the Latitude to 48.229904174
    I think this Comes with the Int/float conversion that is internally done in TinyGPS++

    The error does not occur with plain vanilla GPS Receivers that are limited in their accuracy anyway.
    Do you have any idea how this could be solved? Unfortunately C/C++ is not my first language so I am more or less at a loss when trying to change the conversion Routines

    Thanks!
    Bernhard


  50. Mikal

    10 years ago

    @Bernhard,

    See my response on TinyGPS++.

82 Trackbacks For This Post
  1. เริ่มต้นสร้าง GPS จอสีกับอาดูอี้โน่ | Ayarafun Factory

    [...] http://www.sundial.org/arduino/?page_id=3 [...]

  2. 10

    [...] won’t. I answer a few questions on the Arduino microcontroller forum and post an update to a library I [...]

  3. The Hired Gun » GPS project: show me something

    [...] this journey I also looked into using the TinyGPS library. While it does a nice job of handling the core GPS parsing, I still had the primary desire to log [...]

  4. GPS mit Arduino - Webmeister Blog

    [...] serielle Verbindung werden die  Daten ans Display geschickt. Verwendet werden die Bibliotheken TinyGPS und [...]

  5. The Frustromantic Box, Part 4: Software « New Bright Idea

    [...] Arduino developers for the great librarires, and to Mikal Hart in particular for his work on the TinyGPS and NewSoftSerial [...]

  6. Transmission success - Projects

    [...] and sending the bits of “Hello World” in 7N1 format.  I spent some time with the TinyGPS and NewSoftSerial libraries from Mikal Hart, and got the parsing working nicely and building an [...]

  7. GPS testing with LCD Character Display

    [...] can have the LCD output latitude, longitude, or whatever. You’ll need the TinyGPS library from Arduiniana downloaded and installed for it to work. They suggest using NewSoftSerial, but I couldn’t get [...]

  8. Arduino GPS — not exactly pocket-sized, but cool! « Arduino Projects FTW

    [...] EEPROM so they are persistent between power cycles. The sketch uses Mikal Hart's excellent TinyGPS library and includes code from the ArduPilot Projectfor [...]

  9. A fully functional Arduino GPS receiver | Embedded projects from around the web

    [...] uses a TinyGPS library for easier GPS shield access. So device can be used as normal GPS tracking device the only [...]

  10. Moving Forward with Arduino – Chapter 17 – GPS « t r o n i x s t u f f

    [...] point you will need to install two libraries into the Arduino software – NewSoftSerial and TinyGPS. Extract the folders into the libraries folder within your arduino-001x [...]

  11. Shield Driven Arduino GPS

    [...] sketch uses Mikal Hart’s excellent TinyGPS library and includes code from the ArduPilot Project for [...]

  12. GPS bővítés « Nikon D5000 DSLR

    [...] 2 [...]

  13. The Maritime Geocaching Association » Build Your Own Steampunk GPS

    [...] attached code should pretty much speak for itself. Using the TinyGPS library, your current position is taken and the direction to the final location is calculated. [...]

  14. Moving Forward with Arduino – Chapter 19 – GPS part II « t r o n i x s t u f f

    [...] pull-down resistor). You will need to install the SdFAT library, NewSoftSerial library, TinyGPS library and the SdFat library if not already [...]

  15. Arduinoによる放射線データ収集(3) « stastaka's Blog

    [...] http://arduiniana.org/libraries/tinygps/ USBシリアルを使っているとTX,RXが使えませんが、 [...]

  16. reptile-addict.nl | My Arduino Blog

    [...] Mikal Hart’s tinyGPS library; [...]

  17. Communicating to GPS Receiver using USB Host Shield « Circuits@Home

    [...] how to send raw GPS output to a NMEA 0183 message parser. For the following code example I used Mikal Hart’s TinyGps library. Since the library itself is not handling serial input, it was only necessary to make changes in [...]

  18. GpsBee and Seeeduino Stalker v2 « Wireless Building Automation

    [...] easy developing of the necessary Arduino application I used an existent dedicated library: TinyGPS (http://arduiniana.org/libraries/tinygps/), which help us to parse all the packets received on the serial port from the GpsBee module. Ok, so [...]

  19. SheekGeek » Blog Archive » Weather Balloon Payload Testing on a Model Rocket (Pt.1)

    [...] and gyroscope package and slapped together a simple SD card interface. The libraries I used were TinyGPS and fat16lib (for SD card use). Weather_Balloon_Code and schematic in case you’d like to [...]

  20. Moving Forward with Arduino – Chapter 19 – GPS part II « t r o n i x s t u f f

    [...] forget the 10k ohm pull-down resistor). You will need to install NewSoftSerial library, TinyGPS library and the SdFat library if not already [...]

  21. Anonymous

    [...] [...]

  22. Jacket Positioning System: JPS « Titles are Strange Things

    [...] it’s pretty simple. It only does those functions, but with the help of the truly fantastic TinyGPS library, I have a destination function in the [...]

  23. Testing MTK3329 10Hz GPS module and making an Arduino GPS logger | Develop with Arduino

    [...] TinyGPS for Arduino [...]

  24. Arduino + GPS Shield + LCD 16x2 | We Are The Electric Brothers

    [...] tinygps [...]

  25. TinyGPS Libraryを使ってGPSデータを取得

    [...] ちなみに、データ処理部分は、TinyGPS Libraryなる便利なものがあったので、それを使ってみた。 [...]

  26. GPS приемник на базе модуля Quectel L30 | Arduino Market

    [...] Библиотека для работы с GPS/NMEA для Arduino (TinyGPS) [...]

  27. Using SKYLAB SKM53 GPS with Arduino

    [...] Download TinyGPS her [...]

  28. Arduino GPS module test sketch - Develop with Arduino

    [...] Working with Arduino and TinyGPS [...]

  29. Distance measuring with Arduino - Develop with Arduino

    [...] Working with Arduino and TinyGPS [...]

  30. Tutorial 15 for Arduino: GPS Tracking | JeremyBlum.com

    [...] used the tinyGPS library to decode the NMEA GPS Data. Cooking-Hacks generously supplied both the GPS shield and SD Card [...]

  31. Early Sailing Sensor designs | Andrew Hodel

    [...] the TinyGPS library: http://arduiniana.org/libraries/tinygps/ Share this: Written by andrewhodel Posted in Engineering, [...]

  32. When thinking o… | pa2dy

    [...] “TinyGPS is designed to provide most of the NMEA GPS functionality I imagine an Arduino user would want ñ position, date, time, altitude, speed and course ñ without the large size that seems to accompany similar bodies of code.  To keep resource consumption low, the library avoids any floating point dependency and ignores all but a few key GPS fields.” – TinyGPS website [...]

  33. GPS Box | pa2dy

    [...] “TinyGPS is designed to provide most of the NMEA GPS functionality I imagine an Arduino user would want ñ position, date, time, altitude, speed and course ñ without the large size that seems to accompany similar bodies of code.  To keep resource consumption low, the library avoids any floating point dependency and ignores all but a few key GPS fields.” – TinyGPS website [...]

  34. GPS Box « Sketching with Hardware

    [...] “TinyGPS is designed to provide most of the NMEA GPS functionality I imagine an Arduino user would want ñ position, date, time, altitude, speed and course ñ without the large size that seems to accompany similar bodies of code.  To keep resource consumption low, the library avoids any floating point dependency and ignores all but a few key GPS fields.” – TinyGPS website [...]

  35. Telemetría y data logger with Arduino Part IIÁlvaro López | Álvaro López

    [...] a Base y testear el alcance de las antenas, el proceso lo he ejecutado en el Base. He utilizado la librería TinyGPS que aparentemente funciona bastante bien, y los programas usados han sido los [...]

  36. Updated – WISMO228 Library for Arduino | Rocket Scream

    [...] (while adding more functionality) as we also need use the SD library for logging and also the TinyGPS library for GPS NMEA output [...]

  37. GPS Speed Display | Open Source Software Development

    [...] project makes use of the TinyGPS library. It provides a useful parsing library with easy access to the data returned by the Serial [...]

  38. Arduino + HMC6343 + u-blox MAX-6 | cjdavies.org

    [...] not hard to parse it yourself, but why go to the effort when there are libraries like TinyGPS that can do it for [...]

  39. EECS Sr Design » Blog Archive » 7. Team Bravo Squad – Prototype I Final Report: Emergency GPS Locator

    [...] the next while tweaking things. During that time, we rewrote the code (attached below) to use the TinyGPS library and wired the switch up. For the switch, it was simply a matter of connecting the common pin on the [...]

  40. Interfaceando com modulo GPS EM-411 | Alan Carvalho de Assis

    [...] Estava procurando uma biblioteca para interfacear com o modulo EM-411 mas não queria algo muito complexo, apenas algo que retornasse a distancia entre duas lat/long e o angulo entre elas. Então encontrei o projeto TinyGPS. [...]

  41. Montando o GPS | Heliostat Brasil

    [...] to interpret the information the GPS sends out ourselves as there’s a really helpful libraryTinyGPS that will do the hard work for [...]

  42. Fastrax UP501 GPS Module - Babelduck Cybernetics

    [...] Works with Arduino TinyGPS Library http://arduiniana.org/libraries/tinygps/ [...]

  43. Sketching with Hardware 2012 6/6 – GPS Box | Blog

    [...] “TinyGPS is designed to provide most of the NMEA GPS functionality I imagine an Arduino user would want ñ position, date, time, altitude, speed and course ñ without the large size that seems to accompany similar bodies of code.  To keep resource consumption low, the library avoids any floating point dependency and ignores all but a few key GPS fields.” – TinyGPS website [...]

  44. Slow progress, but progress non-the-less! | Decibear

    [...] tutorial video from Jeremy Blum to help us work out the GPS module, in which he referred us to the TinyGPS arduino library which we found lovely to use. With the help of Jeremy, and the example sketches with the library, [...]

  45. Pre-Race Telemetry Snippets | TechWeasel

    [...] TinyGPS Arduino library makes it very simple to make your GPS do something useful, much thanks… Hope [...]

  46. GPS modules for sale! | Rock 7 - RockBLOCK

    [...] is standard 9600 baud serial NMEA sentences.  There’s an excellent GPS NMEA decoder library for Arduino here which works with this [...]

  47. Data geo-tagging primer | biodesign for the real world

    [...] TinyGPS is a library for Arduino that allows to use a GPS module relatively painlessly. [...]

  48. Arduino GPS Tracking System -Arduino for Projects

    [...] used the tinyGPS library to decode the NMEA GPS Data. Cooking-Hacks generously supplied both the GPS shield and SD Card [...]

  49. Arduino GPS Datalogger -Arduino for Projects

    [...] using two really awesome libraries written by Mikal Hart, so make sure you have downloaded them! (TinyGPS and NewSoftSerial ) TinyGPS basically makes it easier for us to extract data like longitude and [...]

  50. nmea gpgga | GPS検索

    [...] TinyGPS | Arduiniana sentences – the number of valid $GPGGA and $GPRMC sentences processed; failed_checksum …. I am trying to input some proper NMEA commands but the response goes just like that. CHARS=0 …. 46 Trackbacks For This Post. เริ่มต้น สร้าง … [...]

  51. gpgga format | GPS検索

    [...] TinyGPS | Arduiniana sentences – the number of valid $GPGGA and $GPRMC sentences ….. 46 Trackbacks For This Post … and sending the bits of “Hello World” in 7N1 format. I spent … [...]

  52. My Proposal Box, Part 3: Software

    [...] click here to download it. You will also need to download the PWMServo library (version 2) and the TinyGPS library written by Mikal Hart. While you are at his site, thank him for his amazing work. If you [...]

  53. Xronos Clock Home – Time via GPS

    [...] for what I needed, and used interrupts, and other complex stuff Fortunately Time library used TinyGPS library, which is indeed very lightweight and straightforward. It also “requires” [...]

  54. Arduino en GPS | Pieters fijne blog

    [...] TinyGPS library [...]

  55. Greater Accuracy with TinyGPS 13 | Arduiniana

    [...] TinyGPS [...]

  56. GPS Bee Kit (Part 2) | Zx Lee

    [...] the next part, I am going to use one of the library available for Arduino, which is TinyGPS. You can download TinyGPS library here. This library ease your job to get all the information from [...]

  57. The Frustromantic Box, Part 4: Software | New Bright Idea

    [...] the Arduino developers for the great libraries, and to Mikal Hart in particular for his work on the TinyGPS and NewSoftSerial [...]

  58. Playing around with GPS: ATtiny GPS LongLat Logger « insideGadgets

    [...] recently purchased one of those U-blox GPS modules from Ebay for $20 and after downloading the TinyGPS library for the Arduino, it works well once it has valid GPS data (I had to have mine close to the window) [...]

  59. Módulo GPS Skylab SKM53 | AUTOMALABS

    [...] a biblioteca TinyGPS (documentação e download da v13). Requer [...]

  60. My 15$ GPS module | Bajdi.com

    [...] to the module and hooked it up to an ATmega328 running at 3.3V / 8MHz. I installed the Arduino tinygps library and uploaded one of the example sketches to the ATmega. I put my laptop, micro controller and GPS [...]

  61. 86duino

    [...] This requires the TinyGPS and NewSoftSerial libraries from Mikal Hart: http://arduiniana.org/libraries/TinyGPS and http://arduiniana.org/libraries/newsoftserial/ [...]

  62. GPS Ublox Neo-6M cu Arduino Uno | ArduHobby

    [...] biblioteca tinyGPS sau [...]

  63. Arduino Development Journal/May 2014 | Surfing Satellites

    [...] one extra sentence that is discarded by TinyGPS (a very cool library – check it out at http://arduiniana.org/libraries/tinygps/).  I corrected that and believe the GPS delivers the optimum number of sentences at 19200 baud to [...]

  64. Tutorial – Arduino and MediaTek 3329 GPS » Geko Geek

    [...] fly, so thankfully there is an Arduino library to do this for us - TinyGPS. So head over to the library website, download and install the library before [...]

  65. Tutorial – Arduino and MediaTek 3329 GPS

    [...] fly, so thankfully there is an Arduino library to do this for us - TinyGPS. So head over to the library website, download and install the library before [...]

  66. GPS und Arduino | wer bastelt mit?

    [...] Eine recht praktische und kompakte Library zum Parsen von GPS/NMEA Daten: TinyGPS [...]

  67. Interfacing a USB GPS with an Arduino | Bayesian Adventures

    [...] Library to connect to the shield and I modified the code a little to stream incoming data into Mikal Hart’s GPS Parser Library, TinyGPS. Here is the crux of the [...]

  68. Freematics Blog – Users Guide for Arduino Telematics Kits

    [...] TinyGPS Library [...]

  69. Freematics Blog – Freematics OBD-II Adapter Programming Guide

    [...] TinyGPS Library [...]

  70. Spark Core and TinyGPS Library | devlper

    [...] comes a sample application using Spark Core and TinyGPS library. TinyGPS is a very powerful and fast NMEA GPS parser for Arduino and compatible. In this [...]

  71. Arduino UNO with GPS module(GY-GPS/NEO6MV2) - TFP

    [...] the Arduino IDE, I shall directly skip on the coding part then. Our arduino sketch will require Tiny GPS library, which you can download it from here. Import the downloaded library to your Arduino IDE. [...]

  72. GPS logging on SD card using TinyGPS | CL-UAT

    [...] tutorials are either too complex (i.e. include extra stuff like displays) or they don’t use TinyGPS or TinyGPS++ library. In the first step I’ve managed to get GPS working and displaying the [...]

  73. A cheap, functioning GPS | Denial Media

    [...] first thing I had to do software wise was install the TinyGps library. This was hard to do as the creator’s website was iffy at the time. I ended up downloading it from github and renaming it to get rid of the dash [...]

  74. GPS Tracker на ардуино своими руками | FNIT.RU

    [...] TinyGPS (ссылка на скачивание в середине страницы) [...]

  75. Arduino Time Library learning notes | tlfong01

    [...] requires the TinyGPS and NewSoftSerial libraries from Mikal Hart: http://arduiniana.org/libraries/TinyGPS and http://arduiniana.org/libraries/newsoftserial/ Example [...]

  76. Arduino (IoT): Simple Tutorial GPS Top Titan 3 Glonass: Parte 1 – Santiapps – Arduino (IoT), iOS, Android & Glass

    [...] ser parsed a datos de ubicación, velocidad etc.  Esto lo logramos usando la TinyGPS library (http://arduiniana.org/libraries/tinygps/) que veremos en la Parte [...]

  77. The SX1276 Modules Shootout – HopeRF’s RFM95W vs NiceRF’s LORA1276-C1 vs HPDTEK’s HPD13 – Rocket Scream

    [...] the base station. If a valid acknowledgement packet is received, the current GPS information (using TinyGPS library)  is retrieved from L80 GPS module and stored. Some of you might have argue why not use the full [...]

  78. Shield o Módulo GPS con Arduino Introducción - Geek Factory

    [...] http://arduiniana.org/libraries/tinygps/ [...]

  79. Módulo GPS Skylab SKM53 | Diário de Nilton Felipe

    [...] a biblioteca TinyGPS (documentação e download da v13). Requer [...]

  80. Tutorial Arduino: monta un GPS con reloj con Arduino - Arduino, Genuino, Raspberry Pi. Noticias y proyectos.

    [...] LCDUn módulo GPS en este caso el EM-411Breadboard, jumperwires y un potenciometro.Biblioteca TinyGPS.Enlace al tutorial completo.Califique esto Sample rating [...]

  81. Living by Numbers | nr's blog

    [...] photo you can see the GPS shield, which has now turned up. A quick bit of poking with the lovely TinyGPS library has shown that it’s giving me location data, and as a bonus, there’s a function [...]

  82. Tutorial : Reading GPS data via Arduino – DISTRIBUTOR ALAT PENGUSIR TIKUS

    [...] Library Used : http://arduiniana.org/libraries/tinygps/ [...]

Leave a Reply