Back from the dead - DHT22 / AM2302 problem.

Here we can discuss about the problem found
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

Back from the dead - DHT22 / AM2302 problem.

Post by AndyGadget »

On the old forum I flagged up a problem I was having with the DHT22 / AM2302 temperature & humidity sensors on ESP32 where the module was returning 'nan' for certain ranges of measured temperature. The old thread is here : https://groups.google.com/g/annex_wifi_ ... ulIAbvCAAJ

At the time, Bugs tried a sensor he had and experienced no problems.
My sensors worked fine when I ran an Arduino sketch to do the same measurement.
The DHT22s work fine on ESP8266.
I gave up in the end and used a BME280 instead.

However, I have been having reliability problems with the BME280 as after about 6 months the humidity reading goes to 100% and stays there. I've had three of them exhibit this behaviour.

So, 9 months on and back to the AM2302. I bought a new AM2302 from a different supplier and I am seeing exactly the same problem; at a critical temperature of around 25.7C the module starts returning 'NAN' (not a number) instead of a numerical value, recovering when the temperature drops.

Has anyone else tried these devices with success, or otherwise?
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by Fernando Perez »

Hello Andy.
Do you mean to say that the problem appears only with the ESP32, but it works correctly with the ESP8266 and with Arduino devices?

At what voltage is it feeding the AM2302, at 5v or 3.3v?
How long are the cables connecting the meter to the ESP32?
Is the environment in which you place the meter outdoors, a greenhouse or a room?

If you connect the faulty BME280s to an Arduino, with their corresponding libraries, does it still show 100%?
Try to recover damaged sensors by placing them on top of a moisture-wicking can for 24 hours.

I only have a BME280; it works fine but I haven't had it on for more than a week, I don't know in the long run.
I abandoned the DHT11 because of its unreliability.
I was thinking of getting a GY-21 HTU21, but I read bad reviews on the Internet.
User avatar
Electroguard
Posts: 836
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 268 times
Been thanked: 317 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by Electroguard »

A few other thoughts...
CiccioCB has fixed many memory leaks during the Annex lifetime, so different versions may have different long-term memory leakage problems.
Another factor which might affect long-term stability could perhaps be the original arduino device drivers on which the Annex drivers are based - cos if for instance they use integers as cumulative counters they might eventually reach a (32K?) integer maximum with unplanned results.

To avoid such problems from memory leakage and clogging accumulators and growing histories etc, I don't keep important devices running indefinitely.
Some monitor their ramfree so they can do a pre-emptive reboot after any necessary housekeeping, others do a scheduled nightly reboot.

I've found the Dallas 1-wire waterproof DS18B20's to be very reliable, but they are temperature only, so I might also use a BME280 just for humidity and atmospheric pressure. The waterproof DS18B20''s can be bought as job lots of 5 for about a fiver, or individually with cable lengths up to 10m (handy for reaching external locations) and so far all have differed by less than 1 degree.

The problem I find with BME280's is that the air in the enclosure is warmed by the electronics and affects the reading, so the internal electronic sensor is not actually measuring the true ambient temperature. I've sometimes tried subtracting an offset from the reading (by comparing with a thermometer) but I've found that the offset at the cooler extreme always differs from the offset at the warmer extreme, and my old brain can't remember the maths needed to normalise them... does anyone know how ?

Whereas a cabled waterproof DS18B20 can be safely poked out into free air (or liquid) for a true reading, and 2 or more DS18B20's in parallel could be averaged for greater accuracy and/or a wider sampling range.
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by AndyGadget »

I just mentioned the BME280 devices in passing, but you've both picked up on it so I think the best thing to do is for me to create a separate thread in the 'hardware' section to discuss the BME280 (as this appears to be a hardware issue) and continue the DHT22 discussion here (as this may be driver related.)
Jan Volk
Posts: 71
Joined: Wed Mar 03, 2021 1:35 pm
Been thanked: 23 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by Jan Volk »

Hi Andy

