A *NEW* Full-featured GPS/NMEA Parser for Arduino

TinyGPS++ is a new Arduino library for parsing NMEA data streams provided by GPS modules.

Like its predecessor, TinyGPS, this library provides compact and easy-to-use methods for extracting position, date, time, altitude, speed, and course from consumer GPS devices. 

However, TinyGPS++’s programmer interface is considerably simpler to use than TinyGPS, and the new library can extract arbitrary data from any of the myriad NMEA sentences out there, even proprietary ones.

Download and Installation

To install this library, download here, unzip the archive into the Arduino “libraries” folder, and restart Arduino. You should rename the folder “TinyGPSPlus”.


TinyGPS++ is the immediate inheritor of TinyGPS, a popular compact parser that is used in Arduino installations around the world.  TinyGPS++ is not quite as ‘tiny’ as its older sibling, but its powerful and extremely easy-to-use new object model and useful new feature set make it an attractive alternative.


Let’s say you have an Arduino hooked to an off-the-shelf GPS device and you want to display your altitude.  You would simply create a TinyGPS++ instance like this:

#include "TinyGPS++.h"
TinyGPSPlus gps;

Repeatedly feed it characters from your GPS device:

while (ss.available() > 0)

Then query it for the desired information:

if (gps.altitude.isUpdated())

Differences from TinyGPS

Although TinyGPS++ shares much the same compact parsing engine with TinyGPS, its programmer interface is somewhat more intuitive.  As a simple example, here’s how easy it is to print out the current latitude, longitude, and altitude in TinyGPS++:

Serial.print("LAT=");  Serial.println(gps.location.lat(), 6);
Serial.print("LONG="); Serial.println(gps.location.lng(), 6);
Serial.print("ALT=");  Serial.println(gps.altitude.meters());

Both libraries extract basic position, altitude, course, time, and date, etc. from two common NMEA sentences, $GPGGA and $GPRMC. But there are a number of other interesting sentences out there, both NMEA-defined and vendor-proprietary, just waiting to be harvested.

Consider the obscure $GPRMB, for example, which provides “recommended minimum navigation information” if you have a destination waypoint defined.


With TinyGPS++ it is now possible to extract just the “L” in the third field (it means “steer Left!”). It’s easy with the new TinyGPSCustom watcher object:

TinyGPSCustom steerDirection(gps, "GPRMB", 3);
Serial.print(steerDirection.value()); // prints "L" or "R"

Naturally, this extra functionality comes at some cost.  TinyGPS++ consumes somewhat more memory than TinyGPS, and it’s interface is incompatible.  So how to decide whether to update?  Here’s a guide:

Consider TinyGPS++ over TinyGPS if:

  • Compatibility with existing code (using TinyGPS) isn’t necessary.
  • Your sketch is not close to reaching RAM or flash resource limits.
  • You are running on Due or processor which can take advantage of the higher precision of 64-bit “double” floating-point.
  • You prefer the more intuitive object model.
  • You need to query for NMEA data beyond the basic location, date, time, altitude, course, speed, satellites or hdop.

Feeding the Hungry Object

To get TinyGPS++ to work, you have to repeatedly funnel the characters to it from the GPS module using the encode() method. For example, if your GPS module is attached to pins 4(RX) and 3(TX), you might write code like this:

SoftwareSerial ss(4, 3);
void loop()
  while (ss.available() > 0)

After the object has been “fed” you can query it to see if any data fields have been updated:

  if (gps.location.isUpdated())
    Serial.print("LAT="); Serial.print(gps.location.lat(), 6);
    Serial.print("LNG="); Serial.println(gps.location.lng(), 6);
} // end loop()

The TinyGPS++ Object Model

The main TinyGPS++ object contains several core sub-objects:

  • location – the latest position fix
  • date – the latest date fix (UT)
  • time – the latest time fix (UT)
  • speed – current ground speed
  • course – current ground course
  • altitude – latest altitude fix
  • satellites – the number of visible, participating satellites
  • hdop – horizontal diminution of precision

Each provides methods to examine its current value, sometimes in multiple formats and units. Here’s a complete list:

