Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why The altitude is change if it is Evening or Night?

I have this following code :

public SensorEventListener sensorEventListener = new SensorEventListener() {
    @Override
    public void onSensorChanged(SensorEvent event) {
        float pressure_value = 0.0f;
        float height = 0.0f;
        if (Sensor.TYPE_PRESSURE == event.sensor.getType())
        {
            pressure_value = event.values[0];
            height = SensorManager.getAltitude(SensorManager.PRESSURE_STANDARD_ATMOSPHERE, pressure_value);
        }
        value = String.valueOf(height);
    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {

    }
};

I've got the altitude meter e.g 43,xxxxxxx at 09.AM.

And i have check it again in 09.PM, the result is changing. It change 2 meter or more.

Is it because the pressure changed by moon or anything else ?

And How to fix this ?

I have read the following thread : Android: How to get accurate altitude?

But i still got confused.Could you guide me how to write the code ? And for note, i want to using it based on barometric sensor.

like image 496
Leonard Febrianto Avatar asked Jul 29 '15 04:07

Leonard Febrianto


2 Answers

Barometers provide pressure readings, not altitude ones.

Now because there's a gradient of pressure, and in general it decreases with altitude, you could theoretically infer the difference in altitude from the difference in pressure. Thats all you know with a non-calibrated altimeter: you don't know your current altitude, but you will know when you climb or descent and how much.

To calculate the altitude from your current pressure you need a reference pressure. For instance, you need to know what the pressure is at sea level. So if at sea level the pressure is x hPa, and your barometer reads x+3 hPa, and you know pressure increases +1hPa per meter, your altitude would be 3m above sea level.

The problem is that any reference pressure will always be changing due to meteorological phenomena. So it will only be valid for some time in a certain area. Airports provide this info for aircraft so that they can set their altimeters with the correct reference pressure (for instance, QNH). Once you know this reference pressure normalized to sea level (QNH is not, you better use QFF), you can pass it as the first parameter to this method:

SensorManager.getAltitude(<reference pressure at sea level>, pressure_value);

And remember that you can't hardcode the reference pressure. It is constantly changing, like temperature. You need to look it up in the internet, or using aviation meteorological services.

like image 197
Mister Smith Avatar answered Oct 04 '22 15:10

Mister Smith


Change of temperature between day and night results in difference of air pressure and thats the reason you get different altitude readings. If you can account the effects of temperature the error can be corrected.

like image 20
sambid shrestha Avatar answered Oct 04 '22 13:10

sambid shrestha