From 888d8b312a4913516af0857067da567111af3b0e Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 1 Dec 2017 14:08:40 +0000 Subject: [PATCH] Convert negative gas resistance readings to unsigned int32 --- library/bme680/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/bme680/__init__.py b/library/bme680/__init__.py index 1e5bfcb..a8f7720 100644 --- a/library/bme680/__init__.py +++ b/library/bme680/__init__.py @@ -354,6 +354,9 @@ class BME680(BME680Data): var3 = ((lookupTable2[gas_range] * var1) >> 9) calc_gas_res = ((var3 + (var2 >> 1)) / var2) + if calc_gas_res < 0: + calc_gas_res = (1<<32) + calc_gas_res + return calc_gas_res def _calc_heater_resistance(self, temperature):