Arduino Forum

Using Arduino => Sensors => Topic started by: waterboy550 on Feb 01, 2011, 04:22 pm

Title: DHT11 Temp and Humidity Sensor
Post by: waterboy550 on Feb 01, 2011, 04:22 pm
I am trying to use the DHT11(http://www.robotshop.com/dfrobot-dht11-temperature-and-humidity-sensor-2.html) with my Arduino Duemilanova. I have found some code that some poeple have had some success with. Here is a link to that (http://sheepdogguides.com/arduino/ar3ne1humDHT11.htm). I however keep getting the error: "Error 1: DHT start condition 1 not met." I have the sensor plugged into analog 0, I have also tried analog pin 0-5 while changing the code to the correct 14-19 pin. Anyone have experience with this sensor and this code or any other code that has been successful with these sensors?
Title: Re: DHT11 Temp and Humidity Sensor
Post by: pwillard on Feb 01, 2011, 06:49 pm
My first question:  Why ANALOG Zero? This device communicates digitally and does not perform any analog interfacing.

http://www.micro4you.com/files/sensor/DHT11.pdf (http://www.micro4you.com/files/sensor/DHT11.pdf)

Nuelectronics also has some code for this:
http://www.nuelectronics.com/download/projects/sensor_pde/dht11.pde (http://www.nuelectronics.com/download/projects/sensor_pde/dht11.pde)

And some additional info here(which appears to be a fix for the reference code you mentioned):
http://linux-utils.blogspot.com/2010/10/dht11-arduino-with-virtualwire.html (http://linux-utils.blogspot.com/2010/10/dht11-arduino-with-virtualwire.html)





Title: Re: DHT11 Temp and Humidity Sensor
Post by: waterboy550 on Feb 01, 2011, 10:56 pm
I've looked at a few of those links and haven't had much success. I'll have more time to troubleshoot this issue tomorrow. If anyone else has some knowledge about these sensors that would be great! I'll post my results soon, hopefully  :)
Title: Re: DHT11 Temp and Humidity Sensor
Post by: waterboy550 on Feb 02, 2011, 04:59 pm
I have the sensor connected to the following things. Vcc to 5V, ground to ground, and data line to ADC0. Do I need to connect the ground and the Arduino ground?
Title: Re: DHT11 Temp and Humidity Sensor
Post by: waterboy550 on Feb 02, 2011, 05:16 pm
SOLVED:
Use this code (http://sheepdogguides.com/arduino/ar3ne1humDHT11.htm)

Make the corrections on this site (http://linux-utils.blogspot.com/2010/10/dht11-arduino-with-virtualwire.html)

Also the ground on the sensor does need to be connected to the Arduino's ground!!!!

Thanks for all the help!!!!
Title: Re: DHT11 Temp and Humidity Sensor
Post by: pwillard on Feb 02, 2011, 11:36 pm
Quote
Also the ground on the sensor does need to be connected to the Arduino's ground!!!!


Just out of curiosity... what did you connect the ground to?
Title: Re: DHT11 Temp and Humidity Sensor
Post by: carl47 on Apr 18, 2011, 08:06 am
Quote
Just out of curiosity... what did you connect the ground to?


Of course the ground must be connected to arduino earth.

They have a three pin connector which fits very neatly next to a bare 328 socket -pin 21(VCC) -pin 22(GND) -pin 23(PC0)

I have a question about this sensor available at:

http://littlebirdelectronics.com/collections/df-studio/products/dht11-temperature-and-humidity-sensor


 Using the code at:

 
http://www.dfrobot.com/image/data/DFR0067/DHT11_TEST.zip


  The read sequence gets 5 bytes. The last byte is the check sum.

  The first 4 bytes are:
  "8bit integral RH data + 8bit decimal RH data + 8bit integral T data + 8bit decimal T data".
 
  The first two bytes are humidity. The first byte is the whole number(20 to 90).
  The next byte is the decimal fraction but its always 0.
 
  The same with the the two bytes for temperature(0 to 50).

  Why bother providing the second byte in each case if its always 0?

  The Resolution is stated as 1 digit so the decimal fraction is useless?
Title: Re: DHT11 Temp and Humidity Sensor
Post by: robtillaart on Apr 18, 2011, 09:47 am
@waterboy
I recently created a library for both DHT11 & DHT 22, might be usefull, see - http://arduino.cc/playground/Main/DHTLib
Title: Re: DHT11 Temp and Humidity Sensor
Post by: carl47 on Apr 19, 2011, 06:30 am
@robtillaart

With the example code I gave above I get:

Quote
Ready
Current humdity = 70.0%  temperature = 23.0C


With your class I get:

Quote
DHT11 TEST PROGRAM
LIBRARY VERSION: 0.3.2



Read sensor: OK
Humidity (%): 70.00
Temperature (oC): 23.00
Temperature (oF): 73.40
Temperature (K): 296.15
Dew Point (oC): 17.25
Dew PointFast (oC): 17.23


I like your class and I will use it in my project.

Any thoughts on the extra byte matter that I brought up?
Title: Re: DHT11 Temp and Humidity Sensor
Post by: robtillaart on Apr 19, 2011, 11:32 am
Quote
Why bother providing the second byte in each case if its always 0?

   The Resolution is stated as 1 digit so the decimal fraction is useless?

Quote
Why bother providing the second byte in each case if its always 0?

   The Resolution is stated as 1 digit so the decimal fraction is useless?


In the DHT22 these bytes are used and contain data. The protocol to transmit the data is the same for DHT11 and DHT22, however the meaning/interpretation of the bytes transported differs.

For the DHT11 one can just skip byte 2 and 4 as they are not used. It would save 40% of the communication if they were not sent

If you have remarks or comments to improve the DHT lib,  please PM me .
Rob
Title: Re: DHT11 Temp and Humidity Sensor
Post by: carl47 on Apr 20, 2011, 02:35 am
Thanks for your answer Rob.

I understand now.

cheers   :)