I recognize this problem and experienced it a while back. On Esp8266 no problem with different DHT22 sensors on an ESP32 often message 'nan'. Tried with delays then but didn't really help. I then had the thoughts, I won't be the only one and threw it aside for a while. I want to view the signals simultaneously on an oscilloscope one more time.
I suspect that the problem is in the Annex firmware??

For the BME280, I do not have the experience of 100% RH as I have only used it in a short trial set-up in the house.

I have good experience with the DS18B20. In the attic, the Annex Wifi RDS program has been running without any problems in a Sonoff module with 3 waterproof DS18B20 sensors mounted against the pipes as a dashboard for heating with Supply, Return and Tap water with round meters on the ESP web server on the output screen.
And the same sensors have been working for many years in a hobby greenhouse for indoor and outdoor temperature and a window position control with potentiometer as a window position detector, but also in Basic with an Arduino nano and Bascom AVR.

A solution can be to mount two DS18B20 in a measuring box one above the other and to a method of measuring moisture with dry-wet bulb on the basis of a Müller table. This was and still is used in the greenhouses and is subject to some maintenance, such as clean water (demi-water) and cotton wick and freezes when it falls below zero!

I came across another temperature RH sensor the DHT20 and has an I2C connection instead of 1 wire connection like the DHT22 and has the same housing and are very cheap on AliExpress. These have been ordered so I can't judge yet but they say a replacement of the DHT11.
(2 instead of 1 to compensate transport)
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by AndyGadget »

Thanks for the feedback, Jan. Pleasew let us know how you get on with the DHT20.
I was also looking at the AM2320 which appears to be an AM2302 with an I2C interface, but without knowing whether the problem lies with the sensor itself or the data bus it could be money down the drain. Tomorrow I'll do a bit more research on the devices I've got.

A agree about the DS18B20 sensors. I've used these in the past with a different microcontroller (Picaxe) and they just sit there and get on with the job.
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by Fernando Perez »

And this little gadget that Cicciocb cited in [Local Link Removed for Guests]
couldn't connect via bluetooth to a nearby ESP32?
The ESP32 can transmit the information from various sensors to another central ESP32 located in his house.
User avatar
Electroguard
Posts: 836
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 268 times
Been thanked: 317 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by Electroguard »

As Fernando says, the standalone gizmo's that CiccioCB used with his Lilygo Epaper could be a good option for reliable humidity sensing.
They are neat self-contained units showing temp and humidity on LCD display, and I've had one sat on my desk and another on a bedside cabinet for several months, which both seem stable and accurate.
Francesco said they can be reprogrammed with streaming firmware which allows Annex to receive data from several devices without requiring pairing.
I was originally planning to get the Lilygo Epaper device, but at 50 quid with a touch case that's too expensive now, so I shall use them with bluetooth in exactly the same way but to an esp32 with TFT display. Need to prepare for winter first though, so will be a bad weather job.
Hendrix
Posts: 39
Joined: Sun Feb 14, 2021 11:03 am
Has thanked: 9 times
Been thanked: 8 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by Hendrix »

Fernando Perez » Wed Oct 06, 2021 11:04 pm
"The ESP32 can transmit the information from various sensors to another central ESP32 located in his house."

How would you advise to transmit information? By Telegram maybe?
(A little off-topic, sorry for that.)
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Back from the dead - DHT22 / AM2302 problem.

Post by Fernando Perez »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Thu Oct 07, 2021 8:14 am Fernando Perez » Wed Oct 06, 2021 11:04 pm
"The ESP32 can transmit the information from various sensors to another central ESP32 located in his house."

How would you advise to transmit information? By Telegram maybe?
(A little off-topic, sorry for that.)
Through ESP-Now. I love the ESP-Now system. :D
In this case, it would act as a mere bridge between the Bluetooth, with a very limited range, and the Wi-Fi system.
After all, Andy already has ESP modules with an external antenna, so the communication between his house and his greenhouse is already assured.
[Local Link Removed for Guests]
But, effectively, the possibility of registering the data directly in the cloud through Telegram, Google SpreadSheets, ThingSpeak, etc, etc. remains open.
I use, with exceptionally reliable results, a PHP-MySQL system hosted on the server where I have contracted my domain and Web pages.
Post Reply