DHT22 Error Message

I am new to Node-RED and I am trying to setup a simple temp & humidity sensor using a DHT22 but I have an error on the message output.

My setup is
RPi 4
OS Bullseye 64bit
Waveshare DHT22 - 3 cable output
Node-RED 3.0.2
Node.js v18.14.0

From the Waveshare SLD information the DHT22 shows a 5.1k resistor across vcc and the data pin, so there is no need for another pull resistor, I have connected the DHT direct to the pin on the RPi GPIO, as this sensors comes with a XH2.54 3-pin cable that can be plugged into the GPIO's on the RPi.

PINs used are
PIN 1 - 3.3v
PIN7 - (GPIO4)

I followed the install process on Node-RED for the DHT22 node and its dependencies but I cannot get the readings output via the debug msg, the error message isvalid: false and errors: 4. I just don't know how to solve it.

I also tried this with OS Buster,
I also tried 5v PIN,

no change in output msg.

Any help much appreciated.


Not sure but I think the DHT22's output is at it's supplied voltage and Raspberry Pi GPIO pins are not safe at 5V.

Try using another GPIO pin, at 3,3V

Many thanks for the feedback, my default setting is the 3.3v PIN which gives the main error I listed. I just tried 5v PIN to see if it made any difference but no change to the output.
I have it currently connected to 3.3v PIN.

I have a dozen of these running and have found them reliable but a pain to setup. Also, they are extremely slow and I don't poll them more than 1 every 3 seconds max. Figuring out how to connect them was at best confusing as there were several options such as bcm numbering, physical pin and some others. As I recall there was a lot of trial and error in looking up pin numbers and changing data pins on different gpio pins until I found a combination that worked. Do you have other dht22's you can try? Although that sensor seems pretty robust I'm concerned about having hooked it up to 5 V. I don't remember the spec off hand but I think it's a 3.3 volt device.

No this is the only one I have which I bought to try out Node-Red with my RPi
I seen YouTube video's of the same and it looks like being straight forward, but the error does not tell me anything.
So I cannot figure out is it the dht22 node, BCM, the sensor or my permissions.
I am currently checking now if my permissions are right as I have it starting on boot, and start the localhost interface to bring up the dashboard as admin user which is different to my pi login details.
Ultimately, I want to collect the data with MQTT store that in influx with Node-RED creating the flow and display with Grafana.

This is why so many of us:

a) No longer use DHT sensors :grin:
b) Don't use Pi GPIO.

It seems a lot easier and more reliable to stick sensors into a cheap ESP and send outputs direct to MQTT.

Also, last time I looked, DHT sensors were finally more expensive than newer, better sensors. I guess because nobody wants them any more. Not only are they slow (and they certainly will return errors if you access them too quickly), they are very inaccurate (even the 22's) and the sensors drift out of alignment over time. Of course, we all have some stock of them which is a bit annoying. :slight_smile:


Many thanks for the feedback, that's my next step now and get a ESP32 DEV board

Don't overlook the humble Wemos D1 Mini (probably even cheaper than the ESP32 Dev board) and perfectly adequate for the simple task you described.
AliExpress do a version with a Type-C USB connector.

If you just want to measure temperature the DS18B20 is a good choice. If you need to measure humidity and air pressure as well, then you might want to consider the BME280.

1 Like

Great suggestions and many thanks, I will look at those option