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