DHT-11 Temperature & Humidity sensor

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Anyone have experience with this unit?

I successfully got it working with an attiny2313, however the humidity readings are way off what my home weather station shows. The DHT-11 shows 19% Rel Humidity while the weather station shows 37%. I am inclined to believe the weather station.

The DHT-11 does however, show the correct temperature (it matches the other thermometers I have).

Anyone know of any other humidity sensors I can buy that are reasonable in price (NOT $25)?

Anyone?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've not looked, but is there a way to calibrate the sensor? If not, you can simply apply an adjustment factor in your program to compensate for the difference.
No need to chuck it out, unless it's totally unreliable.

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i don't think its totally unreliable, it is however consistently wrong.

I thought there might be a more accurate sensor available without spending too much $$.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The reading is off by x2.... 1 bit.... try changing the spi clock phase?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The DHT-11 does not use SPI, it uses a variation of the 1 wire protocol. As I mentioned before, The temperature is reading accurately. Here is my code:

;--------------------------------
;Start bit looks like this
;     18mS      ________    80uS    __________   1st bit begins here
;|_____________|  40uS  |__________|   80uS   |__________
;master has    |now slave sends response
;control of    |
;line to here  |
;
ReadDHT:
	ldi	flags,0
	cbi	DQPORT,DQ		;data line low for 18mS (Start bit)
	sbi	DQDDR,DQ		;data line = output

	ldi	temp,19
	mov	dcount,temp	
	rcall	Delay
	
	cbi	DQDDR,DQ		;data line = input
					;data line should be high from slave

	rcall	Delay_10us  	;release data line for more than 40uS 
	rcall	Delay_10us   
	rcall	Delay_10us   
	rcall	Delay_10us
 	rcall Delay_10us
	
	sbic	DQPIN,DQ		;if line not low by now (50uS), exit (error)
	rjmp	ReadDHT_END_1

	clr   temp
ReadDHT1:				;line is low now, wait until it goes high
	inc   temp
	sbic	DQPIN,DQ		;if line not low by now, exit (error)
	rjmp	ReadDHT1_END

	cpi	temp,0
	brne	ReadDHT1		;loop until line high or timeout
  	rjmp 	ReadDHT_END_2

ReadDHT1_END:
	clr  	temp
ReadDHT2:				;line high, wait for line to go low
	inc	temp
	sbis	DQPIN,DQ		;if line low, jump to ReadDHT2_END
	rjmp	ReadDHT2_END

	cpi	temp,0
	brne	ReadDHT2		;loop until line low or timeout
  	rjmp 	ReadDHT_END_3

ReadDHT2_END:
	clr	CKSUM				;
	rcall	ReadByte			;			
	sts	RH_data_H,temp		;
	add	CKSUM,temp			;

	rcall	ReadByte			;
	sts	RH_data_L,temp		;
	add	CKSUM,temp			;

	rcall	ReadByte			;
	sts	T_data_H,temp		;
	add	CKSUM,temp			;

	rcall	ReadByte			;
	sts	T_data_L,temp		;
	add	CKSUM,temp			;

	rcall	ReadByte			;
	cp	CKSUM,Temp			;	
	brne	ReadDHT_END_4		;

ReadDHT_END:
	cbi	DQDDR,DQ			;release data line
	ret

ReadDHT_END_1:
	ldi	flags,1
	rjmp	ReadDHT_END

ReadDHT_END_2:
	ldi	flags,2
	rjmp	ReadDHT_END

ReadDHT_END_3:
	ldi	flags,3
	rjmp	ReadDHT_END

ReadDHT_END_4:
	ldi	flags,4
	rjmp	ReadDHT_END
;--------------------------------
;we get here when data line is low
;first half of bit always begins low
;                  ____
;a "0" bit = _____|30uS|
;            50uS
;                  _______
;a "1" bit = _____| 70uS  |
;            50uS
;
ReadByte:
	ldi	bitcnt,8
	clr	DByte

ReadByteLP:		
	clr	temp
ReadDHT3:
	inc	temp
	sbic	DQPIN,DQ		;wait for data line to go high
	rjmp	ReadDHT3_END	;jump if data line high 
	cpi	temp,46
	brne	ReadDHT3	
	rjmp	ReadByteEnd		;waiting too long, timeout after 75uS

ReadDHT3_END:
	rcall	Delay_30us  	;data line should be high for min 26-28 uS	
	
	clc
	sbic	DQPIN,DQ		;if line low after 30uS, bit = 0
	sec				;if line still high after 30uS, bit = 1
	rol	dbyte			;shift bit to Bit0 of DByte
      
	clr	temp			;now wait for line to go low for nextbit
