Skip to content

Commit 4a5daf0

Browse files
authored
adafruit_bme680.py: Fix compensation of pressure values
Compared the ot reference code, one expression in the lengthy calculation was split in two lines. Since a previous interim value was used in the expression twice and replaced by the first part of the split expression, the overall result was different to the reference code. The resulting pressure was not that different, 10 hPa at 1000hPa absolute value, but clearly outside of the spec with 1hPa absolute pressure error.
1 parent 1c8dade commit 4a5daf0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

adafruit_bme680.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ def pressure(self):
189189
var2 = (var2 * self._pressure_calibration[5]) / 4
190190
var2 = var2 + (var1 * self._pressure_calibration[4] * 2)
191191
var2 = (var2 / 4) + (self._pressure_calibration[3] * 65536)
192-
var1 = ((var1 / 4) * (var1 / 4)) / 8192
193-
var1 = (((var1 * self._pressure_calibration[2] * 32) / 8) +
192+
var1 = (((((var1 / 4) * (var1 / 4)) / 8192) *
193+
(self._pressure_calibration[2] * 32) / 8) +
194194
((self._pressure_calibration[1] * var1) / 2))
195195
var1 = var1 / 262144
196196
var1 = ((32768 + var1) * self._pressure_calibration[0]) / 32768

0 commit comments

Comments
 (0)