Skip to content

Commit e7b71a5

Browse files
authored
Merge pull request #16 from adafruit/aht20_calibration
Calibration patch for newer AHT20's
2 parents d62022d + fe1abce commit e7b71a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

adafruit_ahtx0.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,15 @@ def reset(self) -> None:
107107

108108
def calibrate(self) -> bool:
109109
"""Ask the sensor to self-calibrate. Returns True on success, False otherwise"""
110+
# Newer AHT20's may not succeed, so wrapping in try/except
110111
self._buf[0] = AHTX0_CMD_CALIBRATE
111112
self._buf[1] = 0x08
112113
self._buf[2] = 0x00
113114
with self.i2c_device as i2c:
114-
i2c.write(self._buf, start=0, end=3)
115+
try:
116+
i2c.write(self._buf, start=0, end=3)
117+
except Exception: # pylint: disable=broad-except
118+
pass
115119
while self.status & AHTX0_STATUS_BUSY:
116120
time.sleep(0.01)
117121
if not self.status & AHTX0_STATUS_CALIBRATED:

0 commit comments

Comments
 (0)