DHT sensor

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
lbayo
Posts: 24
Joined: Tue Mar 16, 2021 2:10 pm

DHT sensor

Post by lbayo » Sat Apr 03, 2021 3:29 am

Hello,

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?

Post Reply