# DHT22 AM2302 sensor doesn't work in nodered

**URL:** https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513
**Category:** General
**Created:** [29 May 2020 21:04 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513 "2020-05-29T21:04:06Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Mario-1977](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mario-1977/32/22960_2.png) [@Mario-1977](https://discourse.nodered.org/u/Mario-1977)
#### Post date: [29 May 2020 21:04 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/1 "2020-05-29T21:04:06Z")

</div>

Platform: pi 3 model B+ rev.1.3

OS: Rasbian

Node-RED: 1.0.5

Node.js: v12.17.0

problem node: node-red-contrib-dht-sensor v1.0.4

bcm2385 revision. a020d3

DHT22 sensor: AM2302

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/34377d4c8ffa7ec6489aaf3b1a8debf4988896e4.jpeg)

Hello I'm new in using Nodered but I found it perfect for my home automation project.

I bought 2 sensors DHT22 instead of the DHT11.

I used succesfully the DHT11 sensor connected to GPIO23 (physical pin 16) recieveing temperature and humidity values.

I changed the DHT11 with the DHT22 sensor connected to the same GPIO23 and changing the sensor model into the node-red-contrib to DHT22

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/e/de89de028fc37dcbe1f06ed60c6155025703806e.png)

and I recived wrong values as output:

{"\_msgid":"99d420d7.3025b","topic":"rpi-dht22","payload":"0.00","humidity":"0.00","isValid":false,"errors":4,"location":"Test\_T&H","sensorid":"dht22"}

I tried the same sensor with the same connection with Adafruit library and it works properly

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b67b3665bde3674aeb8d9252a18cebba11dd6c48.png)

I don't know how to solve it. But for me it's necessary to find a solution because I want to continue to work with nodered.

Can someone help me?

Thank you

Regards

---

<div class="post-metadata">

### Author: ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)
#### Post date: [29 May 2020 22:17 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/2 "2020-05-29T22:17:24Z")

</div>

I had the same thing happen when I switched from a dht11 to dht22. What finally fixed mine was changing the pin numbering from physical pins to bcm. Sounds dumb but it worked.

---

<div class="post-metadata">

### Author: ![Mario-1977](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mario-1977/32/22960_2.png) [@Mario-1977](https://discourse.nodered.org/u/Mario-1977)
#### Post date: [31 May 2020 10:24 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/3 "2020-05-31T10:24:37Z")

</div>

> [@gerry](#):
>
> Sounds dumb but it worked.

Thanks gerry for your suggestion but in my case it doesn't work. I changed from Physical pins (rev.2) to  
BCM gpio

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f7a2f7a001ebb8b499b056a144b976d84d46ae88.png)

following my wiring connection

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/2/326d9be0ef27b844ff547e068d14495201c4b3c1.jpeg)

but I always received wrong values:

{"\_msgid":"e68c589b.d4d8f8","topic":"rpi-dht22\_test","payload":"0.00","humidity":"0.00","isValid":false,"errors":4,"location":"Test\_T&H","sensorid":"dht22"}

I tried also to change the connection pin to other pins but nothing happened.

I thought the possible problem could be the correlation between the pins in the list node-red-contrib-dht-sensor and the real pins so I changed (and tested) all the proposed pin numbers into the node-red-contrib-dht-sensor list, but nothing.  
Following my wiring pin table:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/51e8eca350540f4e2a1ce8076b920ea9b1a71796.png)

Could the problem be a no compatibility of the sensor DHT22 AM2302 with the node-red-contrib-dht-sensor? Or does it depend from my hardware configuration?  
Does anyone know if there is an alternative palette to node-red-contrib-dht-sensor to control a DHT22 sensor into nodered?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [31 May 2020 10:53 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/4 "2020-05-31T10:53:35Z")

</div>

Just to verify, did you install the BCM2835 library and node-dht-sensor as it says in the [pre-req's](https://flows.nodered.org/node/node-red-contrib-dht-sensor)?

---

<div class="post-metadata">

### Author: ![Mario-1977](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mario-1977/32/22960_2.png) [@Mario-1977](https://discourse.nodered.org/u/Mario-1977)
#### Post date: [31 May 2020 12:34 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/5 "2020-05-31T12:34:34Z")

</div>

No I didn't install the BMC libraries as told in the pre-req's.

But I just do it and update the BMC to the version 1.65:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0a370d30d93a758dd82c9f12fb2ac5b6748707d8.png)  
Then I followed the other 2 steps in pre-req's and I re-installed the node-dht-sensor dependency and the node-red-contrib-dht-sensor node.  
And I updated npm to the latest version (patch) 6.14.5 and Node-js to version 12.17.0

The output values coming from node-red-contrib-dht-sensor are still wrong with both BCM GPIO (in my case 23) or Physical pin rev.2 (in my case 16).

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [31 May 2020 15:05 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/6 "2020-05-31T15:05:43Z")

</div>

Are you sure you have the pins connected properly? Is it possible the dht22 pin outs on the board are different than the dht11?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [31 May 2020 15:34 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/7 "2020-05-31T15:34:25Z")

</div>

After installing the BMC v1.65 library, node-dth-sensor and then the node-red-contrib-dht-sensor, I wired up a dht22 using:  
Pin 1 (3.3v) to pin 1 of the dht22  
Pin 6 (Gnd) to pin 4 of the dht22  
Pin 16 (BCM 23) to pin 2 of the dht22  
and a 10K resistor between pins 1 and 2 of the dht22

the node is reporting fine.

```auto
{"_msgid":"591e2642.bdc308",
  "topic":"rpi-dht22",
  "payload":"23.20",
  "humidity":"34.60",
  "isValid":true,"errors":1,
"sensorid":"dht22"}

```

I would uninstall/install node-red-contrib-dht-sensor and try again. If that doesn't work, try another dht22.

---

<div class="post-metadata">

### Author: ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)
#### Post date: [31 May 2020 15:56 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/8 "2020-05-31T15:56:00Z")

</div>

Just a note: Be careful with the resistor as many of the packaged DHT sensors have the resistor already in the circuit. I don't know if the DHT you are using has one or not but read the data sheet carefully.

---

<div class="post-metadata">

### Author: ![Mario-1977](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mario-1977/32/22960_2.png) [@Mario-1977](https://discourse.nodered.org/u/Mario-1977)
#### Post date: [19 June 2020 17:27 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/9 "2020-06-19T17:27:52Z")

</div>

Hello I bought and tested a new sensor DHT22 (a branded one) and now it works fine. So my problem was the sensor.  
I suggest to buy brended sensors and not generic unbrended sensors and of course to use the good node-red-contrib-dht-sensor.  
Thanks to **gerry** and **zenofmud** for your suggestions

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [3 July 2020 17:27 UTC](https://discourse.nodered.org/t/dht22-am2302-sensor-doesnt-work-in-nodered/27513/10 "2020-07-03T17:27:53Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
