Hi Folks,
Using this samle code, on every loop I am able to see a new values for location.lng(), location.lat() and location.altitude.meters() but speed.kmph() and course.deg() are not updated at the same moment. Difficult to know what’s the frequency both are updated. My test was done in the car.
I want to know and be sure to update the speed and course.deg on every read. Thanks in advance
void readGPS(LocalisationGPS& Geo)
{
while (Serial1.available() > 0)
{
if (gps.encode(Serial1.read()))
{
if (millis() - lastSerial >= SERIAL_PERIOD)
{
lastSerial = millis();
if (gps.location.isValid() && gps.location.age() < MAX_GPS_AGE_MS)
{
Geo.longitude = String(gps.location.lng());
Geo.latitude = String(gps.location.lat());
Geo.altitude = String(gps.altitude.meters());
Geo.speed = String(gps.speed.kmph());
Geo.heading = String(gps.course.deg());
Serial.print("lo:\t");Serial.println(Geo.longitude);
Serial.print("la:\t");Serial.println(Geo.latitude);
Serial.print("al:\t");Serial.println(Geo.altitude);
Serial.print("sp:\t");Serial.println(Geo.speed);
Serial.print("he:\t");Serial.println(Geo.heading);
if (gettingFix)
{
gettingFix = false;
unsigned long elapsed = millis() - startFix;
Serial.printlnf("%lu milliseconds to get GPS fix", elapsed);
}
}
else
{
Serial.println("no location");
if (!gettingFix)
{
gettingFix = true;
startFix = millis();
}
}
}
}
}
}