Page 1 of 1

Altitude with BMP180

Posted: Wed Mar 09, 2022 8:05 am
by Euzikial
So it turns out that BMP180.py driver calculates altitude wrongly as it is showing me that I live on a mountain (870+ meters) while im almost sitting at the beach

p = -7990.0*math.log(self.pressure/self.baseline)

i have changed it to

p = (44331.5 - 4946.62 *self.pressure**(0.190263)

using the part of the code from

https://pvlib-python.readthedocs.io/.../atmosphere.html

and it came back with the same results - 870+ meters while google maps are saying im at 7+ meters.

Is it wrong if I divide by 10 the result of one of the formulas? f/e

p = (44331.5 - 4946.62 *self.pressure**(0.190263))/10

Re: Altitude with BMP180

Posted: Wed Mar 09, 2022 8:37 am
by Roberthh
I do not know which driver you use, but in my driver I use:

Code: Select all

            p = 44330 * (1.0 - math.pow(self.pressure /
                                        self._baseline, 0.1903))
where _baseline is the actual pressure at sea level, which will change all the time. You get that pressure typically from the weather reports, which tell you this "normalized" value. You cannot calculate the height just using the pressure without reference to the actual sea level pressure, which is the zero level of your scale.

Re: Altitude with BMP180

Posted: Thu Mar 10, 2022 2:53 am
by Euzikial
Thank you for your input. I will look into it. And yes I do update QNH (local baro pressure at sea level) every two hours.
I will update the formula and see what happens

Re: Altitude with BMP180

Posted: Thu Mar 10, 2022 5:17 am
by Euzikial
Roberthh wrote:
Wed Mar 09, 2022 8:37 am
I do not know which driver you use, but in my driver I use:

Code: Select all

            p = 44330 * (1.0 - math.pow(self.pressure /
                                        self._baseline, 0.1903))
where _baseline is the actual pressure at sea level, which will change all the time. You get that pressure typically from the weather reports, which tell you this "normalized" value. You cannot calculate the height just using the pressure without reference to the actual sea level pressure, which is the zero level of your scale.
What is your source of your code?

Re: Altitude with BMP180

Posted: Thu Mar 10, 2022 6:59 am
by Roberthh
My driver is here: https://github.com/robert-hh/BMP085_BMP180
As told, is was derived from a different implementation.