I am also using timer tick interrupt to read from the GPS, which should be more reliable. If you want to do that you will need these:
// Interrupt driven GPS serial I/O
void handleSysTick(void* data) {
char c = GPS.read();
}
void useInterrupt(boolean v) {
if (v) {
static HAL_InterruptCallback callback;
static HAL_InterruptCallback previous;
callback.handler = handleSysTick;
HAL_Set_System_Interrupt_Handler(SysInterrupt_SysTick, &callback, &previous, nullptr);
}
}
double gpsLat, gpsLon, gpsGeo, gpsAlt;
void initGPS() {
pinMode(D6, OUTPUT);
digitalWrite(D6, LOW);
GPS.begin(9600);
//# request a HOT RESTART, in case we were in standby mode before.
GPS.sendCommand("$PMTK101*32");
delay(250);
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_ALLDATA); // request everything!
delay(250);
GPS.sendCommand(PGCMD_NOANTENNA); // turn off antenna updates
delay(250);
gpsStartTime = millis();
gpsLat = gpsLon = gpsGeo = gpsAlt = 0;
}
Add this to setup():
initGPS();
useInterrupt(true);