DHT22 bug ?
-
- Posts: 46
- http://meble-kuchenne.info.pl
- Joined: Sat Feb 04, 2023 1:09 pm
- Has thanked: 2 times
- Been thanked: 2 times
DHT22 bug ?
Since the latest update, the dht22 component is only willing to produce a 000 value or an incorrect readout , what is the cause ?
-
- Matrix Staff
- Posts: 1465
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 204 times
- Been thanked: 347 times
Re: DHT22 bug ?
If you roll back the DHT22 component to an earlier version (via Library Updates), does it work then? Which latest version of the component is working for your project?
Re: DHT22 bug ?
I have tried both components (dth22 and grove dth22) and 4-16-20 Mhz quartz frequency as well . The update was done about 2 weeks ago , the project before that worked in simulation and in reality .
-
- Valued Contributor
- Posts: 1453
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 707 times
Re: DHT22 bug ?
Found a DHT22 and had a play. Wired up to an esp32 and an oscilloscope - interesting trace!
I couldn't understand why pulling the pin low for 3ms (actually this only needs to be 1ms) would start a 'sensor' reading in the component - but my pulling a pin low for a period didn't (just a low for 3ms) I didn't get a reading using the component though - and wasn't sure why.
So - a little time later - I came up with this. Tested and working on an esp32 - it uses a slightly different approach to the component (making the code slightly simpler?) I also time in 10us lumps - making the delays slightly more achievable for some MCUs..
If anyone would like a play...
It's not a component (sorry) - and Temp and Humidity are saved as 10 times the actual value (so currently displaying 12.8C and 64.3% humidity which are saved as 128 and 643)
As an aside - if there is a timeout error - and less than 40 bits are received - it is necessary to check that there isn't an error before calculating temp - otherwise there is a compilation error (data may be used uninitialised) - that compiler is very neat!
Martin
I couldn't understand why pulling the pin low for 3ms (actually this only needs to be 1ms) would start a 'sensor' reading in the component - but my pulling a pin low for a period didn't (just a low for 3ms) I didn't get a reading using the component though - and wasn't sure why.
So - a little time later - I came up with this. Tested and working on an esp32 - it uses a slightly different approach to the component (making the code slightly simpler?) I also time in 10us lumps - making the delays slightly more achievable for some MCUs..
If anyone would like a play...
It's not a component (sorry) - and Temp and Humidity are saved as 10 times the actual value (so currently displaying 12.8C and 64.3% humidity which are saved as 128 and 643)
As an aside - if there is a timeout error - and less than 40 bits are received - it is necessary to check that there isn't an error before calculating temp - otherwise there is a compilation error (data may be used uninitialised) - that compiler is very neat!
Martin