Serial.println(gps.location.lat(), 6); // Latitude in degrees (double)
Serial.println(gps.location.lng(), 6); // Longitude in degrees (double)
Serial.print(gps.location.rawLat().negative ? "-" : "+");
Serial.println(gps.location.rawLat().deg); // Raw latitude in whole degrees
Serial.println(gps.location.rawLat().billionths);// ... and billionths (u16/u32)
Serial.print(gps.location.rawLng().negative ? "-" : "+");
Serial.println(gps.location.rawLng().deg); // Raw longitude in whole degrees
Serial.println(gps.location.rawLng().billionths);// ... and billionths (u16/u32)
Serial.println(gps.date.value()); // Raw date in DDMMYY format (u32)
Serial.println(gps.date.year()); // Year (2000+) (u16)
Serial.println(gps.date.month()); // Month (1-12) (u8)
Serial.println(gps.date.day()); // Day (1-31) (u8)
Serial.println(gps.time.value()); // Raw time in HHMMSSCC format (u32)
Serial.println(gps.time.hour()); // Hour (0-23) (u8)
Serial.println(gps.time.minute()); // Minute (0-59) (u8)
Serial.println(gps.time.second()); // Second (0-59) (u8)
Serial.println(gps.time.centisecond()); // 100ths of a second (0-99) (u8)
Serial.println(gps.speed.value()); // Raw speed in 100ths of a knot (i32)
Serial.println(gps.speed.knots()); // Speed in knots (double)
Serial.println(gps.speed.mph()); // Speed in miles per hour (double)
Serial.println(gps.speed.mps()); // Speed in meters per second (double)
Serial.println(gps.speed.kmph()); // Speed in kilometers per hour (double)
Serial.println(gps.course.value()); // Raw course in 100ths of a degree (i32)
Serial.println(gps.course.deg()); // Course in degrees (double)
Serial.println(gps.altitude.value()); // Raw altitude in centimeters (i32)
Serial.println(gps.altitude.meters()); // Altitude in meters (double)
Serial.println(gps.altitude.miles()); // Altitude in miles (double)
Serial.println(gps.altitude.kilometers()); // Altitude in kilometers (double)
Serial.println(gps.altitude.feet()); // Altitude in feet (double)
Serial.println(gps.satellites.value()); // Number of satellites in use (u32)
Serial.println(gps.hdop.value()); // Horizontal Dim. of Precision (100ths-i32)

Validity, Update status, and Age

You can examine an object’s value at any time, but unless TinyGPS++ has recently been fed from the GPS, it should not be considered valid and up-to-date. The isValid() method will tell you whether the object contains any valid data and is safe to query.

Similarly, isUpdated() indicates whether the object’s value has been updated (not necessarily changed) since the last time you queried it.

Lastly, if you want to know how stale an object’s data is, call its age() method, which returns the number of milliseconds since its last update. If this returns a value greater than 1500 or so, it may be a sign of a problem like a lost fix.


When a TinyGPS++ sketch fails, it’s usually because the object received an incomplete NMEA stream, or perhaps none at all.

Fortunately, it’s pretty easy to determine what’s going wrong using some built-in diagnostic methods:

  • charsProcessed() – the total number of characters received by the object
  • sentencesWithFix() – the number of $GPRMC or $GPGGA sentences that had a fix
  • failedChecksum() – the number of sentences of all types that failed the checksum test
  • passedChecksum() – the number of sentences of all types that passed the checksum test

If your sketch has been running a while but charsProcessed() is returning 0, you likely have a problem with your wiring or serial connection. (If data never arrives from the GPS unit, it stands to reason it’s not getting to TinyGPS++.) I often insert a little debug clause into my GPS sketches detects this condition then prints out the incoming stream:

// Debug: if we haven't seen lots of data in 5 seconds, something's wrong.
if (millis() > 5000 && gps.charsProcessed() < 10) // uh oh
  Serial.println("ERROR: not getting any GPS data!");
  // dump the stream to Serial
  Serial.println("GPS stream dump:");
  while (true) // infinite loop
    if (ss.available() > 0) // any data coming in?

Another common failure is when the sentences sent to TinyGPS++ are incomplete. This usually happens when you retrieve the characters from the GPS so slowly or infrequently that some are lost. The symptom is easy to spot: checksum failure.