ReadDHT4:
	inc	temp
	sbis	DQPIN,DQ		;wait for data line to go low again (next bit)
	rjmp	ReadDHT4_END 

	cpi	temp,0
	brne	ReadDHT4
	rjmp	ReadByteEnd		;waiting too long, timeout after 500uS

ReadDHT4_END:
	dec	bitcnt
	brne	ReadByteLP
	mov	temp,DByte
ReadByteEnd:
	ret

the readings come out in hex and are then converted to bcd using bin2bcd8 routine, then they are displayed to a terminal.

;***************************************************************************
;* "bin2BCD8" - 8-bit Binary to BCD conversion
;* This subroutine converts an 8-bit number (temp) to a 2-digit 
;* i.e 0x15 becomes 0x21
;* result in temp
;***************************************************************************
;.def	tBCD	= r21			;add this to main asm file
;
bin2bcd8:
	clr	tBCD			;clear temp reg
bBCD8_1:
	subi	Temp,10		;input = input - 10
	brcs	bBCD8_2		;abort if carry set
	subi	tBCD,-$10 		;tBCD = tBCD + 10
	rjmp	bBCD8_1		;loop again
bBCD8_2:
	subi	Temp,-10		;compensate extra subtraction
	add	Temp,tBCD	
	ret
;*********************************************
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi!
I have the same problem. I received my DHT11 sensors from China yesterday and I also have a weather station at home. Weather station shows 32%, DHT11 shows 14%! Temperature readings are accurate.

The datasheet of the DHT11 says: 20-90%, how can it show 14% then? Should it be interpreted as 20 + 14% ?

One more thing: I use my own implementation of the protocol and CRC checks never fail.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't have my old project notes available at the time, but I've seen the differences, also.

I have several of the first release units, and several from various batches over the years. Note that the coefficients for calculating the values vary with the exact version of the sensor.

Also be sure you aged the sensor before comparing its measurements. Give it a day after you solder it.

Make sure you do not have the internal heater on.

Make sure it was not in 100% humidity and has condensation inside the sensor.

Even doing all of this I've still seen at least 10% variations between several other products and my Sensirion PCBs.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi!
I did not solder it , I put it into a 4-pin header. So soldering shouldn't be a problem.

What do you mean by internal heater?

I also saw a chinese video about the DHT-11 (http://v.youku.com/v_show/id_XMj...), in this video they also have these unbelievable low humidity values.

At low humidity levels it looks like that the readings are of by about 18% but, yesterday evening I made some tests in the bathroom and both sensors (Weather station, DHT11) showed 85% after a 10 minute shower with closed window. Today I will try to raise the humidity of my room to 45-50% and see what happens.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My mistake, :oops: I was thinking abut the SHT-11 Temp & Humidity sensor, not the DHT-11 Temp & Humidity sensor.

I suspect most of the comments apply to both, however.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the meantime, I am ready with testing, the readings are always off by 20. Just add 20 to the results. :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I bought 3 of them and each sensor shows different humid reading. One shows 39%, other 48 and 17%.
This makes no sense at all!
Readings should be good because CRC check is always ok!

I thing they are cheap and very bad quality, that's all.

But I'm worried about sht11 sensor, this should be accurate (and costly), are they really good ?

Does anyone have experience with sht11?
I would like to know them better before buying them :)

Regards
filip

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do we create a 100% RH situation? Put a box over a teakettle on the stove? See if they all read within 10% at 90% RH?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bobgardner wrote:
How do we create a 100% RH situation? Put a box over a teakettle on the stove? See if they all read within 10% at 90% RH?

In your case, Bob, since you live in Orlando Florida, just step outside the air conditioned space at 4pm on an average summer's day!
:lol:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've used the SHT21 and it seems to be accurate, it also handles the rain, snow and direct sunlight without much trouble...

http://krazatchu.ca/2010/08/19/w...

Michael

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey guys,
older post here, but I was wondering if anyone found a way to use these DHT11 sensors? I have exactly the same problems, where the readings are far too low, and also vary widely between identical sensors. Temperature is always accurate, but RH is all over the place, and when placed in known RH environments, they are nowhere near correct. I'm an Arduino guy myself.

So, is the verdict to chuck these things and go with the DHT22, or SHT11, or possibly another option? I don't mind paying for a better sensor if that's the answer, but I dont want to throw money at the problem, if we're just not reading the data back correctly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

newbie123 wrote:
The DHT-11 does not use SPI, it uses a variation of the 1 wire protocol. As I mentioned before, The temperature is reading accurately. Here is my code:

