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:
@@ -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__':
|
||||
|
||||
Reference in New Issue
Block a user