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

Update bmp581.py correct altitude calc, and remove excessive rounding… #2

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bmp581.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ def altitude(self):
With the measured pressure p and the absolute altitude the pressure at sea level
can be calculated too. See the altitude setter for this calculation
"""

# updated to Bosch’s formula in bmp180 datasheet, and eliminate excessive rounding of altitude
altitude = 44330.0 * (
1.0 - ((self.pressure / self.sea_level_pressure) ** 0.190284)
1.0 - ((self.pressure / self.sea_level_pressure) ** (1.0 / 5.255))
)
return round(altitude, 1)
return altitude

@altitude.setter
def altitude(self, value: float) -> None:
Expand Down
Loading