11 years, 1 month ago.

DHT11 checksum error

I connected a DHT11 from dealextreme.com to my mbed and sometimes it works fine and sometimes not. I get Err 6 which means checksum is not OK. See printf below. Connections I made are 5V, data (with 4k7 pull up to 5V), nc, and GND, as prescibed. It also happens on other mbed pins, on a breadboard or in a PCB, with another DHT11 and when the DHT11 is supplied from 3v3 or 5V. Does anyone has a solution?

Temperature is 23.00 C 
Temperature is 73.40 F 
Temperature is 296.15 K 
Humidity is 35.00 
Dew point is 6.74  
Dew point (fast) is 6.71  
Temperature is 23.00 C 
Temperature is 73.40 F 
Temperature is 296.15 K 
Humidity is 35.00 
Dew point is 6.74  
Dew point (fast) is 6.71  

Err 6 

Err 6 

Err 6 

Err 6 
Temperature is 23.00 C 
Temperature is 73.40 F 
Temperature is 296.15 K 
Humidity is 35.00 
Dew point is 6.74  
Dew point (fast) is 6.71 

Question relating to:

5 Answers

10 years, 11 months ago.

Also got the checksum error (error 6), Im trying to find out where it comes from... If somebody knows it would be nice saving time :)

Accepted Answer
11 years ago.

With the AM2302 (DHT22) I get the same result. The data is read correctly sometimes, but Err 6 is also issued. I use for my test the LPC11U24 board.

Terminal Output

Temperature is 19.00 C 
Temperature is 66.20 F 
Temperature is 292.15 K 
Humidity is 42.00 
Dew point is 5.81  
Dew point (fast) is 5.79  

Err 6 

Err 6

Does anyone have any Idde?

11 years ago.

I got a dht11 just the other day, I wrote the following test program to try it out, I have had it running for hours with no problem.

  1. include "mbed.h"

/* this program interfaces a DHT11 to the pin defined as Data it reads the temperature and humidity 23-03-2013 */

  1. define timeOut 20000;

DigitalInOut Data =p19; using p19 int SensorRead(int *T,int *P );

int main() { while(1) { int Temp,Humid; wait(0.5); int x=SensorRead(&Temp,&Humid); if (x==1) printf("Time out error \n");

else if (x==2) printf("Check sum error\n"); else printf("Temperature is %d and humidity is %d\n",Temp,Humid);

} } int SensorRead(int *T,int *H )temp and humidity sensor: DHT11 { Timer t; Data.output(); set as output

Data.write(0); set it low for 18ms wait_ms(18); Data.write(1);back to 1 for 40 uSec wait_us(40); Data.input(); set as input int count=timeOut; while (Data.read()==0) if (count == 0) return 1; 1 is timeout error

count=timeOut; while (Data.read()==1) wait for line to drop if (count==0) return 1;

now ready to read 40 bits/. long long Comms=0,bit; 40 bit communication for (int i=0;i<40;i++) { start bit is zero int Length; t.reset(); reset timer count=timeOut; while(Data.read()==0) if (count==0) return 1; t.start(); start timer

count=timeOut; while (Data.read()==1) if (count==0) return 1; t.stop(); Length=t.read_us();

if (Length>40) { bit=1; bit<<=(39-i); Comms|=bit; store bit } } int chk; chk=(int)(Comms&0xff);

Comms>>=16; second last byte is of no interest

  • T=(int)Comms&0xff; store temperature Comms>>=16;
  • H=(int)Comms&0xff;

if (*H+*T!=chk) checksum error return 2;

else return 0; ok

}

11 years ago.

I have the same error , Err 6 , after Err 7. :( Anybody found the solution?

10 years, 11 months ago.

All,

See my observations on the checksum error I sent yesterday. I dug into it a little bit. The last bit of the checksum byte is not being read properly. I believe that the code is missing the very first bit (not sure though, it still reads 40 bits). After the bits are read, the code shifts all bits to the left as they are stored into DHT_data[ ] so the bytes align correctly. The shift occurs with code line "b |= ( 1 << (7-j));" . The 7 shouldn't be necessary. The author must have known there was an issue.

As long as Humidity + Temperature = an even number, there is no checksum error. If odd, there is.

http://mbed.org/questions/1053/DHT-CRC-calculation-error/

...kevin