Explanation: Every NMEA sentence ends with a numeric field that represents a mathematical summing of all the characters in the sentence. It’s there to ensure data integrity. If this number doesn’t match the actual sum (perhaps because some characters went awry), TinyGPS++ simply discards the entire sentence and increments an internal “checksum failed” counter. You can read this counter with:

Serial.print("Sentences that failed checksum=");

// Testing overflow in SoftwareSerial is sometimes useful too.
Serial.print("Soft Serial device overflowed? ");
Serial.println(ss.overflow() ? "YES!" : "No");

If the checksum counter is continually incrementing, you have a problem. (Hint: don’t use delay() in your sketch.)

Custom NMEA Sentence Extraction

One of the great new features of TinyGPS++ is the ability to extract arbitrary data from any NMEA or NMEA-like sentence. Read up on some of the interesting sentences there are out there, then check to make sure that your GPS receiver can generate them.

The idea behind custom extraction is that you tell TinyGPS++ the sentence name and the field number you are interested in, like this:

TinyGPSCustom magneticVariation(gps, "GPRMC", 10)

This instructs TinyGPS++ to keep an eye out for $GPRMC sentences, and extract the 10th comma-separated field each time one flows by. At this point, magneticVariation is a new object just like the built-in ones. You can query it just like the others:

if (magneticVariation.isUpdated())
  Serial.print("Magnetic variation is ");

Establishing a fix

TinyGPS++ objects depend on their host sketch to feed them valid and current NMEA GPS data. To ensure their world-view is continually up-to-date, three things must happen:

  1. You must continually feed the object serial NMEA data with encode().
  2. The NMEA sentences must pass the checksum test.
  3. For built-in (non-custom) objects, the NMEA sentences must self-report themselves as valid. That is, 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 the position and altitude information is discarded (though time and date are retained).

It may take several minutes for a device to establish a fix, especially it has traveled some distance or a long time has elapsed since its last use.

Distance and Course

If your application has some notion of a “waypoint” or destination, it is sometimes useful to be able to calculate the distance to that waypoint and the direction, or “course”, you must travel to get there. TinyGPS++ provides two methods to get this information, and a third (cardinal()) to display the course in friendly, human-readable compass directions.

const double EIFFEL_TOWER_LAT = 48.85826;
const double EIFFEL_TOWER_LNG = 2.294516;
double distanceKm =
    EIFFEL_TOWER_LNG) / 1000.0;
double courseTo =
Serial.print("Distance (km) to Eiffel Tower: ");
Serial.print("Course to Eiffel Tower: ");
Serial.print("Human directions: ");

Library Version

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


Sample Sketches

TinyGPS++ ships with several sample sketch which range from the simple to the more elaborate. Start with BasicExample, which demonstrates library basics without even requiring a GPS device, then move onto FullExample and KitchenSink. Later, see if you can understand how to do custom extractions with some of the other examples.


Thanks go out to the many Arduino forum users for outstanding help in testing and popularizing TinyGPS, this library’s predecessor. Thanks especially to Maarten Lamers, who wrote the wiring library that originally gave me the idea of how to organize TinyGPS++.

All input is appreciated.

Mikal Hart

