DHT22 - Random ERRNO [116] error...
Posted: Wed Jan 12, 2022 6:34 pm
Hi,
I am using a DHT22 temperature / humidity sensor but am having an issue with it when trying to read it.
ESP32 will every now and then (can run for minutes or days) stop due to the error as listed below: -
MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32
Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<stdin>", line 20, in <module>
File "<stdin>", line 11, in read_humidity
File "dht.py", line 17, in measure
OSError: [Errno 116] ETIMEDOUT
>>>
I have tried using a TRY and EXCEPT in my code but this does not work as once the error has happened the only way to clear it is a power cycle...
Any help would be much appreciated, thanks
I am using a DHT22 temperature / humidity sensor but am having an issue with it when trying to read it.
ESP32 will every now and then (can run for minutes or days) stop due to the error as listed below: -
MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32
Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<stdin>", line 20, in <module>
File "<stdin>", line 11, in read_humidity
File "dht.py", line 17, in measure
OSError: [Errno 116] ETIMEDOUT
>>>
Code: Select all
import dht
import machine
from machine import Pin
import time
dht22 = dht.DHT22(machine.Pin(16))
def read_humidity():
dht22.measure()
time.sleep(0.5)
humidity = dht22.humidity()
print(humidity)
temperature = dht22.temperature()
print(temperature)
while True:
time.sleep(2)
read_humidity()
Any help would be much appreciated, thanks