Avoid Adafruit PulseIn hangs when claiming the DHT GPIO pin.

libgpiod_pulsein fails with "Unable to set line N to input" on Raspberry Pi OS, so read via bitbang and release the pin after a single-shot run.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-17 22:25:17 +08:00
co-authored by Cursor
parent 85f4107938
commit f061673880
2 changed files with 18 additions and 3 deletions
+4 -1
View File
@@ -82,7 +82,10 @@ def main():
'Single run temperature and humidity reading '
'[version: 2.0, Python 3]'
)
return sensor_read(cfg, dev_type, dhtpin)
try:
return sensor_read(cfg, dev_type, dhtpin)
finally:
dhtreader.close()
if __name__ == '__main__':