![]() |
Forum Index : Microcontroller and PC projects : MM2: DHT22 Is there an issue?
Author | Message | ||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 998 |
Hi, I am new to the Micromite and have been playing with a DHT22 temperature and humidity sensor on one of Micks NanoMites. It worked first go but has been intermittent since it first went for a few minutes. It sometimes works and other times show 1000/1000 as the result, indicating it either not there or giving invalid data. I figured it was a faulty DHT22 but only have one so could not prove it. After I got my $10 Logic Analyzer I looked at the signal from the DHT22 (AM2302 is same thing) and after downloading the data sheet could understand the signaling, and it all appeared to be good, but MMBasic saying 1000/1000. The data comes back as 40 bits, 2 * 8 bits for temp and 2 * 8 bits for humidity and 8 bits as parity. The parity is the sum of the previous 4 * 8 bits. The binary values coming back are divided by 10 to give the temperature and humidity to 1 decimal place. If I breath on the sensor it starts working but if temperature falls below 25.6 degrees is stops working. I am suspicious that MMBasic 4.6 is getting the parity calculation wrong if there is a carry from bit(7) when the previous 4 * 8 bits are added. i.e it says the data is invalid. Has anyone else seen this? Can anyone check the source code to see how MMBasic calculates the parity bits for the DHT22 command? Regards Gerry Latest F4 Latest H7 FotS |
||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 327 |
I setup a DHT22 on a breadboard during the 4.6 beta testing and it worked every time. When I updated to 4.6 release version, I have not been able to get it to work reliably. I have not spent any real time checking into it other than replacing the jumper wires twice (one long set and one short set) and trying another DHT22. Hopefully later today I'll have a chance to re-flash my Micromites and test with 4.6a and a older version. I'll have to see if the temperature effects my sensor too. It was a little warmer while the beta test was going on (about 27C), right now it's about 21C in my office. --Curtis I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
I have one working in my workshop with V4.6a but here in Nth Qld. the temperature has not been below 25 for maybe 2 months. I'll turn on the air conditioner today and give it a test. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6262 |
I can confirm a problem. V4.6 Beta 25 works OK Beta 26, V4.6 and V4.6a all fail. Room temperature a pleasant 22 degrees. I didn't play with CPU speed. Jim VK7JH MMedit |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
Just checked mine and can confirm a problem when temp. goes below 25.6C. V4.6a Paul. @ TassieJim. at 22 deg. I would be wearing a jumper. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Justplayin![]() Guru ![]() Joined: 31/01/2014 Location: United StatesPosts: 327 |
Yep! Tested with beta 16 and it was working down to 11.5 with no problems (surrounded sensor with bottles of water from the fridge). Release versions 4.6 and 4.6a both failed. I also tried heating the sensor with a heat gun while testing the different versions of firmware and the warmer temperatures did not effect whether the DHT22 worked or not. --Curtis I am not a Mad Scientist... It makes me happy inventing new ways to take over the world!! |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 998 |
Thanks for all that testing guys. I'll stop wriggling leads trying to make it go for now. Is there a way to report to Geoff or does he look here? I have asked for a copy of the source to see if I can see how it works. Regards Gerry Latest F4 Latest H7 FotS |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6262 |
That looks like a misread of the returned value when it gets down to a single byte Jim VK7JH MMedit |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3281 |
Damn, it sounds like a bug. I must have tested it in the warmer weather. Give me a couple of days and I will see if I can track it down. Geoff Geoff Graham - http://geoffg.net |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
Tried to see what would happen if the humidity dropped down to 25%. So I heated the sensor in an enclosed environment to lower the humidity, but found as soon as the temp. reaches 42 deg. the same problem occurs. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 998 |
I think it is really a combination of the temperature and humidity. They come across as 4 * 8 bits.e.g. 0000 0000 high byte for temp 1111 1100 low byte for temp (252 is 25.2) 0000 0010 high byte for humidity 0000 0001 low byte for humidity. 51.3% --------- 1111 1111 checksum byte --------- If when these are added up for the check byte there is a carry out to the next highest bit (ie bit(8)) that it fails. When temperature is below 25.5 the chance of a humidity byte not causing a carry is low. The above combination of 25.2 deg and 51.3% humidity would probably be OK as no carry is generated in the checksum. Gerry Latest F4 Latest H7 FotS |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1982 |
Interesting, because when I said it failed at 42 deg. the humidity at the time was 51.3% Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |