mikalhart / TinyGPSPlus

A new, customizable Arduino NMEA parsing library
http://arduiniana.org
1.05k stars 486 forks source link

No Altitude and Satellites values. #115

Closed ad1k4h closed 1 year ago

ad1k4h commented 1 year ago

I have this function. This needs to be populate the values to global function:

void startGPS()
{
  if (gps.location.isValid())
  {

    latitude = String(gps.location.lat(), 10);
    longitude = String(gps.location.lng(), 10);
    altitude = String(gps.altitude.meters(), 2); // Altitude in meters (double)
    speed = String(gps.speed.kmph(), 2);
    satellites = String(gps.satellites.value());
    Serial.println(satellites);
    GPS_Status(1);
  }
  else
  {
    Serial.print(F("Searching for Satellites..."));
    GPS_Status(0);
  }

}

I getting latitude, longitude and speed, but altitude and satellites are empty. Am i trying it good or its a bug?

mikalhart commented 1 year ago

Altitude and satellites come from the $GPGGA sentence, while the others are available in $GPRMC. Best guess? Either your device has been configured to disable $GPGGA sentences, or you are calling startGPS() before the first $GPGGA sentence has been retrieved.

Are you calling startGPS repeatedly? If so, you should try temporarily removing the Serial.print(F("Searching for Satellites...")); line, because it may be introducing delays that cause serial overflow.

Last thing to try… change

if (gps.location.isValid())

to

if (gps.location.isValid() && gps.satellites.isValid())

Good luck!

M

ad1k4h commented 1 year ago

Changing to this:

if (gps.location.isValid() && gps.satellites.isValid())

Solved the issue. Thank you so much, and sorry for the issue. May thanks! <3

mikalhart commented 1 year ago

Changing to this:

if (gps.location.isValid() && gps.satellites.isValid())

Solved the issue. Thank you so much, and sorry for the issue. May thanks! <3

Excellent!