Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
Added an optional manually set temperature if temperature adjustments are required.
  • Loading branch information
chad-ermacora committed Jun 11, 2020
1 parent 6bccfcb commit 1095f3f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions library/bmp280/__init__.py
Expand Up @@ -198,9 +198,15 @@ def get_pressure(self):
self.update_sensor()
return self.pressure

def get_altitude(self, qnh=1013.25):
def get_altitude(self, qnh=1013.25, manual_temperature=None):
# qnh = pressure at sea level where the readings are being taken.
# The temperature should be the outdoor temperature.
# Use the manual_temperature variable if temperature adjustments are required.
self.update_sensor()
pressure = self.get_pressure()
temperature = self.get_temperature()
if manual_temperature is None:
temperature = self.get_temperature()
else:
temperature = manual_temperature
altitude = ((pow((qnh / pressure), (1.0 / 5.257)) - 1) * (temperature + 273.15)) / 0.0065
return altitude

0 comments on commit 1095f3f

Please sign in to comment.