Altitude with BMP180

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Euzikial
Posts: 3
Joined: Wed Mar 09, 2022 5:26 am

Altitude with BMP180

Post by Euzikial » Wed Mar 09, 2022 8:05 am

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

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Altitude with BMP180

Post by Roberthh » 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.

Euzikial
Posts: 3
Joined: Wed Mar 09, 2022 5:26 am

Re: Altitude with BMP180

Post by Euzikial » Thu Mar 10, 2022 2:53 am

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

Euzikial
Posts: 3
Joined: Wed Mar 09, 2022 5:26 am

Re: Altitude with BMP180

Post by Euzikial » Thu Mar 10, 2022 5:17 am

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?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Altitude with BMP180

Post by Roberthh » Thu Mar 10, 2022 6:59 am

My driver is here: https://github.com/robert-hh/BMP085_BMP180
As told, is was derived from a different implementation.

Post Reply