Skip to content

Commit f0eac09

Browse files
authored
Merge pull request #22 from FoamyGuy/busy_timeout_calibration
Timeout if remain busy during calibration
2 parents 5fbff98 + e0a60e7 commit f0eac09

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

adafruit_ahtx0.py

+5
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ def calibrate(self) -> bool:
130130
except (RuntimeError, OSError):
131131
pass
132132

133+
start_busy_time = time.monotonic()
133134
while self.status & AHTX0_STATUS_BUSY:
135+
if time.monotonic() - start_busy_time > 3.0:
136+
raise RuntimeError(
137+
"Sensor remained busy 3 seconds. Could not be calibrated"
138+
)
134139
time.sleep(0.01)
135140
if not self.status & AHTX0_STATUS_CALIBRATED:
136141
return False

0 commit comments

Comments
 (0)