Altitude GPS

Hello everyone.
I am doing an altimeter for the hike. I use a ms5611 pressure sensor to have variations of my altitude. However to initialize the altitude and calculate the QNH, I use a gps ublox with an arduino card. My problem is that I can't print an altitude in my serial monitor. I think it's because I do not find satellites. Do you think that this comes from my code or that it is because I plug the gps with the usb of my computer which does not have enough intensity? Thank you :slight_smile:

/*The circuit:
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)
*/
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
 
 
SoftwareSerial mySerial(10, 11);
Adafruit_GPS GPS(&mySerial);
 
 
#define GPSECHO  false
 
boolean usingInterrupt = false;
void useInterrupt(boolean);
 
void setup()
{
  Serial.begin(115200);
 
 
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
  GPS.sendCommand(PGCMD_ANTENNA);
 
  useInterrupt(true);
 
  delay(1000);
}
 
SIGNAL(TIMER0_COMPA_vect)
{
  char c = GPS.read();
#ifdef UDR0
  if (GPSECHO)
    if (c) UDR0 = c;
#endif
}
 
void useInterrupt(boolean v)
{
  if (v)
  {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  }
  else
  {
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}
 
uint32_t timer = millis();
 
void loop()
{
  if (GPS.newNMEAreceived())
  {
 
    if (!GPS.parse(GPS.lastNMEA()))
      return;
  }
 
  if (timer > millis())  timer = millis();
  if (millis() - timer > 1000)
  {
    timer = millis();
 
  
    Serial.println();
 
    //Altitude
 
 
    Serial.print("Altitude en metres: ");
    Serial.print(GPS.altitude, 0);
    Serial.println(" m");
 

  }
}

You may not have a position fix. Make sure you are out of doors with a clear view of the sky, and give the GPS unit up to 15 minutes to get the initial fix.

Post examples of the actual output.

Hello,
Thank you for your answer.
That's right, after 10 min, the GPS found satellites. I have these values ​​in my serial monitor. I did not know it could take so much time. As long as I can not find a satellite, it prints 0m.
The problem is that I notice that the values ​​are drifting. How can I know which altitude is the right one? In the end I only need a value to calibrate my pressure sensor. Thank you.

Altitude en metres: 0 m

Altitude en metres: 0 m

Altitude en metres: 0 m

Altitude en metres: 0 m

Altitude en metres: 0 m

Altitude en metres: 0 m

Altitude en metres: 0 m

Altitude en metres: 0 m

Altitude en metres: 173 m

Altitude en metres: 171 m

Altitude en metres: 172 m

Altitude en metres: 172 m

Altitude en metres: 171 m

Altitude en metres: 170 m

Altitude en metres: 169 m

Altitude en metres: 169 m

Altitude en metres: 168 m

Altitude en metres: 167 m

Altitude en metres: 167 m

Altitude en metres: 167 m

Altitude en metres: 167 m

Altitude en metres: 165 m

You cannot know which is the 'right one' unless you check on a map.

The GPS derived altitude often does vary quite a lot, this is normal. Often a lot more than the small variation you are seeing.

Best you can do is average the readings.

Altitude is much less well determined than horizontal position.

Even under good conditions, horizontal position error might be +/-3 m, while altitude error could be +/-30 m and sometimes much worse. You might need to average values over an entire 24 hour period to get an accurate estimation of the altitude.

Is your GPS receiver WAAS-capable? If so, altitude estimates should be pretty good --- good enough for vertical guidance on precision aircraft instrument approaches.

gfvalvo:
Is your GPS receiver WAAS-capable? If so, altitude estimates should be pretty good --- good enough for vertical guidance on precision aircraft instrument approaches.

I have found that in testing most all common GPS, Ublox 6,7,8, MTK3329, MTK3339, produce the height errors I suggested, can you point to one that does not ?

Since the height I presume is produced by trianglulation, a more stable\accurate height would also require a much better position error than the +- 5 to 10m that is common for the above GPSs.

If so, altitude estimates should be pretty good

Define "pretty good".

srnet:
I have found that in testing most all common GPS, Ublox 6,7,8, MTK3329, MTK3339, produce the height errors I suggested, can you point to one that does not ?

In this case, I was speaking while wearing my instrument pilot’s hat, not my hobbyist hat. I was thinking that once you have a WAAS-enabled GPS you get the enhanced vertical accuracy.

Perhaps that’s not the case? All I can tell you is that a WAAS-enabled GPS is all you need to fly an LPV Approach. No other sensors are required, except an altimeter to recognize Decision Height.

jremington:
Define "pretty good".

25 feet (7.6 m) lateral and vertical accuracy 95 percent of the time.
See LPV Approach.

gfvalvo:
25 feet (7.6 m) lateral and vertical accuracy 95 percent of the time.

mmmm is that +- 7.6m or +- 3.8m ?

The OP posted figures for an 8m altitude variation.

Generally speaking the altitude error is 1.5X or greater than the horizontal position error, so +/- 8 m is a reasonable estimate for the best situations. This is a simple fact of the triangulation algorithm used and cannot be avoided.

This quote, from the link in reply #9, clearly means +/- 7.6 m, not +/- 3.8 m (that is the +/- two sigma, or 95% confidence interval definition):

LPV is designed to provide 25 feet (7.6 m) lateral and vertical accuracy 95 percent of the time.[5] Actual performance has exceeded these levels. WAAS has never been observed to have a vertical error greater than 12 metres in its operational history.

This author suggests that those landing small aircraft using GPS altitude should make sure that their insurance is paid up (even with the most modern GPS receivers).

Thank you to everyone for your answer.
I use a gps ublox neo 6m.
In the datasheet (https://www.u-blox.com/sites/default/files/products/documents/NEO-6_DataSheet_(GPS.G6-HW-09005).pdf), I see that Receiver type SBAS: WAAS, EGNOS, MSA.
I know my real altitude is about 188m and my values found by my gps are :

Altitude en metres: 226

Altitude en metres: 224

Altitude en metres: 224

Altitude en metres: 224

Altitude en metres: 224

Altitude en metres: 223

Altitude en metres: 224

Altitude en metres: 223

Altitude en metres: 218

Altitude en metres: 216

Altitude en metres: 220

Altitude en metres: 219

Altitude en metres: 220

Altitude en metres: 216

Altitude en metres: 217

Altitude en metres: 217

Altitude en metres: 216

Altitude en metres: 217

jremington:
You might need to average values over an entire 24 hour period to get an accurate estimation of the altitude.

I would like to start my hike before the night :slight_smile: I have an uncertainty of a few meters depending on the measurement. I hesitate to keep the GPS or to initialize my altitude manually. The advantage of GPS is that if I do not know the altitude of the place where I am, he can give me an estimate.
Does the accuracy of the altitude depends on the number of satellites found by the GPS?
Thank you

clem64000:
Does the accuracy of the altitude depends on the number of satellites found by the GPS?

Not always.

But its academic really, apart from getting a GPS with a bigger better antenna, there is little you can do to improve the number of satellites received.

clem64000:
I use a gps ublox neo 6m. In the datasheet (https://www.u-blox.com/sites/default/files/products/documents/NEO-6_DataSheet_(GPS.G6-HW-09005).pdf)

That might be the GPS chip itself your are using but it cannot be the GPS module\board you are using.

The GPS chip you posted the link for has no antenna, so would never work.

Its the antenna actually used that is the real important bit, they vary from just about working to very good.

The module I use is this one : Gps module apm2.5 with eeprom navigation satellite positioning geekcreit for arduino - products that work with official arduino boards Sale - Banggood.com sold out-arrival notice-arrival notice.
There is an antenna directly on it.

That is a perfectly acceptable, inexpensive module with the minimum acceptable antenna.
It is enabled for WAAS, EGNOS, MSAS.

You should be aware that position and altitude errors vary greatly, depending on both the number of satellites that the GPS unit can receive and their positions in the sky.

Even under good conditions, position errors can range from +/- 3 m to +/- 50 m. The images below show some altitude measurements I made from outside my home (altitude 590 feet or about 180 m) over a 24 hour period, using a high end Garmin (GPSMAP 60CSX) commercial receiver.

The standard deviation of these ~15,000 measurements is 12 feet, or 3.6 m, so the 2 sigma, 95% confidence interval is +/- 7.8 m, which agrees with the previous discussion.

Altitude as a time series:
gps_alt.png

Altitude as a histogram:
gps_alt_histo.png

gps_alt.png

gps_alt_histo.png

On 24h your system seems to work well. I tried to leave my GPS for 1 hour, he did not find satellites ... I think I will use the manual method to calibrate my altitude. However there are watches with GPS which can calculate an altitude similar to reality. I'm going search and if I do not get convincing results, I'll calibrate my altimeter manually. Thank you all :slight_smile:

I tried to leave my GPS for 1 hour, he did not find satellites

Were you outside, with a clear view of the sky?

jremington:
Were you outside, with a clear view of the sky?

No, in my home and the sky was cloudy. I will try to test the gps outside during 24h. But if I'm in the mountains and the sky is cloudy I may not find satellites.