diff --git a/adafruit_bmp280.py b/adafruit_bmp280.py index 6ab9b1b..2af58b9 100644 --- a/adafruit_bmp280.py +++ b/adafruit_bmp280.py @@ -369,6 +369,11 @@ def altitude(self) -> float: p = self.pressure # in Si units for hPascal return 44330 * (1.0 - math.pow(p / self.sea_level_pressure, 0.1903)) + @altitude.setter + def altitude(self, value: float) -> None: + p = self.pressure # in Si units for hPascal + self.sea_level_pressure = p / math.pow(1.0 - value / 44330.0, 5.255) + ####################### Internal helpers ################################ def _read_coefficients(self) -> None: """Read & save the calibration coefficients"""