11 years, 6 months ago.

DHT CRC calculation error

Wim,

I have seen that the DHT code sometimes gets CRC errors. After looking at the code for some time, I discovered that the last bit in the 40 bit input stream does not get read. This bit is the LSb of the CRC byte and thus, this bit is always 0. This would explain why some readings are good (Hum + Temp = even number) and others bad (odd number).

I do not know if the error is in the very first bit read from the 40 bit stream or the last bit.

Regards,

...kevin

Question relating to:

Hi,

I am using a FRDM-K64F and the code from the repository does no work (I keep getting Err 6); The modification suggested by Antonio Buonanno (using 40 instead of 41 in the size of the bits) makes it a little bit more stable, but the issue is still around. Does anyone have an answers for that?

posted by Clovis Fritzen 26 Jun 2014

I saw the same problem and think it's fixed in this repo. Would you mind testing and reporting back? https://mbed.org/teams/components/code/DHT/

posted by Sam Grove 16 Aug 2014

5 Answers

10 years, 3 months ago.

I saw the same problem and think it's fixed in this repo. https://mbed.org/teams/components/code/DHT/ Would you mind testing and reporting back?

Accepted Answer
10 years, 8 months ago.

hi to all i use this lib for DHT11, but sumetimes i have this Err 6, do you have idea where is the problem? do you fix it?

best regards Antonio

i fix it, the problem is:

  1. define DHT_DATA_BIT_COUNT 41 change in
  2. define DHT_DATA_BIT_COUNT 40 and all work well
posted by Antoniolinux B. 06 Mar 2014
11 years, 4 months ago.

Hi Wim,

I have tried to use your lib for DHT11 but it still generates Err 7 and sometimes Err 6. The meaningful data only comes out at the first measurement. Do you have any update in your lib til now? What is the bug in your code?

Thanks, AnhNT,

8 years, 7 months ago.

There are 2-errors for DHT22. First, line 81 (_DHTtype == 11) ? wait_ms(18) : wait(1); should be (_DHTtype == 11) ? wait_ms(18) : wait_ms(1);. Second is the value returned form CalcTemperature(), CalcHumidity() have no the fractional part.

10 years, 3 months ago.

This works, no err6 (crc failure) anymore.