DHT usermod with DHT22

Hi All,

I am using the latest 0.12.0 version of wled on a wemos esp32 board and I was trying to get the DHT usermod with a DHT22 sensor working, but unfortunatelly I can’t get a sensor reading.
The if (dht_sensor.measure(&tempC, &humidity)) { condition always returns false for me.
I tried to revert back to a previous version where the esp32DHT library was used from bertmelis, but it is all the same.
The sensor seems to be fine, I tried it out with Tasmota and also by running the example code from GitHub - alwynallan/DHT_nonblocking: Non-blocking Arduino library for the DHT11, DHT21, and DHT22 and in both cases the sensor worked.

I simply added the following build flags to the esp32dev env in platformio.ini for the custom build.

[env:esp32dev]
board = esp32dev
platform = espressif32@2.0
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32 -D USERMOD_DHT -D USERMOD_DHT_CELSIUS  -D USERMOD_DHT_MEASUREMENT_INTERVAL=60000 -D USERMOD_DHT_FIRST_MEASUREMENT_AT=90000 -D USERMOD_DHT_PIN=21  -D ARDUINO_ARCH_ESP32
lib_deps = ${esp32.lib_deps}
   https://github.com/alwynallan/DHT_nonblocking
   

Any help is appreciated.

Thanks,
Andras

1 Like