Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

error in altitude calculation, and over agressive rounding round(altitude, 1) #1

Closed
bradcar opened this issue Nov 22, 2024 · 1 comment

Comments

@bradcar
Copy link
Contributor

bradcar commented Nov 22, 2024

In your code for altitude you have
altitude = 44330.0 * (
1.0 - ((self.pressure / self.sea_level_pressure) ** 0.190284)
)
return round(altitude, 1)
In the Bosch Sensor guide (ex: in bmp180 they show a different formula page 16 of: https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf).
Since you are raising the difference in pressure & SLP to a power small differences can make a difference.

Consider this return value instead, because it eliminates the over rounding of altitude limits accuracy to 100cm on device capable of a couple of centimeters:
altitude = 44330.0 * (
1.0 - ((self.pressure / self.sea_level_pressure) ** (1.0 / 5.255))
)
return altitude

@jposada202020
Copy link
Owner

Corrected by #2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants