Skip to content

Commit 826eed3

Browse files
Andrew SmithAndrew Smith
Andrew Smith
authored and
Andrew Smith
committed
Add Calculated Sea Level Pressure based on Altitude
1 parent 9c9721c commit 826eed3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

adafruit_bmp280.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,14 @@ def altitude(self) -> float:
368368
- which you must enter ahead of time)"""
369369
p = self.pressure # in Si units for hPascal
370370
return 44330 * (1.0 - math.pow(p / self.sea_level_pressure, 0.1903))
371+
372+
@property
373+
def p0(self, altitude_m=0.0) -> float:
374+
"""The calculated sea level pressure based on altitude (:attr:`altitude`)
375+
- which you must enter ahead of time)"""
376+
p = self.pressure # in Si units for hPascal
377+
p0 = p / math.pow(1.0 - altitude_m/44330.0, 5.255)
378+
return p0
371379

372380
####################### Internal helpers ################################
373381
def _read_coefficients(self) -> None:

0 commit comments

Comments
 (0)