I am working with an ESP32 and a DHT-11 temperature and humidity sensor, and the system has a strange behavior.
When running a simple program, DHT returns values without any problem,
Code: Select all
from machine import *
from dht import *
from utime import sleep
s11=DHT11(Pin(33))
while True:
try:
s11.measure()
temp=s11.temperature()
hum=s11.humidity()
print (temp,hum)
except:
print ("-----")
pass
sleep (2)
but when the same code is embedded in a larger program, DHT returns the error code.
The large program performs many tasks on many threads (mqtt communication, CO2 measurement, etc.).
Could there be any interference between the DHT interface (one-wire) and the python thread management system?