Skip to content

Commit e0a60e7

Browse files
committed
timeout if remain busy during calibration
1 parent 5fbff98 commit e0a60e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

adafruit_ahtx0.py

Lines changed: 5 additions & 0 deletions
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)