Problem with DHT22 (AM2302) Grove

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

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


I2C Display run
Ultrasonic Sensor run show (Waterlevel)
no datas from DHT22

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?

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

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

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

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

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

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.

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.

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

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.

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

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.

Can’t reproduce, unfortunately

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.

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.

I filed an issue. Can’t solve it for myself now since I don’t have the hardware matching yours exactly to reproduce.

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.

Hi, you can try the following

4 Likes

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.

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.

1 Like