# Problem with DHT22 (AM2302) Grove

**URL:** <https://forum.xod.io/t/problem-with-dht22-am2302-grove/536>\
**Category:** Uncategorized\
**Created:** [February 24, 2018, 5:04pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536 "2018-02-24T17:04:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [February 24, 2018, 5:04pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/1 "2018-02-24T17:04:02Z")

</div>

Dear Community,  
i use a Arduino Leonardo with the Extentionboard V2  
I’m currently programming a plant irrigation and would incorporate the DHT22 temp feeler.  
Unfortunately this shows no values ​​with the dht2x thermometer node.  
I connected it analog and digital but without success.  
when i use it in the arduino ide with the example sketch it works on digital pin 2 correct

---

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [February 25, 2018, 10:10am UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/2 "2018-02-25T10:10:50Z")

</div>

I have connected the AM2302 sensor to a Mega 2560 this seems to work.  
However, I connect more sensors and an i2c display so everything works, only the AM2302 sensor don´t work

 ![Unbenannt](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/0d7909f31cc743888cb206cbf4ee493def7cea87.jpg)  
I2C Display run  
Ultrasonic Sensor run show (Waterlevel)  
no datas from DHT22

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [February 27, 2018, 11:50am UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/3 "2018-02-27T11:50:16Z")

</div>

Am I understand you correctly? If you connect _just_ the DHT22 it works. And when you add the LCD or ultrasonic the DHT22 stops.

Or do you mean DHT22 never reads the data? Have you tried it on other ports?

---

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [February 27, 2018, 3:45pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/4 "2018-02-27T15:45:49Z")

</div>

thanks for answering nkrkv,

Only DHT22 as sensor but with i2c lcd.  
If I try it with more sensors, he shows me only analog, digital signals on i2c lcd but not the DHT22 values.  
I try it with USB and/or external Powersupply but nothing change the problem.

I tried it on the digital and PWM port as well as on the analog with the same result.  
The DHT22 sensor works when I try it with the Arduino IDE. There are also values ​​when I embed him on XOD but only alone without further sensors

---

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [February 27, 2018, 5:35pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/5 "2018-02-27T17:35:06Z")

</div>

in this picture you can see that the DHT22 and the i2c lcd works without any further sensors!

 ![IMG_3077](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/ce030c211e3196a61964d17995c2856b66732235.JPG)

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [February 27, 2018, 5:54pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/6 "2018-02-27T17:54:54Z")

</div>

Which port #s are you using for the 3 sensors & LCD?

---

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [February 27, 2018, 6:44pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/7 "2018-02-27T18:44:50Z")

</div>

hello gweimer,

Ports in use:  
A0 -\> UV Sensor  
A1 -\> Moisture  
A2 -\> keypad for LCD submenue (experimental)  
D2 -\> DHT22 (AM2302)  
D3 -\> 1ch. relais  
D4 -\> water flow sensor (YF-B5)  
D5/6 -\> Ultrasonic (HC-SR04) Waterlevel  
I2C -\> 20x4 LCD  
thats it

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [February 27, 2018, 11:43pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/8 "2018-02-27T23:43:30Z")

</div>

Which pins are used for I2C on your board? It usually over-laps with “normal” pins.

---

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [February 28, 2018, 7:53am UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/9 "2018-02-28T07:53:30Z")

</div>

Arduino Mega 2560  
SDA-\>20  
SCL-\>21

Arduino Leonardo  
SDA-\>2  
SCL-\>3

It could well be that there are problems on the Leonardo.  
Why, however, on the mega too? Here I do not use the ports of the I2C bus.  
I’ll try different ports today.

---

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [March 1, 2018, 9:20am UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/10 "2018-03-01T09:20:46Z")

</div>

so I tested different ports, but the result remained the same.  
As soon as I attach a sensor to the DHT22 and the i2C LCD, no matter  
which port the DHT22 does not work anymore.  
I tried with MEGA and LEONARDO on different Ports witch I2C LCD and without.

I have no idea what the problem could be.

---

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [March 1, 2018, 1:40pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/11 "2018-03-01T13:40:42Z")

</div>

I have been able to narrow down the problem.  
The problem is on the part of the I2C bus.  
If I use a display without I2C or sensors,  
I can use the DHT22 and any number of other sensorswithout problems.

I think that together between i2c and 1 wire bus causes this problem. Unfortunately my knowledge about programming ends here.

I hope one of you can fix this problem

regarts  
Chris

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [March 1, 2018, 4:16pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/12 "2018-03-01T16:16:52Z")

</div>

My best guess would be that I2C communication code is setting up a 2nd loop to handle communication out-of-band (sort of…). The delay calls in DHT code will perform a yield(). If I2C holds CPU long enough, you miss the pin transitions in DHT code & error out without trying to read values.

Changing delays to while loops would not perform the yield, and would also allow more flexibility in test (depending on how you code loop, transition could happen between 70 & 80 us without generating error for example…).

Of course, this is just speculation & changing the DHT code might not make any difference… I don’t have that sensor, so I can’t try to reproduce the error or test code changes.

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [March 2, 2018, 10:05pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/13 "2018-03-02T22:05:38Z")

</div>

> [@chris-cross](#):
>
> The problem is on the part of the I2C bus.  
> If I use a display without I2C or sensors,  
> I can use the DHT22 and any number of other sensorswithout problems.

Cool, we have a clear way to try to reproduce the problem.

> [@gweimer](#):
>
> My best guess would be that I2C communication code is setting up a 2nd loop to handle communication out-of-band (sort of…). The delay calls in DHT code will perform a yield(). If I2C holds CPU long enough, you miss the pin transitions in DHT code & error out without trying to read values.

Sounds very reasonable. I²C LCD’s straightly use the Arduino library and to be honest I didn’t look at its internals yet. If it’s indeed blocks with `delay`’s, it’s stronger than DHT lib which releases control when idle. If so, we’ll have to make a XOD-aware I²C LCD lib.

That’s a subject for testing. Will do it next week.

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [March 6, 2018, 12:07pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/14 "2018-03-06T12:07:09Z")

</div>

Can’t reproduce, unfortunately

 ![20180306_145628](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/ffd6d9298832b553fc5c9da9f63cfa95a613b6df.jpg)

It works and updates for me. Yes, it is not a Grove AM2302 sensor, but an AM2301 however it _should_ interface the same way. Would you share a xodball which shows the program with the thermometer and LCD (without anything other) refusing to work on your hardware? I’ll try to reproduce.

BTW, the I²C LCD library looks pretty innocent and should not interfere anything.

---

<div class="post-metadata">

**Author:** ![chris-cross](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@chris-cross](https://forum.xod.io/u/chris-cross)\
**Post date:** [March 7, 2018, 5:38pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/15 "2018-03-07T17:38:01Z")

</div>

I have now set all the values from the DHT22 lib ​​up and down for waiting time. But are responsible without result.  
Unfortunately, my programming skills are not enough to change something in the I2C lib.  
Is there a way to get around the problem that the I2C LCD Node needs to access directly the Arudino library?

@gweimer and @nkrkv  
Many thanks for your help, the probram is fantastic!

I will now use a Mega 2560 to integrate more LCDs without I2C.

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [March 12, 2018, 2:53pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/16 "2018-03-12T14:53:13Z")

</div>

I filed an [issue](https://github.com/xodio/xod/issues/1110). Can’t solve it for myself now since I don’t have the hardware matching yours exactly to reproduce.

---

<div class="post-metadata">

**Author:** ![omran](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/omran/32/1112_2.png) [@omran](https://forum.xod.io/u/omran)\
**Post date:** [April 3, 2019, 9:55pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/17 "2019-04-03T21:55:03Z")

</div>

I face the same with XOD 0.28.2  
I use Arduino Uno R3 and tried to change the port but the problem persists. I also tried LCD 2x16 and 4x20 with I2C and without and unfortunately it shows no values ​​with the dht2x thermometer node.  
If any of you found a solution for this issue please advise what to do.

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [April 5, 2019, 4:04am UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/18 "2019-04-05T04:04:24Z")

</div>

Hi, you can try the following

![](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/b/b9e73f222c00ab55e5fb6d349b1abe97beec1857.gif)

---

<div class="post-metadata">

**Author:** ![omran](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/omran/32/1112_2.png) [@omran](https://forum.xod.io/u/omran)\
**Post date:** [April 8, 2019, 3:43pm UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/19 "2019-04-08T15:43:31Z")

</div>

Hi

Many thanks for your contribution. I tried pin 6 through 12 as input, in the beginning it was working but for no reason it stopped. I tried pin 2 as advised by a college now it is working.

---

<div class="post-metadata">

**Author:** ![n5ztw](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@n5ztw](https://forum.xod.io/u/n5ztw)\
**Post date:** [September 17, 2019, 12:04am UTC](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536/20 "2019-09-17T00:04:38Z")

</div>

I found a work around for the AM2302 sensor not reading issue.  
Connecting “DONE” on the sensor to “UPD” on the display results in Humidity posting correctly and temperature flashing for a sub second. There seems to be some kind of timing issue. I played around for hours with delays and such and eventually fell into a solution by happy accident. Residing in the states I simply added a C to F conversion node between the sensor “Tc” and display “L1” this math was enough delay to correct the issue. If you want degrees C simply insert an “ADD” node for say 10 then a “SUBTRACT” node for the 10 again and that will also work as I tested it.

[Next page](https://forum.xod.io/t/problem-with-dht22-am2302-grove/536.md?page=2)
