Delay() interferes with NMEA sentence? [Resolved]

I was having a great deal of difficulty getting a GPS fix from my AssetTracker Shield. NMEA sentence was garbled and gpsFix() returned false, even though red LED on the AssetTracker was off (indicating a valid GPS fix).
I finally resolved the issue by deleting delay(1000) statement from the application.
I surmise that the delay() function interferes with serial communication between the GPS module and the Adafruit parser.
Does anyone know whether this makes sense?

I’d go with yes, it make sense that that would happen.

Reading the serial data from the GPS occurs in the main loop(), so if you block the loop by using a delay() it’s quite likely that data would be lost.

Thanks rickkas7. That helps.

Thanks for the help @rickkas7

OK, so I got rid of the delay() statements, and substituted a simple test to determine whether I have a good fix. I’m still puzzled by how it (doesn’t) work. Following is my test program

#include "AssetTracker/AssetTracker.h"
long lastPrint = 0;
AssetTracker t = AssetTracker();
void setup() {
void loop() {
    if(millis()-lastPrint > 6000){
        lastPrint = millis();

and a portion of the output it generates.


I seem to be having difficulty getting consistent transmissions of the NMEA sentence from the Adafruit GPS to the Electron.

Notice that the time difference between subsequent fixes is not always 6 seconds.

Any suggestions?

I’m not a huge fan of the Adafruit GPS library. I prefer the TinyGPS++ library which I find to be more reliable. This is a Particle port of the TinyGPS++ library, plus my LIS3DH driver, with an optional compatibility layer so the API is mostly the same as the official AssetTracker library.


Thanks rickkas7, I will give it a try. :wink:

1 Like