From 42cfd8da712b87ac8cf37a81a6ffeb6865e81794 Mon Sep 17 00:00:00 2001 From: savannahcofer <31944130+savannahcofer@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:32:13 -0500 Subject: [PATCH] Fix timeout error in adafruit_bme680.py This fixes #76. Line 393 of the library adafruit_bme680.py is written, if start_time >= time.monotonic() - 3.0: raise RuntimeError("Timeout while reading sensor data") However, this is always going to return true and raise a Runtime Error regardless of your timing rate. This commit replaces line of code with the inverse of that, which is looking at the difference between the time.monotonic (the overall time) and the start_time (when you are looking at a new sensor data): if time.monotonic() - start_time >= 3.0: raise RuntimeError("Timeout while reading sensor data") --- adafruit_bme680.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_bme680.py b/adafruit_bme680.py index 144b877..0151ad0 100644 --- a/adafruit_bme680.py +++ b/adafruit_bme680.py @@ -390,7 +390,7 @@ def _perform_reading(self) -> None: data = self._read(_BME680_REG_MEAS_STATUS, 17) new_data = data[0] & 0x80 != 0 time.sleep(0.005) - if start_time >= time.monotonic() - 3.0: + if time.monotonic() - start_time >= 3.0: raise RuntimeError("Timeout while reading sensor data") self._last_reading = time.monotonic()