Benchmarking NMEA Libraries

Hi all.

I am a hardware guy and have great interest on arduino NMEA parsing libraries. I did tested simple sketches on NMEA, TinyGPS and TinyGPS++ libraries respectively using oscilloscope to view input NMEA sentences vs output sentences from my Mega2560.

With due respect to respective library authors for their overwhelming effort, I would like to share my findings and likewise fishing for validations from others interested in this data.

  1. NMEA have about 82.7ms delay with respect to input GPS port (Mega Serial1) and output (Mega
    Serial).
  2. TinyGPS have about 2.07ms delay
  3. TinyGPS++ have about 2.07ms delay

I wanted to test with NeoGPS but owing to my very limited coding skills, I seem cannot show in serial monitor NMEA sentences. If anyone can provide a sample code to stream input NMEA sentences and passed through NeoGPS then outputs to serial monitor.

Below are the sketches I used to test.

  1. NMEA test sketch
#include <nmea.h>

NMEA gps(ALL);

void setup()
{
  Serial.begin(4800); // serial port to PC
  Serial1.begin(4800); // serial port from GPS 

}


void loop() {
  if (Serial1.available() > 0) {        // if there's a byte waiting to be read
    if (gps.decode(Serial1.read())) {
     Serial.println(gps.sentence());
    }
  }
}
  1. TinyGPS test sketch
/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/

#include <TinyGPS.h>
TinyGPS gps;


void setup()
{
  Serial.begin(4800);
  Serial1.begin(4800);
 
}

void loop()
{
  if (Serial1.available() > 0)
  {
     char c = Serial1.read();
     Serial.write(c); // uncomment this line if you want to see the GPS data flowing
   // if (gps.encode(c)) // Did a new valid sentence come in?
  }
}

TinyGPS++ Test sketch

#include <TinyGPS++.h>

TinyGPSPlus gps1;

void setup()
{
  Serial.begin(4800);           //set serial monitor Port Baud rate
  Serial1.begin(4800);            //set GPS Port One Baud rate.
  
}

void loop()

{
 if (Serial1.available() > 0)    // Port One Data available
  {
    char c = Serial1.read();
    Serial.write(c);
   // if (gps1.encode(c));           // Did a new valid sentence come in?
  }
}

I have attached screenshots of my measurements. Photos are NMEAlib, TinyGPS & TinyGPS++ full data packet and zoom-in measurements.

The example TinyGPS sketches dont appear to use any functions from the TinyGPS library.

One sketch has a comment that softserial is required, but then does not appear to use it ?

I don’t think you are measuring the delay from the libraries at all - especially not with the two versions of TinyGPS. At 4800 baud it takes 2.08ms to transmit one character. The receiving side can’t start to transmit a received character until it sees the stop bit which therefore takes about 2.08ms between the start of the sender’s transmission and the start of the receiver’s transmission. All you’re measuring is the 4800 baud transmission rate.
Your code for the NMEA library actually calls the library and prints the decoded result which causes a longer delay (dunno whether you’ve measured it correctly though). The code for both TinyGPS sketches simply relays whatever character is received from the GPS and your oscilloscope images confirm this.

Pete

Or, you could look at the NeoGPS pages that compare NeoGPS (duh), Adafruit_GPS, TinyGPS and TinyGPS++, in terms of RAM, program size and execution speed...

The NeoGPS benchmark sketch is included with the library: NMEAbenchmark.ino. It will show the execution time for any NeoGPS configuration, Nominal or custom. This configuration capability is unique to NeoGPS.

Cheers,
/dev