;--------------------------------
;Start bit looks like this
;     18mS      ________    80uS    __________   1st bit begins here
;|_____________|  40uS  |__________|   80uS   |__________
;master has    |now slave sends response
;control of    |
;line to here  |
;
ReadDHT:
	ldi	flags,0
	cbi	DQPORT,DQ		;data line low for 18mS (Start bit)
	sbi	DQDDR,DQ		;data line = output

	ldi	temp,19
	mov	dcount,temp	
	rcall	Delay
	
	cbi	DQDDR,DQ		;data line = input
					;data line should be high from slave

	rcall	Delay_10us  	;release data line for more than 40uS 
	rcall	Delay_10us   
	rcall	Delay_10us   
	rcall	Delay_10us
 	rcall Delay_10us
	
	sbic	DQPIN,DQ		;if line not low by now (50uS), exit (error)
	rjmp	ReadDHT_END_1

	clr   temp
ReadDHT1:				;line is low now, wait until it goes high
	inc   temp
	sbic	DQPIN,DQ		;if line not low by now, exit (error)
	rjmp	ReadDHT1_END

	cpi	temp,0
	brne	ReadDHT1		;loop until line high or timeout
  	rjmp 	ReadDHT_END_2

ReadDHT1_END:
	clr  	temp
ReadDHT2:				;line high, wait for line to go low
	inc	temp
	sbis	DQPIN,DQ		;if line low, jump to ReadDHT2_END
	rjmp	ReadDHT2_END

	cpi	temp,0
	brne	ReadDHT2		;loop until line low or timeout
  	rjmp 	ReadDHT_END_3

ReadDHT2_END:
	clr	CKSUM				;
	rcall	ReadByte			;			
	sts	RH_data_H,temp		;
	add	CKSUM,temp			;

	rcall	ReadByte			;
	sts	RH_data_L,temp		;
	add	CKSUM,temp			;

	rcall	ReadByte			;
	sts	T_data_H,temp		;
	add	CKSUM,temp			;

	rcall	ReadByte			;
	sts	T_data_L,temp		;
	add	CKSUM,temp			;

	rcall	ReadByte			;
	cp	CKSUM,Temp			;	
	brne	ReadDHT_END_4		;

ReadDHT_END:
	cbi	DQDDR,DQ			;release data line
	ret

ReadDHT_END_1:
	ldi	flags,1
	rjmp	ReadDHT_END

ReadDHT_END_2:
	ldi	flags,2
	rjmp	ReadDHT_END

ReadDHT_END_3:
	ldi	flags,3
	rjmp	ReadDHT_END

ReadDHT_END_4:
	ldi	flags,4
	rjmp	ReadDHT_END
;--------------------------------
;we get here when data line is low
;first half of bit always begins low
;                  ____
;a "0" bit = _____|30uS|
;            50uS
;                  _______
;a "1" bit = _____| 70uS  |
;            50uS
;
ReadByte:
	ldi	bitcnt,8
	clr	DByte

ReadByteLP:		
	clr	temp
ReadDHT3:
	inc	temp
	sbic	DQPIN,DQ		;wait for data line to go high
	rjmp	ReadDHT3_END	;jump if data line high 
	cpi	temp,46
	brne	ReadDHT3	
	rjmp	ReadByteEnd		;waiting too long, timeout after 75uS

ReadDHT3_END:
	rcall	Delay_30us  	;data line should be high for min 26-28 uS	
	
	clc
	sbic	DQPIN,DQ		;if line low after 30uS, bit = 0
	sec				;if line still high after 30uS, bit = 1
	rol	dbyte			;shift bit to Bit0 of DByte
      
	clr	temp			;now wait for line to go low for nextbit
ReadDHT4:
	inc	temp
	sbis	DQPIN,DQ		;wait for data line to go low again (next bit)
	rjmp	ReadDHT4_END 

	cpi	temp,0
	brne	ReadDHT4
	rjmp	ReadByteEnd		;waiting too long, timeout after 500uS

ReadDHT4_END:
	dec	bitcnt
	brne	ReadByteLP
	mov	temp,DByte
ReadByteEnd:
	ret

the readings come out in hex and are then converted to bcd using bin2bcd8 routine, then they are displayed to a terminal.

;***************************************************************************
;* "bin2BCD8" - 8-bit Binary to BCD conversion
;* This subroutine converts an 8-bit number (temp) to a 2-digit 
;* i.e 0x15 becomes 0x21
;* result in temp
;***************************************************************************
;.def	tBCD	= r21			;add this to main asm file
;
bin2bcd8:
	clr	tBCD			;clear temp reg
bBCD8_1:
	subi	Temp,10		;input = input - 10
	brcs	bBCD8_2		;abort if carry set
	subi	tBCD,-$10 		;tBCD = tBCD + 10
	rjmp	bBCD8_1		;loop again
bBCD8_2:
	subi	Temp,-10		;compensate extra subtraction
	add	Temp,tBCD	
	ret
;*********************************************

Hi,

Thanks for the code, it helped a lot.
I believe this should work on DHT22(similar sensor to DTH11) as well?

Is there anything i should change?

Thanks

Martin