TinyGPS++

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

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

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

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

Download and Installation

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

History

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

Usage

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

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

Repeatedly feed it characters from your GPS device:

while (ss.available() > 0)
  gps.encode(ss.read());

Then query it for the desired information:

if (gps.altitude.isUpdated())
  Serial.println(gps.altitude.meters());

Differences from TinyGPS

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

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

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

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

$GPRMB,A,4.08,L,EGLL,EGLM,5130.02,N,00046.34,W,004.6,213.9,122.9,A*3D

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

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

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

Consider TinyGPS++ over TinyGPS if:

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

Feeding the Hungry Object

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

SoftwareSerial ss(4, 3);
void loop()
{
  while (ss.available() > 0)
    gps.encode(ss.read);
  ...

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

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

The TinyGPS++ Object Model

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

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

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

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

Validity, Update status, and Age

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

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

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

Debugging

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

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

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

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

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

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

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

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

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

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

Custom NMEA Sentence Extraction

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

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

TinyGPSCustom magneticVariation(gps, "GPRMC", 10)

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

if (magneticVariation.isUpdated())
{
  Serial.print("Magnetic variation is ");
  Serial.println(magneticVariation.value());
}

Establishing a fix

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

  1. You must continually feed the object serial NMEA data with encode().
  2. The NMEA sentences must pass the checksum test.
  3. For built-in (non-custom) objects, the NMEA sentences must self-report themselves as valid. That is, if the $GPRMC sentence reports a validity of “V” (void) instead of “A” (active), or if the $GPGGA sentence reports fix type “0” (no fix), then the position and altitude information is discarded (though time and date are retained).

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

Distance and Course

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

const double EIFFEL_TOWER_LAT = 48.85826;
const double EIFFEL_TOWER_LNG = 2.294516;
double distanceKm =
  TinyGPSPlus.distanceBetween(
    gps.location.lat(),
    gps.location.lng(),
    EIFFEL_TOWER_LAT,
    EIFFEL_TOWER_LNG) / 1000.0;
double courseTo =
  TinyGPSPlus.courseTo(
    gps.location.lat(),
    gps.location.lng(),
    EIFFEL_TOWER_LAT,
    EIFFEL_TOWER_LNG);
Serial.print("Distance (km) to Eiffel Tower: ");
Serial.println(distanceKm);
Serial.print("Course to Eiffel Tower: ");
Serial.println(courseTo);
Serial.print("Human directions: ");
Serial.println(TinyGPSPlus.cardinal(courseTo));

Library Version

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

Serial.println(TinyGPSPlus::libraryVersion());

Sample Sketches

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

Acknowledgements

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

All input is appreciated.

Mikal Hart

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

  1. Vincenzo

    10 years ago

    I am having an issue in getting the right altitude, I have connected in parallel to the serial of my GPS module both a PC running ucenter v5.07 and an Arduino MEGA using TinyGPS++.

    I get wrong altitude from Arduino, the difference is always about 43 meter less than the correct value that is also correctly displayed by “ucenter”.

    I am just calling gps.altitude.meters() after checking that it is valid.

    Is this a known issue, or am I doing anything wrong?

    Thanks


  2. Henry Hung

    10 years ago

    Hi,
    I tried tinyGPS++ with MTK gps, in the fullexample, the check sum fail nr is increasing, as below, is it normal? and I can not get speed and course information..

    FullExample.ino
    An extensive example of many interesting TinyGPS++ features
    Testing TinyGPS++ library v. 0.92
    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
    —————————————————————————————————————————————
    **** **** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 63 0 0
    4 255 24.948257 121.509254 780 ********** 08:05:55 **** 128.20 ****** ***** *** 9792 327.98 NNW 269 1 1
    4 255 24.948257 121.509246 743 ********** 08:05:56 **** 128.20 ****** ***** *** 9792 327.98 NNW 573 2 3
    4 255 24.948257 121.509246 809 ********** 08:05:57 **** 128.20 ****** ***** *** 9792 327.98 NNW 779 3 4
    4 255 24.948257 121.509239 843 ********** 08:05:58 **** 128.20 ****** ***** *** 9792 327.98 NNW 1113 4 6
    4 255 24.948257 121.509231 133 ********** 08:06:00 **** 128.20 ****** ***** *** 9792 327.98 NNW 1319 5 6
    4 255 24.948257 121.509223 254 ********** 08:06:01 **** 128.20 ****** ***** *** 9792 327.98 NNW 1627 6 9
    4 255 24.948255 121.509223 262 ********** 08:06:02 **** 128.20 ****** ***** *** 9792 327.98 NNW 1835 7 11
    4 255 24.948253 121.509216 280 ********** 08:06:03 **** 128.20 ****** ***** *** 9792 327.98 NNW 2041 8 13
    4 255 24.948255 121.509216 311 ********** 08:06:04 **** 128.20 ****** ***** *** 9792 327.98 NNW 2247 9 13
    4 255 24.948251 121.509208 356 ********** 08:06:05 **** 128.30 ****** ***** *** 9792 327.98 NNW 2453 10 13


  3. Mikal

    10 years ago

    Thanks Robert. If you want to “do something” rather than just seemingly wait for 1 second, either add your own code to the sample SmartDelay function, or else reduce the amount of time waiting in SmartDelay. In that example, I chose a one second delay so that the updates would occur every second. But you could do with a smaller value.


  4. Mikal

    10 years ago

    Vincenzo– Hmm.. I don’t know why the values would differ like that. The only way to tell for sure is to print out and examine the NMEA data stream. Perhaps two different fields are being examined?


  5. Mikal

    10 years ago

    @Henry Hung,

    Does the checksum fail value continue to increase if you let the sketch continue to run?

    I think the problem here is that the sketch is not able to keep up with the data stream coming in from the GPS. This is likely because I think your GPS is updating 10 times per second and trying to Serial.print a line of text at each update. Serial.print is very slow. Possible solutions:

    1. Slow down the GPS update rate (MTK) to 1 per second.
    2. If possible increase the baud rate on the Serial console.
    3. Don’t print so much data at every update. Instead, print data every second or 5 seconds or something.


  6. Stanley

    10 years ago

    Dear Mikal,

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

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

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

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

    Thanks in advance..


  7. Dave

    10 years ago

    Hello,

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

    Thanks!


  8. Fredrik

    10 years ago

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

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

    Thanks!
    Fredrik


  9. Mikal

    10 years ago

    @Fredrik,

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


  10. Mikal

    10 years ago

    @Dave,

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


  11. Arion

    10 years ago

    Mikal,

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


  12. Chris

    10 years ago

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


  13. Yaron

    10 years ago

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


  14. Thor Valø

    9 years ago

    /*
    GPS_Tiny
    Consistent read of GPS serial
    Created 17.10.2014
    By Thor Valo
    */

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

    #include ; // required for virtual RX, TX

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

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

    void setup()
    {
    Serial.begin(115200);
    gpsSerial.begin(9600);
    } // end setup

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

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

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

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


  15. alessandro

    9 years ago

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

    Thank you for sharing!
    Alessandro


  16. Stefan

    9 years ago

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


  17. Juan Domingo

    9 years ago

    Hey there!

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

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

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

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

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

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

    I fixed it defining GNRMC header in TinyGPSPlus.cpp

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

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

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

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

    Regards,
    Juan


  18. Pete

    9 years ago

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

    Is there a simple code to achieve this?


  19. Mikal

    9 years ago

    @Arion,

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


  20. Mikal

    9 years ago

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


  21. Mikal

    9 years ago

    @Yaron, sorry for the slow reply.

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

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

  22. Mikal

    9 years ago

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


  23. Mikal

    9 years ago

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


  24. Mikal

    9 years ago

    @Juan Domingo,

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


  25. Mikal

    9 years ago

    @Pete,

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

    if (gps.time.minute() < 10)
       Serial.print("0");
    Serial.println(gps.time.minute());
    

  26. Yaron

    9 years ago

    Hi Mikal,

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

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

    Thank you


  27. Jay

    9 years ago

    Hi Mikal,

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


  28. user

    9 years ago

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


  29. Mikal

    9 years ago

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


  30. Mikal

    9 years ago

    @user,

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


  31. Jay

    9 years ago

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

    For example (based on Arduino smoothing example):

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

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

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

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

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

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

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


  32. Practical_Pirate

    9 years ago

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

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

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


  33. Nikos

    9 years ago

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

    http://www.ebay.com/itm/Ublox-NEO-6M-V2-GPS-Module-Aircraft-Flight-Controller-For-Arduino-MWC-IMU-APM2-/321598638877?pt=LH_DefaultDomain_2&hash=item4ae0c5cb1d

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

    Any idea why ?

    Thank you once again.


  34. Mikal

    9 years ago

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


  35. Rob

    9 years ago

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


  36. Mikal

    9 years ago

    @Rob, hey thanks for the nice words.


  37. Arion

    9 years ago

    Mikal,

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

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

    Arion


  38. christian

    9 years ago

    Hey Mikal,

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

    Regards


  39. Craig Swanson

    9 years ago

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

    Craig


  40. MPCadosch

    9 years ago

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

    Thanks!


  41. sv650s

    9 years ago

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

    #include
    #include

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

    // The TinyGPS++ object
    TinyGPSPlus gps;

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

    void setup()
    {
    Serial.begin(115200);
    ss.begin(GPSBaud);
    }

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

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

    void displayInfo()
    {

    if (gps.location.isValid())
    {
    Serial.print(F("Location: "));
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
    Serial.print(F(","));
    Serial.print(F("Altitude: "));
    Serial.println(gps.altitude.meters());
    Serial.print(F(","));
    Serial.print(F("Satellites: "));
    Serial.print(gps.satellites.value());
    }
    else
    {
    Serial.print(F("INVALID"));
    }

    Serial.println();
    }


  42. Ahmad

    9 years ago

    Hi Mikal,

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

    I used the following program:
    […]

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

    Any Recommend?


  43. Mikal

    9 years ago

    @Craig Swanson,

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


  44. Mikal

    9 years ago

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


  45. Mikal

    9 years ago

    @Ahmad,

    What kind of problems are you having?

5 Trackbacks For This Post
  1. Arduino GPS with OLED Display | Home of Benty

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

  2. SpainLabs - Mantener tus proyectos en hora

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

  3. Prototype 1 – GPS Module | A Mean Center

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

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

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

  5. Connecting u-blox NEO-6M GPS to Arduino | Big Dan the Blogging Man

    […] http://arduiniana.org/libraries/tinygpsplus/ […]

Leave a Reply