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.


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();


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!");
  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.


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.


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
700 Responses → “TinyGPS”

  1. Mike

    6 years ago

    Hi Mikal,
    Probably easy for you. I have downloaded TinyGPS a couple of times, but when I compile it flags TinyGPS gps;

    10 error: ‘TinyGPS’ does not name a type

    All references to TinyGPS are also flagged. I am at a loss as to the reason.

    I placed the TinyGPS folder to the Aurdini program library and loaded it as an example. All the examples will not compile.

    What have I done wrong?

  2. Mikal

    6 years ago

    @Mike, That probably indicates an installation problem. Make sure that in your Arduino/libraries folder there is a folder called TinyGPS, that is, at the same level as EEPROM and LiquidCrystal and SoftwareSerial. And inside that folder are TinyGPS.cpp and TinyGPS.h.

  3. Jerry

    6 years ago

    Hi Mikal.
    Quick question.
    I ran your example code with my gps hooked to arduino mega and it works great.
    The only issue is the time of day that i get from the gps which is wrong – it’s 3 hours earlier then my current time (it shows the time is 3p.m when it’s actually 6 p.m).
    How do i fix that?



  4. Mikal

    6 years ago

    Hi Jerry–

    GPS time is always reported in UTC (Universal Coordinated Time), no matter where your location is. If you know that your location will always be UTC + 3, a simple fix is to just add 3. Make sense?

  5. Paolo

    6 years ago

    Hello Michal, I use your library, it is fantastic. I used Arduino one and ublox 5 to 4Hz at 38400 baud and worked perfectly. For memory problems I switched to ‘arduino mega. I’ve tried both with software serial (pin 10 and 11) with both Serial1 and once every 2 seconds I lose a reading. can you help me, thanks

  6. Mikal

    6 years ago

    Hi Paolo,

    Can you define what you mean by “Lose a reading”? Are you getting checksum errors? Are you suggesting that you are experiencing a new failure tied to the move to Mega?

  7. Paolo

    6 years ago

    yes, on arduino One everything worked. now loses a reading of 1/250 s approximately every 2 sec.

  8. Mikal

    6 years ago


    I still don’t understand what “lose a reading” means. What problem are you seeing in TinyGPS? Checksum errors?

  9. Paolo

    6 years ago

    Thank you, i don’t know if checksum error because on arduino one it is all ok. this is what serial read:

    and this is time output of tiny libary


  10. Mikal

    6 years ago


    I don’t think that input stream generated the output you list. TinyGPS doesn’t understand $PUBX sentences.

    Can you please check the statistics to see whether you are getting checksum errors?

  11. Paolo

    6 years ago

    Sorry Pubx output arrived from your library modify. this output is generate from your originaly library with $gprmc sentence from your example with gps . no error checksum but sometimes repeate , like first and last row in this example

    Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum
    (deg) (deg) Age Age (m) — from GPS —- —- to London —- RX RX Fail

    **** **** 45.478351 7.811578 23 10/09/2013 16:05:41.00 25 ****** 162.60 0.02 SSE 889 321.81 NW 1508 22 0
    **** **** 45.478351 7.811578 232 10/09/2013 16:05:41.00 234 ****** 162.60 0.02 SSE 889 321.81 NW 1508 22 0
    **** **** 45.478351 7.811578 197 10/09/2013 16:05:41.25 200 ****** 162.60 0.02 SSE 889 321.81 NW 1576 23 0
    **** **** 45.478351 7.811578 183 10/09/2013 16:05:41.50 186 ****** 162.60 0.28 SSE 889 321.81 NW 1644 24 0
    **** **** 45.478351 7.811577 152 10/09/2013 16:05:41.75 154 ****** 162.60 0.30 SSE 889 321.81 NW 1712 25 0
    **** **** 45.478351 7.811577 138 10/09/2013 16:05:42.00 140 ****** 162.60 0.04 SSE 889 321.81 NW 1780 26 0
    **** **** 45.478351 7.811577 102 10/09/2013 16:05:42.25 105 ****** 162.60 0.09 SSE 889 321.81 NW 1848 27 0
    **** **** 45.478351 7.811576 89 10/09/2013 16:05:42.50 93 ****** 162.60 0.15 SSE 889 321.81 NW 1916 28 0
    **** **** 45.478351 7.811576 58 10/09/2013 16:05:42.75 61 ****** 162.60 0.04 SSE 889 321.81 NW 1984 29 0
    **** **** 45.478351 7.811576 45 10/09/2013 16:05:43.00 48 ****** 162.60 0.30 SSE 889 321.81 NW 2052 30 0
    **** **** 45.478351 7.811576 12 10/09/2013 16:05:43.25 14 ****** 162.60 0.13 SSE 889 321.81 NW 2120 31 0
    **** **** 45.478351 7.811576 221 10/09/2013 16:05:43.50 4 ****** 158.96 0.41 SSE 889 321.81 NW 2194 32 0
    **** **** 45.478351 7.811576 210 10/09/2013 16:05:43.50 213 ****** 158.96 0.41 SSE 889 321.81 NW 2194 32 0

  12. Rodrigo

    6 years ago

    Hi.. I can read from a simple serial port.. The results that I have is:

    But when I run TinyGPS it doesn’t return the coordinates.. just ****** ***** the only info that I am receiving is:

    Testing TinyGPS library v. 13
    by Mikal Hart

    Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum
    (deg) (deg) Age Age (m) — from GPS —- —- to London —- RX RX Fail
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 0 0 0
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 64 0 0
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 129 0 0
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 193 0 0
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 257 0 0
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 386 0 0
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 451 0 0

    Only these CHARS RX.

    Any IDea about what could be wrong?

  13. Mikal

    6 years ago


    Yeah, if that is an example of what you are receiving, the checksum field is wrong. Every sentence must end with a valid checksum (and a newline), otherwise, TinyGPS discards it. This behavior is exactly what I’d expect.

    What generated that string of characters?

  14. Michel

    6 years ago

    merci, c’est vraiment le bout de programme que je rechercher, télécharger, téléverser et ça marche impeccable. :)

  15. Mikal

    6 years ago

    Merci bien! :)

  16. Alejandro

    6 years ago

    Hey Mikal! I;m receiving these output from the sample code that came along with the tinyGPS library. Do you have any solutions? I don’t know what generated that string of characters…

    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 36 0 0
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 182 0 0
    **** **** ********* ********** **** ********** ******** **** ****** ****** ***** *** ******* ****** *** 328 0 0

  17. Mikal

    6 years ago


    It looks like you are getting characters but no valid sentences. My guess is that the baud rate is incorrect or the module has been configured to some strange “binary” mode. Best way to tell is to print out the characters as they arrive with Serial.write(c).

  18. Rodrigo

    6 years ago

    Hi, Mikal. You know whta I did? I Justr bought another device because after almost 3 weeks I cant make the Itead Studio 1.1 working on TinyGPS.

    Now I have 2 GPS shields and both doesn’t work.

    Well.. I Would really apreciate your help.

    Here is what I get when I run the Simple test:

    My gps baud rate is 38400 and I am connecting the Serial at 115200.

    Simple TinyGPS library v. 13
    by Mikal Hart


    Thats What I receive when run the TEST_WITH_GPS:

    Course Card Chars Sentences Checksum
    (starts only)…****** *** 0 0 0
    (starts only)…****** *** 64 0 0
    (starts only)…****** *** 129 0 0

    I can wait for 1 hour or more and still no data.. only stars and the unic change is the CHAR value…(starts from 0 and increses)

    When I print the serial, I get:

    Goodnight moon!


    Could yuou help me?

    Thabk you very very much:)


  19. Mikal

    6 years ago


    Somehow your sentences are malformed. The mandatory checksum and line feed are not being processed/printed. Per http://aprs.gids.nl/nmea/#rmc, the GPRMC sentence looks like this:


    225446 Time of fix 22:54:46 UTC
    A Navigation receiver warning A = OK, V = warning
    4916.45,N Latitude 49 deg. 16.45 min North
    12311.12,W Longitude 123 deg. 11.12 min West
    000.5 Speed over ground, Knots
    054.7 Course Made Good, True
    191194 Date of fix 19 November 1994
    020.3,E Magnetic variation 20.3 deg East
    *68 mandatory checksum

    But your sentence looks like


    Comparing the two, you’ll see the checksum (*68) is missing:
    $GPRMC,225446, A,4916.45, N,12311.12, W,000.5,054.7,191194,020.3,E*68
    $GPRMC,012725.00,A,2306.59334,S,04633.26616,W,0.055, ,311013, , ,D

    TinyGPS[++] must have a valid checksum and a line terminator to work.

  20. John

    6 years ago

    Hi Mikal. I am facing the same issue as Rodrigo. What could be causing the invalid checksum and the lack of line terminators? What can i do to get TinyGps working with GPRMC sentences such as Rodrigo’s?

  21. Mikal

    6 years ago


    I don’t know. It seems unlikely that the device really departs from the NMEA standard in such an egregious way. Best guess is that the software serial library is having a hard time processing the (relatively) fast 38.4K baud rate. Can you experiment with a slower rate, or perhaps hook the GPS device temporarily to a hardware serial port?

  22. Jon

    6 years ago

    Hi Mikal,

    Thanks for creating the library, its great!

    Had a quick question though, I am trying to get as accurate a time as possible. The Hundredths value is always 0. Is there a way to get the hundredths value to be non zero – say to 3 digits?

  23. Mikal

    6 years ago

    Hi Jon,

    I fear the answer is to get a different GPS module. Most of the modules I have had the opportunity to play with report 2 decimal digits for seconds, but these are always .00. Does anyone know of a module that produces non-zero values here?

  24. Jon

    6 years ago

    Hi Mikal,

    Thanks for the reply. That option only really dawned on me now. Guess it makes sense.

  25. shivanshu

    6 years ago

    Hello Mikal,
    I am new in arduino and currently i m using arduino uno board with a combo GSM/GPRS GPS Module. I don’t know how to start doing a programming for my micro controller using Arduino IDE.
    I have downloaded and installed all the three libraries NewSoftSerial, PString and TinyGPS, all three library also showing in the list of Import Library List but in TinyGPS library is not showing in Examples List.

    Kindly help me out in doing this please tell me which version of IDE i have to use as I have two IDE in my PC Arduino1.0.5 and Arduino 0022.

    Thanks in advance!

  26. Mikal

    6 years ago

    Hi Shivanshu,

    PString and TinyGPS work in all versions of Arduino. NewSoftSerial should not be used in versions >= 1.00, because the NewSoftSerial library has been incorporated into the Arduino IDE as SoftwareSerial.

    When successfully installed, there should be a TinyGPS folder on your computer at the same level as, say, LiquidCrystal. You may need to restart the Arduino IDE to see the examples.

  27. shivanshu

    6 years ago

    Thanks Mikal for the reply.

    Currently i am using three liabraries viz, TinyGPS, SoftSerial, PString. Both the three libraries are compiling properly.

    My question is if i have to send GPS data to any server through GPRS then what code i have to use for it?


  28. William Lynn

    6 years ago


    I’ trying to get EPOCH numbers for time and date using TinyGPS with but when I call NOW()after gps.crack_datetime(xxxxx); it returns a incorrect value. I can get it to work in your example test_with_gps. Can give a little insight on how NOW() reads the time generated by TinyGPS.

    Bill Lynn

  29. Mikal

    6 years ago

    Hi Bill–

    Sorry, I’m afraid I don’t know anything about EPOCH and NOW. Are these part of a different library? They’re not part of TinyGPS. Perhaps if you point to where they come from I can make some guesses?

  30. William Lynn

    6 years ago


    EPOCH is time in seconds since 1970

    NOW() is a function in the Time.h library that returns time as EPOCH.

    I trying to add start and stop times to the puzzle box; GREAT PRODUCT by the way.

    Will TinyGPS++ work with the puzzlebox sketch; I sure there has to be some tweeking.


  31. William Lynn

    6 years ago


    Got TinyGPSPlus running in the puzzle box but still struggling with EPOCH and Time.h

    TinyGPSPlus is a tremendous improvement over TinyGPS.


  32. Fernando

    6 years ago

    Hey guys
    I have a question.
    I saw this receiver only have 4 wire cable?
    How to connect with the arduino?
    just VCC GND RX TX?
    or it need other modules?

  33. Martin

    6 years ago


    I’m unable to get TinyGPS to communicate with my Adafruit ultimate GPS. If I use an Adafruit example sketch it works perfectly, but if I upload a TinyGPS example (same softserial pins) it says that there’s no GPS and to check wiring. Switch back to Adafruit and it works.
    Can you help? I really want to be able to use TinyGPS


  34. Mikal

    6 years ago


    Some GPS modules provide other signals, but yes, those are the basic four.

  35. Mikal

    6 years ago

    Hi Martin,

    Are you running the simple_test example?

    You get that “wiring” check only if the TinyGPS object has not been fed characters, so I’m guessing either the software serial pins have flipped, or something? If you uncomment this line, you can actually watch the characters flow by:

          // Serial.write(c); // uncomment this line if you want to see the GPS data flowing

    Let’s figure this out?

  36. Martin

    6 years ago

    Hi Mikal,

    With simple_test I get “** no characters received from GPS: check wiring **”

    With test_with_GPS_device I get “**** ***** **** 0 0 0″

    When the Adafruit parsing sketch defines the pins using SoftwareSerial it defines the RX and TX reversed. I.e (tx, rx) where your sketch is (rx, tx)
    So I altered your sketch to match the Adafruit parsing sketch and now when I open serial monitor I get “**** *** *** 81 0 6″ etc etc..

    Then I realised the Adafruit GPS communicates at 9600 baud!
    Changed ss.begin(4800) to ss.begin(9600) et voila! It works!

    So I went back to the SoftSerial and flipped the pins back to (rx, tx) and it doesn’t work again..


  37. Martin

    6 years ago

    So.. To summarise..

    I connect rx to tx and tx to rx and change baud from 4800 to 9600 it works perfectly.

    Why the difference between Adafruit sketch and TinyGPS sketch regarding rx and tx?


  38. Mikal

    6 years ago


    In SoftwareSerial, the first parameter in the constructor is ALWAYS RX. I’m sure if you look closer you’ll see that there is no difference between Adafruit’s and TinyGPS’s examples. Don’t be confused by the fact that the line that is RX from the Arduino’s point of view is labeled TX on most GPS modules. That’s TX from the module’s point of view.

  39. Martin

    6 years ago

    Good Morning Mikal,
    You are correct! I’d had never thought of it that way! :)

    So the pins marked rx and tx on the Adafruit ultimate GPS module are actually the GPS modules tx and rx!

    So happy its working now, I’m now using Tinygps++ and it is brilliant. Many thanks.

  40. Fernando

    6 years ago

    Hello Mikal
    I still don’t know how does it work(Model A).
    The connection:
    I connect red to VCC; thin black to GND;white to “3″;thick black to “4″
    Then I got this when I use simple code:
    When I use “test with gps device”, I got “**** ***** **** 0 0 0″the last three number is always 0.
    I am inside.

    I saw what I got looks like Martin’s
    But I have a little words can’t understand.He connect GPS Rx to which Tx? Serial port or Softwareserial port? And it is (rx,tx) or (tx rx)?

    Thank you in advance

  41. Fernando

    6 years ago

    Oh! My connection was wrong.
    black is TX; white is RX;
    But I still can’t get the data.the only change is “chars” is increasing.
    test with gps device:”****** *** 9209 0 0″

  42. Mikal

    6 years ago

    @Fernando, perhaps your baud rate is wrong? The sample code uses 4800 as a common default, but there are many devices out there that work at higher rates.

    It’s a good debug technique to print out the characters as they arrive just to see if they look reasonable:

    char c = ss.read();

  43. Amin

    6 years ago

    Does anyone know if there is any C library for this sensor?
    I’d like top integrate it to CoIDE/Coocox for stm32f4.

  44. Mikal

    6 years ago


    This library isn’t tied to any particular sensor. It’s a generic NMEA GPS parsing library. It’s only thinly tied to Arduino (via the dependence on millis()), and could be ported to C fairly easily.

  45. Fernando

    6 years ago

    Thanks replay
    I have changed the “ss” baud rate to 9600/38400 But nothing change
    The only device I used is just the GPS module and an arduino uno
    Did I miss something?
    Thank you in advance.

  46. Mulham Harrasi

    6 years ago

    hello guys,
    I need HELP to program Arduino to get Lat and Long from GPS em406 with the following parts: EM406 GPS without shield, Arduino UNO,LCD 18×2, potentiometre and circuit board.

    My question: can I use GPS with out SD shield??

    Urgent please !!

  47. John

    6 years ago

    Hello, I am having a problem with this code. My IDE keeps giving me errors compiling. Last one was, “expected constructor, destructor or type conversion before ” token” I have added the library as required. From the IDE, I can see it in the File > Examples. However, from C: drive, it was not there. So I added it manually. To begin with, it would not add it to library because of dash character. I had to rename it just to get it to add. My version of Arduino IDE is 1.0.5. Any help is greatly appreciated. Thank you.

  48. Pete

    6 years ago

    I am using a ITEAD studio GPS shield V1.1 with an Arduino Uno R3. Both are recent purchases.
    I am using the code:



    /* This sample code demonstrates the normal use of a TinyGPS object.
    It requires the use of SoftwareSerial, and assumes that you have a
    4800-baud serial GPS device hooked up on pins 3(rx) and 4(tx).

    TinyGPS gps;
    SoftwareSerial ss(3,4);

    void setup()

    Serial.print(“Simple TinyGPS library v. “); Serial.println(TinyGPS::library_version());
    Serial.println(“by Mikal Hart”);

    void loop()
    bool newData = false;
    unsigned long chars;
    unsigned short sentences, failed;

    // For one second we parse GPS data and report some key values
    for (unsigned long start = millis(); millis() – start < 1000;)
    while (ss.available())
    char c = ss.read();
    Serial.write(c); // uncomment this line if you want to see the GPS data flowing
    if (gps.encode(c)) // Did a new valid sentence come in?
    newData = true;

    if (newData)
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    Serial.print(" LON=");
    Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    Serial.print(" SAT=");
    Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
    Serial.print(" PREC=");
    Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());

    gps.stats(&chars, &sentences, &failed);
    Serial.print(" CHARS=");
    Serial.print(" SENTENCES=");
    Serial.print(" CSUM ERR=");

    It took a while, but I figured out the RX, TX numbers had to be from the perspective of the Uno – so mine are (3,4).
    I also found that the GPS shield wishes to communicate at 38,400 BPS.
    The antenna is outdoors and has an unobstructed view of the sky. The output below was obtained after a 30 minute period.

    When set this way, I do get output, but not correct sentences. By adding the Serial.write (c) line, I can list the output, which seems to lack the checksum and occasionally the terminating CR, I think. There is only one sentence type ($GPRMC) received. Is this normal? Does it indicate no fix?

    Any help solving the problem would be appreciated.

    Here's a sample of the output:

    Simple TinyGPS library v. 13
    by Mikal Hart

    $GPRMC,182149.00,A,4308.16235,N,07344.93820,W,0.010,,010114,,,D1L CHARS=65 SENTENCES=0 CSUM ERR=0
    $GPRMC,182150.00,A,4308.16242,N,07344.93820,W,0.010,,010114,,,D61$GPRMC,182151.00,A,4308.16247,N,07344.93819,W,0.039,,010114,,,D4 CHARS=194 SENTENCES=0 CSUM ERR=0
    $GPRMC,182152.00,A,4308.16257,N,07344.93821,W,0.025,,010114,,,D, CHARS=258 SENTENCES=0 CSUM ERR=0
    $GPRMC,182153.00,A,4308.16264,N,07344.93822,W,0.021,,010114,,,D, CHARS=322 SENTENCES=0 CSUM ERR=0
    $GPRMC,182154.00,A,4308.16270,N,07344.93822,W,0.005,,010114,,,D, CHARS=386 SENTENCES=0 CSUM ERR=0
    $GPRMC,182156.00,A,4308.16279,N,07344.93827,W,0.011,,010114,,,DD4 CHARS=516 SENTENCES=0 CSUM ERR=0
    $GPRMC,182157.00,A,4308.16286,N,07344.93834,W,0.020,,010114,,,D33$GPRMC,182158.00,A,4308.16290,N,07344.93836,W,0.023,,010114,,,D24 CHARS=646 SENTENCES=0 CSUM ERR=0
    $GPRMC,182159.00,A,4308.16291,N,07344.93831,W,0.057,,010114,,,D2 CHARS=710 SENTENCES=0 CSUM ERR=0
    $GPRMC,182200.00,A,4308.16289,N,07344.93826,W,0.036,,010114,,,D01 CHARS=775 SENTENCES=0 CSUM ERR=0
    $GPRMC,182201.00,A,4308.16287,N,07344.93822,W,0.014,,010114,,,DV CHARS=839 SENTENCES=0 CSUM ERR=0
    $GPRMC,182202.00,A,4308.16284,N,07344.93818,W,0.013,,010114,,,D, CHARS=903 SENTENCES=0 CSUM ERR=0
    $GPRMC,182203.00,A,4308.16280,N,07344.93814,W,0.010,,010114,,,D01$GPRMC,182204.00,A,4308.16274,N,07344.93808,W,0.040,,010114,,,D61 CHARS=1033 SENTENCES=0 CSUM ERR=0
    $GPRMC,182205.00,A,4308.16265,N,07344.93804,W,0.034,,010114,,,D2 CHARS=1097 SENTENCES=0 CSUM ERR=0
    $GPRMC,182206.00,A,4308.16258,N,07344.93801,W,0.038,,010114,,,D6L CHARS=1162 SENTENCES=0 CSUM ERR=0
    $GPRMC,182207.00,A,4308.16250,N,07344.93797,W,0.022,,010114,,,D0A CHARS=1227 SENTENCES=0 CSUM ERR=0

  49. Mikal

    6 years ago

    @Mulham Harrasi,

    All you need to get the EM406 to work is 4 connections to the Arduino: +5V and GND, then two pins for TX and RX. No shield required if you can manage to connect to the tiny connector on the GPS module.

  50. Mikal

    6 years ago


    Yeah, it’s annoying that a github archive necessarily has a dash in the name, but an Arduino library must NOT have one. But if you unzip it, rename it simply to “TinyGPSPlus”, then place that folder under the “libraries” folder, i.e. at the same level as, say, LiquidCrystal, you should be good.

81 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 [...]

Leave a Reply