Page last updated on September 28, 2014 at 11:35 am
251 Responses → “TinyGPS++”

  1. Stanley

    4 months ago

    Dear Mikal,

    I’ve figure out a way to decode BeiDou GPS receiver … I took yr code and only change the 2 defines from GP to GN..

    #define _GPRMCterm “GNRMC”
    #define _GPGGAterm “GNGGA”

    There is an extra NMEA sentences called BDGSA similar to BDGSA to check for DOP & active Sats , add both the Sats up would give the total Sats in view…

    Could you add this BeiDou support to your next version release ?

    Thanks in advance..

  2. Dave

    4 months ago


    Is it possible to turn al LED on when there is a fix and an other when there is no fix?
    Tried couple of things, but don’t work…


  3. Fredrik

    4 months ago

    Thanks for the really beautiful and simple impl. of this library!

    I’m using the Adafruit Ultimate GPS module and is trying to parse out altitude and hdop values. But both end up beeing zero all the time. My module does seem to be supporting those NMEA strings… Any tips on what could be wrong? Also lacking a few decimal to get accurate position.


  4. Mikal

    4 months ago


    1. It’s possible that you are losing some data due to overflow?
    2. Serial.print(lat, 6). Add the second parameter to print with greater resolution.

  5. Mikal

    4 months ago


    Sure it’s possible. I look at the age() of, say, the location object. If it’s greater than a couple of seconds you probably don’t have a fix. What have you tried?

  6. Arion

    3 months ago


    Hi. Thank you for the library. Does the function “distanceBetween” calculate distance to another lat/lon location using the curvature of the earth calculations? Thanks!

  7. Chris

    3 months ago

    Used tinyGPS and now plus, with a uBlox NEO 6M successfully (got the data i wanted flawlessly). Now i’m trying to use uBlox LEA 6H from 3drobotics (Ardupilot 2.6). They have configured it for UBX data, but i managed to change the output to NMEA only.
    All i get is this (increasing Chars and Passed)
    DIAGS Chars=6560 Sentences-with-Fix=0 Failed-checksum=0 Passed-checksum=103
    I’ve waited for over an hour and still getting this.
    Using u-center (uBlox software) the LEA 6H locks after a minute (2′ tops).

  8. Yaron

    3 months ago

    Hi Mikal,
    First of all, the Tinygps is superb! It works great! Well done!
    I’m using a up501 gps module connected to Serial2 on my Arduino Mega 2560.
    Is there a way to get the gps to get a fix, and then restart it to get a new fix without turning anything off?
    I want my arduino to get gps fix data, do some other stuff for a few minutes, and then get a new gps fix and the old fix data to be erased.
    Is that possible?
    Thanks for your help!

  9. Thor Valø

    3 months ago

    Consistent read of GPS serial
    Created 17.10.2014
    By Thor Valo

    #include “TinyGPS++.h” // http://arduiniana.org/libraries/tinygpsplus/

    #include ; // required for virtual RX, TX

    TinyGPSPlus gps;
    SoftwareSerial gpsSerial(10, 11); // RX, TX (TX not used)

    const int serialTime = 100; // enough time to read all NMEA sentences once

    void setup()
    } // end setup

    void loop()
    int start = millis(); // reference for starting timestamp
    int now = millis();

    do {
    while (gpsSerial.available() > 0) {
    now = millis();
    } while ((now – start < serialTime)); // breaks out of read gps serial

    if (gps.location.isUpdated())
    Serial.print("Lat: "); Serial.println(gps.location.lat(), 6);
    Serial.print("Lng: "); Serial.println(gps.location.lng(), 6);

    if (gps.altitude.isUpdated()) {
    Serial.print("Alt: "); Serial.println(gps.altitude.meters());
    } // end main loop()

  10. alessandro

    3 months ago

    Dear Mikal you have done a great work! I am pretty sure I will use it in my next gps project. This is my first time I play with gps and I need more accuracy than 2.5 meters provided from all gps shields. Someone told me it can be improved calibrating the gps, I checked on internet but no luck. Do you have any library to suggest or any useful information about it?

    Thank you for sharing!

  11. Stefan

    3 months ago

    Hi Mikal! I’m trying to use version 13 TinyGPS.h, and I had trouble reading the data (data not printing), however I do the same with the V.12 version and if I print the data correctly (using test_with_gps_device). I have tried using the library TinyGPSPlus.h but neither works. the gps is working but does not show me any data (CHARS = 0 = 0 CSUM SENTENCES ERR = 0
    No characters ** received from GPS: check wiring **
      CHARS = 0 = 0 CSUM SENTENCES ERR = 0
    ). I have an Arduino UNO and GPS VPN1513. You have any idea what it could be?

  12. Juan Domingo

    3 months ago

    Hey there!

    First of all, I would like to thank you, Mikal, for sharing TinyGPS++. It’s awesome. Definitely, a piece of well done work.

    I have just spotted why my code wasn’t working perfectly OK with TinyGPS++ lib and I have thought it might be useful to other users or even a nice contribution to a new version of the lib.

    My GNSS device was outputting good data (I checked it by bypassing it through serial) but when at building and printing my propietary frame, I couldn’t get proper values for location.lat(), lng(), kmph(), gps time functions… GPS time suddenly freezed, and lat and lng kept outputting 0 after receiveng data fixes with such information.

    I was about going mad, thoroughly reviewing Mikal’s code, trying to understand what was happening “behind the scenes”. And then… I stopped over the word “_GPRMCterm” and the penny dropped.

    I’m currently working with GNS701, a GPS+GLONASS device. The thing is that when it receives GPS data, it outputs some $GP— frames; when it receives GLONASS data, it outputs some GL— frames; and when it combines both, it outputs some GN— frames. Therefore, you can have both GPGSV and GLGSV frames printed, or GNRMC instead of GPRMC.

    That last one case gave me a hard time. When the RMC frame outputted was the GPS RMC frame, things went reasonably well, as the lib was able to parse it with the encode function. But as soon as a better GPS/GLONASS signal was received, GNRMC frame was obtained. Thus, no further encoding was done.

    I fixed it defining GNRMC header in TinyGPSPlus.cpp

    #define _GPRMCterm “GPRMC”
    #define _GNRMCterm “GNRMC” //ADDED!!

    and matching GNRMC frames to GPRMC parsing (this is a bit twisted, bad practice, I know, but it works for GNRMC frame by now) in line 212

    if (!strcmp(term, _GPRMCterm) || !strcmp(term, _GNRMCterm)) //MODIFIED!!
    curSentenceType = GPS_SENTENCE_GPRMC;

    Adding GPS/GLONASS support should be quite easy. Just needs defining the headers and some extra clauses in switch-case structures (and things like that). So maybe, it’s an interesting feature to include in a new lib version release. I volunteer to help. Please, contact me if so.


  13. Pete

    3 months ago

    thsnks for the great software
    Just one question/ remark
    It would be great if minute and seconds are formatted 00-59
    instead of
    Serial.println(gps.time.minute()); // Minute (0-59) (u8)
    Serial.println(gps.time.second()); // Second (0-59) (u8)

    Is there a simple code to achieve this?

  14. Mikal

    2 months ago


    I didn’t write the distanceBetween function, but I’m pretty sure that it does account for curvature. That is, I doubt whether the distance from New York to Moscow is calculated along the straight line through the center of the earth. It surely is the great circle.

  15. Mikal

    2 months ago

    @Chris, can you dump the raw data that your device is sending? Try Serial.write(c) for each c that comes from the device.

  16. Mikal

    2 months ago

    @Yaron, sorry for the slow reply.

    Yes! Do this C++ trick when you want to reset your TinyGPS[++] object:

    TinyGPSPlus gps;
    gps = TinyGPSPlus(); // reinitialize

  17. Mikal

    2 months ago

    @alessandro, I’ve never heard of any way to calibrate your ordinary over-the-counter GPS modules. Sorry!

  18. Mikal

    2 months ago

    @Stefan, the method for acquiring data from the GPS module didn’t change, so if you’re getting “No characters received”, I feel pretty sure that you are not using the right port or the correct software serial pins. Can you check to make sure they are the same as in the v12 sketch that’s working?

  19. Mikal

    2 months ago

    @Juan Domingo,

    Thank you very much for that clear explanation. I think I will have to incorporate this GLONASS stuff in the near future, and you have helped me figure out how to do it. Thanks

  20. Mikal

    2 months ago


    Yeah, the Arduino printing facility is (necessarily) quite limited. What I end up doing is something like:

    if (gps.time.minute() < 10)

  21. Yaron

    2 months ago

    Hi Mikal,

    Thanks for the reply. I’ll give it a try!

    I also wanted to know if there’s a way to turn the gps off thru the software alone?
    My up501 gps module is connected directly to the 5V pin on the arduino mega and i want it to turn on once every 15 minutes, get valid data, and than turn off again. Is that possible by code?

    Thank you

  22. Jay

    2 months ago

    Hi Mikal,

    Thanks for the excellent TinyGPSplus library ! Just wondered if there is a feature to do a rolling average of the position latitude and longitude, over a specified number of readings to get a stable position. The number of readings could be variable to either speed up or slow down the response. Thanks!

  23. user

    2 months ago

    Is it also possible to use the tinyGPS++ with hardware serial port?
    and how?

  24. Mikal

    2 months ago

    @Jay, that rolling average feature would be useful, but I don’t think it’s quite compelling enough to put into the library. I can see that it would compensate for any minor inaccuracies, but another way to do this is to examine the number of satellites, and generate position data only when there are at least, say, 6 satellites being used.

  25. Mikal

    2 months ago


    Yes, it’s pretty easy. Basically you just replace all the “ss” in the examples with “Serial” or “Serial1″.

  26. Jay

    2 months ago

    Thanks for the reply. I tried to implement a rolling/ smoothing code, but it seems that I can’t pick up the data that the TinyGPS++ extracts.

    For example (based on Arduino smoothing example):

    TinyGPSCustom rawlat (gps, “GPGGA”, 2); // extract raw Lat
    void loop() {

    total= total – readings[readIndex]; // subtract the last reading:

    readings[readIndex] = rawlat; //read in extracted rawlat reading = numReadings) // if we’re at the end of the array…

    readIndex = 0; // …wrap around to the beginning:

    average = total / numReadings; // calculate the average:

    Serial.println(average); // print the average

    So trying to use rawlat doesn’t work ! Compilation error. Any suggestions/ help much appreciated!! Many thanks!

  27. Practical_Pirate

    2 months ago

    Thought you would like to be aware of an open source marine data
    infrastructure (NMEA etc.) consortium that is coalescing on Github/google groups.

    The base website is http://www.SignalK.com . A good
    article from Bill Bishop on Panbo: http://www.panbo.com/archives/2014/11/signal_k_a_true_game_changer_.html

    Some of the conversation on google groups is focused on navigation and
    crowdsourced data and your expertise at fiddling and inventiveness suggest to me you might be able (and willing) to contribute to the conversation.

  28. Nikos

    2 months ago

    Hi Mikal..Thank you for your great work.
    I’m runing your library in a NEOV2 Gps like this one


    but i’m taking Checksum fail errors..
    4 OR 5 in every loop when runing the FullExample.

    Any idea why ?

    Thank you once again.

  29. Mikal

    2 months ago

    @Nikos, what’s the baud rate on that device?

  30. Rob

    1 month ago

    Mikal – Just wanted to thank you for all your effort on this. The TinyGPS library was great, but I think you’ve managed to make it better with TinyGPS++! I’m using it on an E-Traxx based robot and it works great. Thank you again.

  31. Mikal

    1 month ago

    @Rob, hey thanks for the nice words.

  32. Arion

    1 month ago


    Thanks for the previous reply. I have another question. I am trying to get the GPGSV satellite data using TinyGPSCustom objects. There are usually multiple sentences starting with $GPGSV depending on the number of satellites. I cannot read each sentence individually with my custom objects.
    TinyGPSCustom messageNumber1(gps, “GPGSV”, 2);
    TinyGPSCustom messageNumber2(gps, “GPGSV”, 2);
    TinyGPSCustom messageNumber3(gps, “GPGSV”, 2);

    All I get is the last sentence value every time. For example, if there are 3 GPGSV sentences, I get 3 each time instead of 1, 2, 3. I am using the second parameter for now as I am just trying to get the sentences separated so I can read them individually. My goal is to create a visual representation of where the satellites are in the sky using the elevation and azimuth data from these sentences (like the view in this link http://www.ka2ddo.org/ka2ddo/YAACdocs/viewgps.html). Any help would be greatly appreciated. Thanks again!


  33. christian

    4 weeks ago

    Hey Mikal,

    Thanks for sharing the Library. I have a question about the course_to feature of the TinyGPS, sometimes it gives me the right degrees, and sometimes it doesn’t. Any inputs as to why this happens?


  34. Craig Swanson

    3 weeks ago

    In one comment it was said that a Due or processor which can take advantage of the higher precision of 64-bit “double” floating-point is needed for TinyGPS+. Were you refering to hard or soft float? Im only asking because im not seeing any mention of an fpu in these arduino chips. Im interested in using this on a mips based soc but knowing if this is hard or soft float is important. Thank you ever so much


  35. MPCadosch

    3 weeks ago

    @Mikal and @Chris, did you ever figure out how to use it with the uBlox LEA?


  36. sv650s

    3 weeks ago

    i try to take latitude, longitude, altitude and satellites number but for the 2 last this doesn’t work ….
    the values are at 0 for altitude and satellites….
    i have an arduino mega 2560 with a GPS U-Blox-7N
    i have already imported the TinyGPSPlus in my arduino
    this is my code :


    static const int RXPin = 12, TXPin = 11;
    static const uint32_t GPSBaud = 9600;

    // The TinyGPS++ object
    TinyGPSPlus gps;

    // The serial connection to the GPS device
    SoftwareSerial ss(RXPin, TXPin);

    void setup()

    void loop()
    while (ss.available() > 0)
    if (gps.encode(ss.read()))

    if (millis() > 5000 && gps.charsProcessed() < 10)
    Serial.println(F("No GPS detected: check wiring."));

    void displayInfo()

    if (gps.location.isValid())
    Serial.print(F("Location: "));
    Serial.print(gps.location.lat(), 6);
    Serial.print(gps.location.lng(), 6);
    Serial.print(F("Altitude: "));
    Serial.print(F("Satellites: "));


  37. Ahmad

    2 weeks ago

    Hi Mikal,

    I had a GPS module GP 635T connected to Arduino Uno on pin 3,2.

    I used the following program:

    I works perfectly when I walk.
    But it doesn't work when I tried to test it in the car.

    Any Recommend?

  38. Mikal

    2 weeks ago

    @Craig Swanson,

    I don’t think that that comment was referring to how the floating point calculations were performed, i.e. in hardware vs. microcode vs. software emulation, just that on many modern microcontrollers the precision is much higher–64 vs. 32 bits. The original TinyGPS didn’t make use of double, so couldn’t take advantage of the higher precision offered by these controllers.

  39. Mikal

    2 weeks ago

    @sv650s, could you reproduce a short 10-15 line sample of the stream coming in on the serial port?

  40. Mikal

    2 weeks ago


    What kind of problems are you having?

  41. Beat

    6 days ago

    Hi Mikal,
    I am not sure, but the validity of custom sentence is always true?
    $IIMWV,338.0,R,044.0,M,V*21 flags void.

    TinyGPSCustom wind_dir(gps, “IIMWV”, 1);
    TinyGPSCustom wind_speed(gps, “IIMWV”, 3);

    (wind_speed.isValid()) is always ok.
    Now i handle it as custom field itself.
    TinyGPSCustom wind_valid(gps, “IIMWV”, 5);

  42. Beat

    5 days ago

    Upps, found it in the for me not relevant “Establishing a fix” Section (Because i use no GPS)

    For built-in (non-custom) objects, the NMEA sentences must self-report themselves as valid. That is, 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 the position and altitude information is discarded (though time and date are retained).

    But Maybe this could be configurable too..?

9 Trackbacks For This Post
  1. TinyGPS++ to the Rescue | Stainless Steelhead

    [...] to the brains behind Arduiniana, Mikal Hart, Poolbot has moved to the brand-new GPS library set, TinyGPS++.  This saved enormous time in developing custom code to process and check the validity of NMEA [...]

  2. Antenna tracker, first steps | kolin's

    [...] or none, I made simple arduino program for parsing NMEA crap and encoding it in LTM packets. I used TinyGPS++ library for parsing NMEA and few lines from TauLabs [...]

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

    [...] Descarcati biblioteca tinyGPS sau tinyGPS++. [...]

  4. GPS-Logger | Pascal's Königreich

    [...] Card Breakout Board gibt’s bei Adafruit, um mit dem GPS Modul zu sprechen wurde die Library TinyGPS++ [...]

  5. GPS Distance Calculator (for golf) -Use Arduino for Projects

    [...] Tiny GPS++ [...]

  6. Arduino GPS with OLED Display | Home of Benty

    [...] OLED from Adafruit. It’s still a work in progress just squishing together code from the TinyGPS++ library and using the Adafruit GFX [...]

  7. SpainLabs - Mantener tus proyectos en hora

    [...] Con Arduino puedes usar la librería tyniGPS++. [...]

  8. Prototype 1 – GPS Module | A Mean Center

    [...] something useful with it. This isn’t due to any competence on my part, but because of  the TinyGPS++ library by Mikal Hart which is just amazing. There are many examples included with the library, so it is [...]

  9. Unexpected behavior of sprintf with i32/u32 | CL-UAT

    [...] trying to build a string of characters from several elements given by the TinyGPS++ library with the use of [...]

Leave a Reply