Question

What are the data needed for calculating barometric altitude? How do I get them and then calculate the altitude?

Also how accurate is the barometric compared to GPS altitude? I tried GPS but after searching hours in the web I cannot find a suitable Geoid library.

Please correct me if I got any concept long.

Was it helpful?

Solution

You need to use the pressure sensor to measure the pressure then use the SensorManager.getAltitude(float, float) call to convert the measures pressure along with a reference sea level pressure to get the altitude.

The tricky bit is what to use as the reference pressure. This will change with the weather and will drift over time. Typically you would do some sort of calibration to set this values and possibly update it. It depends on your use case what the right solution is.

If properly calibrated pressure based altitude is considerably more accurate then gps based altitude especially if want you are interested in is altitude differences rather than absolute altitudes. With a bit of filtering on the raw pressure sensor values you can easily detect holding the phone at face level or arms length above your head which you want do with gps.

OTHER TIPS

The arguments are: GPS altitude (it's good to use average value calculated from array of measurements) and barometric pressure. Method returns pressure at sea level (formula from SensorManager.getAltitude(float p0, float p) in reverse).

public static float getSealevelPressure (float alt, float p)
{
    float p0 = (float) (p / Math.pow(1 - (alt/44330.0f), 5.255f));
    return p0;
}

I'm using the default value: SensorManager.PRESSURE_STANDARD_ATMOSPHERE until GPS collects 10 locks. After that, the above method is called.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top