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

    @Dorothee,

    Does the SparkFun shield deliver the serial data on pins 3 (RX) and 4 (TX)?


  2. j ferguson

    11 years ago

    I have just upgraded to rev 12. It supports my application, but I would like to use some of the built-in functions which i had to code myself for previous versions.

    But:

    I cannot compile simple_test.pde with Arduino 1.0.1 IDE running on Linux 12.04

    I get these errors:
    simple_test.cpp: In function ‘void loop()’:
    simple_test.cpp:50:26: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
    simple_test.cpp:52:26: error: ‘GPS_INVALID_F_ANGLE’ is not a member of ‘TinyGPS’
    simple_test.cpp:54:22: error: ‘class TinyGPS’ has no member named ‘satellites’
    simple_test.cpp:54:38: error: ‘GPS_INVALID_SATELLITES’ is not a member of ‘TinyGPS’
    simple_test.cpp:54:80: error: ‘class TinyGPS’ has no member named ‘satellites’
    simple_test.cpp:56:22: error: ‘class TinyGPS’ has no member named ‘hdop’
    simple_test.cpp:56:32: error: ‘GPS_INVALID_HDOP’ is not a member of ‘TinyGPS’
    simple_test.cpp:56:68: error: ‘class TinyGPS’ has no member named ‘hdop’

    I’d be happy to try any experiments you might recommend. i did try taking the if/else code out of TinyGPS.h and having #include “Arduino.h” as a separate line – but no joy.

    Are the examples known to work with rev 12?

    best regards,

    John ferguson


  3. Commuted

    11 years ago

    Is this the sirf3 chip? I have one and it outputs NMEA strings continuously. I’m not sure if it’s working. I thought I would need to poll it with strings like “GGA”. The PC software does not work either, but the time and location is correct.


  4. j ferguson

    11 years ago

    Hi Mikal,

    I was able to use distance_between function from my application perfectly,
    gps.distance_between(flat, flon, x2lat, x2lon) works great.

    but not gps.course_to(flat, flon, x2lat, x2lon).
    It gives this error:
    “_1gps_with_heading_serial_LCD_1d_1.cpp381:30: error: ‘class TinyGPS’ has no member named ‘course_to”

    I thought problem might be that somehow “course_to” was a protected name and changed the names in the library (both .cpp and .h files) to ‘bearingto’ but get same error. It is certainly in there and there is no spelling error, why can’t my sketch see it?

    As an aside. Yesterday, after interminable fussing with my code which reads a skylab SKM 53 (Mediatek 3329), which seemed to die after a few seconds and although emitting clock signals, and nmea sentences, quits indicating position changes if there isn’t much movement. It turns out that there is a speed threshold function built into the firmware which turns-off new position indications if the chip hasn’t moved faster than some threshold speed – default appears to be 2 M/sec. This is for use in cars and is intended to restrict display of position “hunting” when the car is parked. No good for use on anchored boat where movement is less than 2 M/sec. There is a command to reset threshold to lower speed or nothing.
    examples:
    $PMTK397,0.2*3F
    $PMTK397,2.0*3F
    first reset threshold to 0.2 m/sec, second to 2.0 m/sec.

    These cannot be written to flash so need to be added to startup.

    but then maybe you already knew about this.

    best regards, john ferguson


  5. Mikal

    11 years ago

    @j ferguson,

    The error messages you mention would suggest to me that you haven’t successfully put the new TinyGPS library in the right place. If your compiler knows you have a TinyGPS class, but you have “no member named ‘course_to’”, that means you’re using the older .h header file.


  6. Mikal

    11 years ago

    @Commuted,

    This software tries to be chip agnostic. If the chip generates $GPGGA and $GPGLL it should work. (But yes, I test with SIRF3.)


  7. j ferguson

    11 years ago

    Hi Mikal,
    my stupid mistake re: missing TinyGPS members was assuming that I could leave earlier TinyGPS library in place and just change folder name to TinyGPSorig without also changing the cpp and h names. I took it out altogether and now everything works fine.

    thanks for your very useful library. I especially appreciate having course_to and distance_between in the library so i can clean my application up a bit.

    now on to the challenge of controlling the minimum speed threshold on the mediatek 3329.

    very best regards, john


  8. j ferguson

    11 years ago

    Hi Mikal,
    I added two words to TinyGPS to make it possible to retrieve content of field 6 in GPGGA, which if non-zero shows data is good, but also shows whether it has DGPS or other correction – thus it is good to know if number was 1 or 2.

    I also added word for GPRMC field 12, which can show a bit more about how the GPS is getting data, in this case “A” for autonomous – good data but no correction, or “D” for DGPS correction which depending on chip, could be WAAS or one of European correction systems, or RTCM if that signal can be input into the chip. I think my Garmin 152H sends “W” if it is WAAS and “D” if it is RTCM from connected DGPS receiver.

    I don’t think it would be good to add these to your code, because i don’t think many other people would want this, but my question is:

    Doesn’t the size of Arduino compiled code depend on which things you’ve called from a library? In other words, if there are things in the library which you do not reference, your code will be no bigger because they are there.

    I know featuritis is a disease, but???


  9. chicodog530

    11 years ago

    Hi, I am trying to make a gps log data to an sd card.
    I have a duemilanove , pharos-gps500 sirf3 and a seeedstudio sd shield. I fly rc planes and want to log the speed and possibly altitude. I have been able to get the gps working with tinygps no problem. But I am lost on how to log the info it displays to my serial monitor on the sdshield. I have been searching online for several days with no luck. I have no prior programming experience. Is there any code out there that you know of that would help me along. Thanks


  10. Ph Dal

    11 years ago

    Hi,

    I’m testing the lib with the example on a ATMEL 2560, and a GP-2106 SiRF IV receiver, connected on Serial2. Compilation is fine, but the GPS seems to be dead, no valid printing is produced on Serial port. I checked with another test of mine, and the GPS does reply, so it is fine. Any hint?
    Thanks.
    Ph


  11. Mikal

    11 years ago

    j ferguson,

    I am eager to make some improvements to TinyGPS. You are correct that a function that is not called by any code is typically optimized away, but it’s hard to make completely independent (and therefore excisable) functions in a library like this.

    M


  12. Mikal

    11 years ago

    @Ph Dal,

    You might try looking at the TinyGPS::stats to see what clues it gives you to start with.


  13. Armand Aanekre

    11 years ago

    Hi Mikal
    I have problems retrieving data on my Arduino uno from my Eagle tree V4 GPS. It sends data at 38400 baud (verfied with oscilloscope, 5 Volts). Three strings: GPGGA @ 10Hz, GPRMC @ 10Hz and GPGSA @ 1 Hz.
    With a simple code using the RX pin (Pin 0) @ 38400 I get correct data as shown below:
    $GPGGA,213841.600,5938.6597,N,00938.6553,E,1,8,1.40,181.3,M,41.0,M,,*59
    $GPRMC,213841.600,A,5938.6597,N,00938.6553,E,0.01,171.12,220912,,,A*67
    $GPGGA,213841.700,5938.6597,N,00938.6553,E,1,8,1.40,181.3,M,41.0,M,,*58
    $GPRMC,213841.700,A,5938.6597,N,00938.6553,E,0.01,171.12,220912,,,A*66
    $GPGGA,213841.800,5938.6597,N,00938.6553,E,1,8,1.40,181.3,M,41.0,M,,*57
    $GPGSA,A,3,13,04,32,23,20,02,31,30,,,,,2.53,1.40,2.11*06
    $GPRMC,213841.800,A,5938.6597,N,00938.6553,E,0.01,171.12,220912,,,A*69

    I have changed the baudrate to this: nss.begin(38400)

    When running your example code, this is what I get.

    Testing TinyGPS library v. 12
    by Mikal Hart

    Sizeof(gpsobject) = 115

    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.00 *** 955 0 0
    **** **** ******* ******* **** ******* ******* **** ******* ****** ***** *** 0 0.00 *** 1911 0 0
    **** **** ******* ******* **** ******* ******* **** ******* ****** ***** *** 0 0.00 *** 2803 0 0
    **** **** ******* ******* **** ******* ******* **** ******* ****** ***** *** 0 0.00 *** 3696 0 0

    Any ideas about what is going on?


  14. Armand Aanekre

    11 years ago

    I removed the SoftSerial and used the “real” RX port to receive data and now it works. I also tried this simple code that should really only repeat the input and it seems that it works somehow, but there seems to be missing/erroneous data at the end of the GGA telegram sometimes.
    I guess Softserial is no good at 38400.. (Running arduino 1.0.1 on original Arduino UNO)

    This is the code I tested softserial with:

    #include
    SoftwareSerial mySerial(3, 4);
    void setup()
    {
    Serial.begin(57600);
    mySerial.begin(38400);
    }
    void loop()
    {
    if (mySerial.available())
    {
    Serial.write(mySerial.read());
    }
    }

    This is the result: (no lineshift either)

    $GPGGA,010034.600,5938.6576,N,00938.6540,E,1,9,0.90,175.8,M,41.E
    $GPGGA,010034.700,5938.6576,N,00938.6540,E,1,9,0.90,175.9,M,41.6
    $GPGGA,010034.800,5938.6576,N,00938.6540,E,1,9,0.90,175.9,M,41.,9
    $GPGGA,010034.900,5938.6576,N,00938.6540,E,1,9,0.90,175.9,M,41.5
    $GPGGA,010035.000,5938.6576,N,00


  15. Ivan Gustavo

    11 years ago

    To get more accurate precision of latitude and longitude, change the code of the function parse_degrees() to this:

    unsigned long TinyGPS::parse_degrees()
    {
    char *p;
    unsigned long left = gpsatol(_term);
    unsigned long tenk_minutes = (left % 100) * 100000;
    unsigned long grad = (left / 100) * 1000000;
    for (p=_term; gpsisdigit(*p); ++p);
    if (*p == ‘.’)
    tenk_minutes += gpsatol(++p);
    return grad + (tenk_minutes / 60);
    }


  16. btricha2

    11 years ago

    Hi Mikal,

    I was wondering if it is possible to get any raw data using TinyGPS, for example: pseudo range, or CF data, or anything that can be used in post processing to improve on the precision of the NMEA coordinates that many gps units like the EM406a put out.

  17. Hi Mikal, Excellent work on TinyGPS! I used it to win 3rd in the 2012 Sparkfun AVC! (Ported to mbed) I don’t know if I ever related to you an issue in parse_degrees() that I and another AVC competitor ran into. I hope this is of help — we both found that the routine was truncating digits from our NMEA sentences. Here’s my fix: http://pastebin.com/NcnR96T4 I increased the precision from 5 to 7 digits after the decimal. My GPS reports to 6 decimal places; I coded TinyGPS for 7 as I was under a deadline and didn’t want to have to fix it twice :) Email me if I can provide more info, etc. You can contact me on my blog website (bot-thoughts.com) Thanks –Michael


  18. Andrew

    11 years ago

    Hi
    Just wanted to say I am using your tinyGPS and absolutely love it.

    I am on train from Newcastle to London and been trying it out and now getting this data:

    Lat/Long: 52.637878,-0.335670
    Actual Course: 112.00
    Desiredcourse: 192.00
    rotationToTarget: 80.00
    Altitude: 20.20
    The distance to go: 126.572120
    Speed in kmph: 201.28

    The “target” is my home and as you can see we are travelling at 201km/h and “off target” by 80degrees

    Planning to use this to record where our next balloon goes:
    here is last one – but we dint know what altitude we reached.
    http://www.youtube.com/watch?v=sNmiiBJzdoc

    ANyway tinyGPS works brilliantly and i wanted to say a huge Thank you

    Andrew


  19. Robert Johnson

    11 years ago

    How can I convert the time and date data to simple variables? I need to use Time and Date for other functions as well. I doubt that sprintf will work for anything but printing a buffer. The attempt is to make a clock that will be delivered both by wire and radio for alarm and timing issues. For example one of it’s many task’s is to schedule an X10 controller to control various lights and appliances.
    Robert K. Johnson Sr


  20. Mikal

    11 years ago

    @Armond,

    My best guess is that TinyGPS can’t quite keep up with the high speed of the flow? Perhaps the serial buffer is overflowing? Can you slow down the amount of data that is being transmitted or processed somehow?


  21. Stephen H

    11 years ago

    For my current project I need to create a new string that includes the whole GPRMC sentence from $ to checksum that I then pass on through a second serial port, what is the neatest way to write the whole sentence to a string? the NMEA library does it but clashes with something else in my sketch and I have not been able to find a work around.


  22. reggy

    11 years ago

    Great library. the lat long are working but cant get speed and course. i’m using eb-85a and arduino mega328. thank you


  23. Axel

    11 years ago

    Hi Mikal,

    just trying to get TinyGPS to work with an Adafruit Ultimate GPS breakout on a boarduino. The Adafruit_GPS lib’s test examples work:

    $GPGGA,084730.000,5014.4124,N,00836.2861,E,1,10,0.84,181.2,M,47.9,M,,*6A
    $GPRMC,084731.000,A,5014.4124,N,00836.2861,E,0.33,87.69,141012,,,A*53

    Fix: 1 quality: 1
    Location: 5014.4121N, 836.2859E

    I get a fix and GPRMC shows “A”, which are the prereqs for TinyGPS to get and parse GPS data (if I understand it right). However, TinyGPS shows only “****”. Any suggestions?

    Thanks and best regards,
    Axel


  24. Axel

    11 years ago

    Hi Mikal,

    found the problem, it was a setting issue. Adafruit Ultimate GPS serial speed default to 9600. Changing code to

    nss.begin(9600);

    returns now all as it should be:

    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
    ————————————————————————————————————————————–
    10 85 50.24017 8.60458 281 10/14/2012 09:38:54 69 197.20 265.35 0.35 W 628 286.32 WNW 574 2 1

    Thanks,
    Axel


  25. Ben

    11 years ago

    Hi Mikal,

    I’m trying to figure out a way to log more than just the standard gps nmea character strings. In addition to the standard NMEA character strings my gps also outputs pmtk and rmc messages of different sentence lengths. Your examples work fine on this gps for the standard gps sentences, however I cannot figure out how use the carriage return feature in tinyGPS to form a data string from each sentence coming from the GPS. Essentially I need a way to use tinyGPS to form data strings that aren’t formatted. Are there any recommendations you can provide?

    thanks!


  26. Mikal

    11 years ago

    Thanks, Ivan and all. The next rev of TinyGPS will contain “perfect precision” parsing.


  27. Mikal

    11 years ago

    @brticha2,

    Many people ask if it’s possible to capture the raw NMEA data from TinyGPS. Remember that you are feeding the raw data TO TinyGPS in the first place. I recommend capturing it before you ever send it to TinyGPS.


  28. Mikal

    11 years ago

    @Michael Shimniok,

    Hey! Thanks for sharing the good news. Nice work! I’ll get that fix into TinyGPS soon.


  29. Mikal

    11 years ago

    @Andrew,

    Hey, thanks very much for sharing. I love taking GPS equipment on trains.

    Fantastic exploration video — w/ A Little Nightmusic! :)

    Thanks again,

    Mikal


  30. Mikal

    11 years ago

    Stephen,

    If I were tasked with capturing the whole GPRMC sentence, I think I would capture the characters before sending to TinyGPS. Would that work for you?


  31. Mikal

    11 years ago

    Ben, it’s a good question. I’m working on a general strategy for capturing custom fields from NMEA-type strings.


  32. awaxa

    11 years ago

    This has probably been corrected already but just in case, I noticed this yesterday:

    https://github.com/awaxa/arduino/commit/268cdccc38d43cb3a984dc3c0922360acae2e9cd
    in
    https://github.com/awaxa/arduino/blob/master/libraries/TinyGPS12.zip

    Cheers and thanks for the fantastic library!


  33. Mikal

    11 years ago

    @awaxa,

    Thanks for the heads up!


  34. James

    11 years ago

    HELP—-
    Does this work with the ARM processor?


  35. Jeremy M

    11 years ago

    Hey,

    I noticed an issue where the GPS is sending both RMC and GGA sentences and the velocity/course information will be invalid, while other data (latitude, longitude, altitude, etc) will be fine, but if GGA is turned off, velocity and speed will work. Have you run into this before?

    Thanks,
    Jeremy


  36. Mikal

    11 years ago

    @James, it’s designed to be processor-agnostic, so I would imagine that it works fine.


  37. Mikal

    11 years ago

    @Jeremy M, what speed is your data arriving at? I can only imagine that there is some kind of overflow issue going on, where some sentences are not being completely received.


  38. manitou

    11 years ago

    I got TinyGPS (v12) to work with DUE. GPS EM-406A is 5v, but spec and scope show TX and pps output are only 2.85v, so no need for level converters. For IDE 1.5 to see the TinyGPS library I had to rename Examples/ to examples/. All three examples worked, replaced SoftwareSerial with Serial1, and for static_test sketch I had to neuter the PROGMEM stuff.

    You don’t even need the TinyGPS lib to test the pulse-per-second output (1 microsecond accuracy). I hooked the pps output to a DUE digital port and used attachInterrupt() (required IDE 1.5.1) witht a micros() timestamp, and used that to measure the clock frequency of the DUE. The simple gpspps sketch and results can be viewed at

    https://github.com/manitou48/crystals

    I also got TinyGPS to work with Maple — a bit more hacking required for that.
    Needed stdlib.h in TinyGPS.cpp, and the examples needed some includes, used Serial1 instead of SoftwareSerial, and SerialUSB in place of Serial.


  39. Mikal

    11 years ago

    @Manitou– thanks!


  40. george

    11 years ago

    thank you


  41. Chantal

    11 years ago

    Hallo,
    ich bin eine Anfängerin in der Programmierung von Arduino UNO, leider kann ich kein Englisch, deshalb auf Deutsch.
    Nun ich habe mir den Arduino UNO und das Buch “Arduino in der Praxis” von Harold Timmis gekauft und wollte aus dem Busch das Projekt: Ausgeben von GPS- Daten auf einem Monochrom- LCD so zusagen nachbauen. Habe das Programm abgeschrieben und beim Prüfen folgende Fehlermeldung erhalten.
    Fehler beim Kompillieren:
    In file included from GPS_Test.cpp:8:
    C:\Program Files\arduino-1.0.1\libraries\NewSoftSerial/NewSoftSerial.h:33:2: error: #error NewSoftSerial has been moved into the Arduino core as of version 1.0. Use SoftwareSerial instead.
    In file included from GPS_Test.cpp:8:
    C:\Program Files\arduino-1.0.1\libraries\NewSoftSerial/NewSoftSerial.h:99: error: conflicting return type specified for ‘virtual void NewSoftSerial::write(uint8_t)’
    C:\Program Files\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error: overriding ‘virtual size_t Print::write(uint8_t)’
    Ich weis nun nicht weiter.
    Wer kann mir dabei helfen?
    Wer das Programm benötigt kann mich kontaktieren und ich sende es dann zu.
    Im Voraus vielen Dank für Eure Unterstützung.


  42. Mikal

    11 years ago

    @george,

    I love it when people just write “thank you”. Thank YOU.


  43. Mikal

    11 years ago

    @ Chantal,

    Ersetzen Sie “NewSoftSerial” mit “SoftwareSerial” in Ihrem Code, und Sie sollten in Ordnung sein.


  44. Klaus

    11 years ago

    Hello
    I have a problem.
    I have 2 GPS receivers
    a GM-210 = 4800bps
    and a navilock nl-507ttl.
    my software works with the GM-210 and 4800bps, but sometimes she can read any data from the GPS sends data.
    but with the navilock nl-507ttl and 9600bps, I get no data what I can do?


  45. Milton Friesen

    11 years ago

    Mikal, I have very much benefited from working through your coding sketches – thanks for all your work.

    For people deep into the coding, there is much to be gleaned. Here is what I can’t find – a very simple sketch – as simple as possible – that uses as little memory as possible to feed NMEA strings to an SD card without taking up any additional memory for processing strings, formatting, and so on. This isn’t likely a high demand application as people likely prefer to have the SD card data already formatted but I’m looking for a very long duty cycle where everything is as efficient as possible and processing of NMEA strings can be done post-data collection. The only variable would be how often a valid GPS fix gets logged – 15 seconds, 5 minutes, 1 hour, etc.

    This is doubtless simple for advanced users but when I try and bring a working GPS sketch together with a working SD datalog sketch, I get bugs that I can’t quite figure out. On the other side, when I use the code from Jeremy Blum’s Tutorial 15, my UNO gets close to memory limits (29,342 of 32,000) and then I get the “programmer out of sync” message. I can make it work if I comment out certain lines but when I used a programmer to remove the bootloader and gain 2,000 bytes, it still wouldn’t run. He uses a Mega so the memory issue isn’t a problem but I’m going the other way – small, long duty cycle, post-collection formatting.

    I will keep working at it but thought you might have some insight.


  46. Mikal

    11 years ago

    @Milton,

    If you are trying to save just the raw NMEA data, you have to realize that you have to buffer it, because writing to SD is slower than incoming GPS. So the question is, how much do you need to buffer? I know that with my EM-406A, all I need is a GPGGA and GPRMC sentence, and that these come by once per second. I think I would use this algorithm. When it’s time to sample GPS data:

    1. start reading the input stream
    2. As soon as I see a $ sign, start saving the data in buffer1 until the terminating newline arrives.
    3. If the sentence isn’t $GPGGA or $GPRMC, go back to step 1
    4. keep reading. As soon as I see a $ sign, start saving the data in buffer2 until the terminating newline arrives.
    5. If the sentence isn’t $GPGGA or $GPRMC or if it’s the same type as in buffer1, go back to step 4

    At this point you should have two buffers filled with one GPRMC sentence and one GPGGA sentence. Write these to the SD card. When the 15 or 5 minutes have elapsed, start again at step 1.


  47. Jayakarthigeyan

    11 years ago

    When I used simpletest.pde that was given with tiny gps library examples… this the result that I got on the serial monitor… what can be the problem please help me out… I am using Arduino 1.0.3 software…

    Simple TinyGPS library v. 12
    by Mikal Hart

    CHARS=120 SENTENCES=0 CSUM ERR=14
    CHARS=240 SENTENCES=0 CSUM ERR=27
    CHARS=462 SENTENCES=0 CSUM ERR=58

    CHARS=9125 SENTENCES=0 CSUM ERR=1174
    CHARS=9245 SENTENCES=0 CSUM ERR=1189
    CHARS=9365 SENTENCES=0 CSUM ERR=1204

    the value in CHARS and CSUM ERR keeps on increasing…


  48. Lucas

    11 years ago

    Hi, Mikal.

    I’m using the MC-1513 and an arduino Uno, but, when I start the test gps, doesn’t work propretly, can you help me? (note: I’ve changed the RX and TX on code, for 3 and 2 as datasheet info.


  49. Mikal

    11 years ago

    Jayakarthigeyan,

    My guess is that you have selected the wrong baud rate when talking to your GPS device, or perhaps your device is set to operate in some kind of binary (i.e. not NMEA) mode.


  50. Mikal

    11 years ago

    @Lucas,

    Without details it’s hard to guess, but make sure you don’t have your RX and TX crossed. Remember that if it says “RX” on the GPS module datasheet, that line is the TX line when it gets to the Arduino.

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

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

  2. 10

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

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

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

  4. GPS mit Arduino - Webmeister Blog

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

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

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

  6. Transmission success - Projects

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

  7. GPS testing with LCD Character Display

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

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

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

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

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

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

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

  11. Shield Driven Arduino GPS

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

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

    [...] 2 [...]

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

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

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

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

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

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

  16. reptile-addict.nl | My Arduino Blog

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

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

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

  18. GpsBee and Seeeduino Stalker v2 « Wireless Building Automation

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

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

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

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

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

  21. Anonymous

    [...] [...]

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

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

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

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

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

    [...] tinygps [...]

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

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

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

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

  27. Using SKYLAB SKM53 GPS with Arduino

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

  28. Arduino GPS module test sketch - Develop with Arduino

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

  29. Distance measuring with Arduino - Develop with Arduino

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

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

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

  31. Early Sailing Sensor designs | Andrew Hodel

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

  32. When thinking o… | pa2dy

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

  33. GPS Box | pa2dy

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

  34. GPS Box « Sketching with Hardware

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

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

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

  36. Updated – WISMO228 Library for Arduino | Rocket Scream

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

  37. GPS Speed Display | Open Source Software Development

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

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

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

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

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

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

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

  41. Montando o GPS | Heliostat Brasil

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

  42. Fastrax UP501 GPS Module - Babelduck Cybernetics

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

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

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

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

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

  45. Pre-Race Telemetry Snippets | TechWeasel

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

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

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

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

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

  48. Arduino GPS Tracking System -Arduino for Projects

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

  49. Arduino GPS Datalogger -Arduino for Projects

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

  50. nmea gpgga | GPS検索

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

  51. gpgga format | GPS検索

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

  52. My Proposal Box, Part 3: Software

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

  53. Xronos Clock Home – Time via GPS

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

  54. Arduino en GPS | Pieters fijne blog

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

  55. Greater Accuracy with TinyGPS 13 | Arduiniana

    [...] TinyGPS [...]

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

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

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

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

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

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

  59. Módulo GPS Skylab SKM53 | AUTOMALABS

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

  60. My 15$ GPS module | Bajdi.com

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

  61. 86duino

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

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

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

  63. Arduino Development Journal/May 2014 | Surfing Satellites

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

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

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

  65. Tutorial – Arduino and MediaTek 3329 GPS

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

  66. GPS und Arduino | wer bastelt mit?

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

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

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

  68. Freematics Blog – Users Guide for Arduino Telematics Kits

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

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

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

  70. Spark Core and TinyGPS Library | devlper

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

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

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

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

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

  73. A cheap, functioning GPS | Denial Media

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

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

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

  75. Arduino Time Library learning notes | tlfong01

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

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

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

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

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

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

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

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

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

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

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

  81. Living by Numbers | nr's blog

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

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

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

Leave a Reply