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() {
    t.begin();
    t.gpsOn();
    Serial.begin(9600);
}
void loop() {
    t.updateGPS();
    if(t.gpsFix())
    if(millis()-lastPrint > 6000){
        lastPrint = millis();
        Serial.println(t.preNMEA());
        }
    }

and a portion of the output it generates.

 6,3
$GPGGA,151145.000,4429.6503,N,06348.3967,W,1,10,0.83,27.1,M,-23.7,M,,*6S,02,3
$GPGGA,151152.000,4429.6503,N,06348.3967,W,1,10,0.83,27.1,M,-23.7,M,,*6S,02,3
$GPGGA,151152.000,4429.6503,N,06348.3967,W,1,10,0.83,27.1,M,-23.7,M,,*6S,02,3
$,,210*C0.6,96
$GPGGA,151208.000,4429.6500,N,06348.3964,W,1,10,0.83,27.1,M,,S,,2,3
$GPGGA,151211.000,4429.6498,N,06348.3964,W,1,10,0.83,27.1,M,-23.7,M,,*6S108,,.03
$GPGGA,151227.000,4429.6498,N,06348.3959,W,2,10,0.83,27.1,M,-23.7,M,000,02237G230634
$GPGGA,151227.000,4429.6498,N,06348.3959,W,2,10,0.83,27.1,M,-23.7,M,000,02237G230634

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.

3 Likes

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

1 Like