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. Mikal

    11 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);
      }
    }
    

  2. Abhishek Nandwana

    11 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.


  3. Mikal

    11 years ago

    @Abhishek,

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


  4. 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


  5. Mikal

    10 years ago

    @Bernhard,

    See my response on TinyGPS++.


  6. Mike

    10 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?
    Regards,
    Mike


  7. Mikal

    10 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.


  8. Jerry

    10 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?

    Thanks

    Jerry


  9. Mikal

    10 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?


  10. Paolo

    10 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


  11. Mikal

    10 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?


  12. Paolo

    10 years ago

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


  13. Mikal

    10 years ago

    @Paolo,

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


  14. Paolo

    10 years ago

    Thank you, i don’t know if checksum error because on arduino one it is all ok. this is what serial read:
    $PUBX,00,140406.00,4528.69702,N,00748.70571,E,387.949,D3,4.7,4.5,0.310,100.90,-0.036,0.0,1.00,1.21,0.86,11,0,0*51
    $PUBX,00,140406.25,4528.69699,N,00748.70558,E,387.682,D3,4.7,4.5,0.114,100.90,-0.015,0.0,1.00,1.21,0.86,11,0,0*51
    $PUBX,00,140406.50,4528.69697,N,00748.70545,E,387.429,D3,4.7,4.4,0.332,100.90,0.008,0.0,1.00,1.21,0.86,11,0,0*74
    $PUBX,00,140406.75,4528.69694,N,00748.70541,E,387.258,D3,4.7,4.4,0.225,100.90,0.020,0.0,0.96,1.17,0.82,11,0,0*76
    $PUBX,00,140407.00,4528.69690,N,00748.70535,E,387.083,D3,4.7,4.4,0.455,90.18,0.039,0.0,1.00,1.21,0.86,11,0,0*48
    $PUBX,00,140407.25,4528.69687,N,00748.70528,E,386.904,D3,4.7,4.4,0.362,79.38,0.052,0.0,1.00,1.21,0.86,11,0,0*49

    and this is time output of tiny libary

    14:06:49.75
    14:06:50.00
    14:06:50.50
    14:06:50.75
    14:06:51.25
    14:06:51.75
    14:06:52.00
    14:06:52.50
    14:06:52.75
    14:06:53.25
    14:06:53.75
    14:06:54.00
    14:06:54.50
    14:06:54.75
    14:06:55.25
    14:06:55.75
    14:06:56.00


  15. Mikal

    10 years ago

    @Paolo,

    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?


  16. Paolo

    10 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


  17. Rodrigo

    10 years ago

    Hi.. I can read from a simple serial port.. The results that I have is:
    $GPRMC,223731.00,A,2307.08381,S,04633.21320,W,0.006,,251013,,,A

    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?


  18. Mikal

    10 years ago

    @Rodrigo,

    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?


  19. Michel

    10 years ago

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


  20. Mikal

    10 years ago

    @Michel–
    Merci bien! :)


  21. Alejandro

    10 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


  22. Mikal

    10 years ago

    @Alejandro,

    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).


  23. Rodrigo

    10 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

    CHARS=64 SENTENCES=0 CSUM ERR=0
    CHARS=128 SENTENCES=0 CSUM ERR=0
    CHARS=256 SENTENCES=0 CSUM ERR=0
    CHARS=320 SENTENCES=0 CSUM ERR=0
    CHARS=384 SENTENCES=0 CSUM ERR=0
    CHARS=448 SENTENCES=0 CSUM ERR=0
    CHARS=512 SENTENCES=0 CSUM ERR=0
    CHARS=576 SENTENCES=0 CSUM ERR=0
    CHARS=640 SENTENCES=0 CSUM ERR=0
    CHARS=768 SENTENCES=0 CSUM ERR=0
    CHARS=832 SENTENCES=0 CSUM ERR=0
    CHARS=896 SENTENCES=0 CSUM ERR=0
    CHARS=960 SENTENCES=0 CSUM ERR=0

    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!

    $GPRMC,012725.00,A,2306.59334,S,04633.26616,W,0.055,,311013,,,DG,$GPRMC,012726.00,A,2306.59334,S,04633.26615,W,0.045,,311013,,,D
    5$GPRMC,012727.00,A,2306.59335,S,04633.26614,W,0.043,,311013,,,D,$GPRMC,012728.00,A,2306.59334,S,04633.26613,W,0.023,,311013,,,D,$GPRMC,012729.00,A,2306.59335,S,04633.26610,W,0.025,,311013,,,D1$GPRMC,012730.00,A,2306.59335,S,04633.26609,W,0.017,,311013,,,D5$GPRMC,012731.00,A,2306.59334,S,04633.26607,W,0.012,,311013,,,D,$GPRMC,012732.00,A,2306.59333,S,04633.26606,W,0.034,,311013,,,D*$GPRMC,012733.00,A,2306.59333,S,04633.26604,W,0.007,,311013,,,D4$GPRMC,012734.00,A,2306.59332,S,04633.26602,W,0.017,,311013,,,D$$GPRMC,012735.00,A,2306.59332,S,04633.26602,W,0.012,,311013,,,D3$GPRMC,012736.00,A,2306.59334,S,04633.26602,W,0.036,,311013,,,D$
    

    Could yuou help me?

    Thabk you very very much:)

    Rodrigo


  24. Mikal

    10 years ago

    @Rodrigo,

    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:

    $GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68

    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

    $GPRMC,012725.00,A,2306.59334,S,04633.26616,W,0.055,,311013,,,D

    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.


  25. John

    10 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?


  26. Mikal

    10 years ago

    @John,

    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?


  27. Jon

    10 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?


  28. Mikal

    10 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?


  29. Jon

    10 years ago

    Hi Mikal,

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


  30. shivanshu

    10 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!


  31. Mikal

    10 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.


  32. shivanshu

    10 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?

    Thanks


  33. William Lynn

    10 years ago

    Mikal;

    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


  34. Mikal

    10 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?


  35. William Lynn

    10 years ago

    Mikal,

    EPOCH is time in seconds since 1970
    http://www.esqsoft.com/javascript_examples/date-to-epoch.htm

    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.

    Bill


  36. William Lynn

    10 years ago

    Miklal:

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

    TinyGPSPlus is a tremendous improvement over TinyGPS.

    Bill


  37. Fernando

    10 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?


  38. Martin

    10 years ago

    Mikal,

    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

    Martin


  39. Mikal

    10 years ago

    @Fernando,

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


  40. Mikal

    10 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?


  41. Martin

    10 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..

    Interesting..


  42. Martin

    10 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?

    Martin


  43. Mikal

    10 years ago

    @Martin,

    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.


  44. Martin

    10 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.
    Martin


  45. Fernando

    10 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:
    “CHARS=12 SENTENCES=0 CSUM ERR=0”
    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


  46. Fernando

    10 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″

4 Trackbacks For This Post
  1. 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 […]

  2. 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 […]

  3. 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) […]

  4. Módulo GPS Skylab SKM53 | AUTOMALABS

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

Leave a Reply