I went through the “Displaying Your Coordinates with a GPS Module” project.
I added the code to get the altitude:
float altitude = myGPS.getAltitude();//
oled.print(“\nAlt:”);
oled.print(altitude, 6);
The altitude that appeared was -24278.000000
I know my altitude is about 60 feet (18.288 meters) above sea level.
Is the library code wrong in getting the altitude from the GPS string?
Or is there something else wrong?
Thanks.
Are there docs for the Sparkfun GPS library? If not, it is usually helpful to look at the code.
A quick glance at the library code reveals that the altitude is returned in millimeters. Knowing that the error in GPS altitude determination is typically +/- 50 meters helps to understand that the number you got (-24 meters) is not unreasonable. Since the altitude is an integer, you don’t need all those zeros after the decimal place, either.
https://github.com/sparkfun/SparkFun_Ub … ibrary.cpp
//Get the current altitude in mm according to ellipsoid model
int32_t SFE_UBLOX_GPS::getAltitude(uint16_t maxWait)