box humidity DHT11

My intent is to get a reading of humidity and temperature from the DHT11, show it on a LCD and also to check if the readings require a relay to turn on a mister, or to turn on a heater.

I found this sketch which seems to do much of what I want:
http://arduino-info.wikispaces.com/PROJECT-Temp-Humidity-Display

I am not understanding which variable will give me the current humidity and which the current temperature so that I can apply some if/else logic to the reading. I would very much appreciate someone looking at the sketch and advising me which variable to use.

Robin

The sketch does not use variables for temperature and humidity. Rather, it creates a DHT11 object and uses methods from this object to print the temperature and humidity.

lcd.print(" F=");
  lcd.print(Fahrenheit(DHT11.temperature), 0);
  Serial.print("Temperature (oF): ");
  Serial.println(Fahrenheit(DHT11.temperature), 2);
  
  lcd.print("  H=");
  lcd.print((float)DHT11.humidity, 0);
  lcd.print("%");
  Serial.print("Humidity (%): ");
  Serial.println((float)DHT11.humidity, 2);

You could create variables, say, float tempFahr, and assign it tempFahr = Fahrenheit(DHT11.temperature) . I think adafruit has a simpler sketch for this sensor. I found a DHT22 sketch there.

Bruce

Thanks Bruce

I found the adafruit sketch. In it they advise using a 10k resistor on pins 1-2 of the sensor but I also note that they are covering a number of different DHT type sensors.

On the sketch I referred to above they did not make that suggestion and I found it worked without the resistor on the DHT11. Should I opt for a 10k resistor with the UNO dispite it working without it?

If in doubt check the data sheet. From memory the DHT11 and DHT22 require different value resistors. If you choose not to use one despite it appearing to work then don't be too surprised if you have strange problems further down the line.

dannable:
If in doubt check the data sheet. From memory the DHT11 and DHT22 require different value resistors. If you choose not to use one despite it appearing to work then don't be too surprised if you have strange problems further down the line.

Sorry for the intromission, but i have a question to what you just said: if you don't use a resistor, is it possible to damage the sensor? I was able to get a reading or two, and then it stopped reporting...

The sensor should not be damaged by it but you might get faulty readings.

The longer the wires you use the bigger the chance on bad readings.

robtillaart:
The longer the wires you use the bigger the chance on bad readings.

I think this is normal length:
That's why i am very confused.

this length should not give such problems.

Which library do you use?

Do you take enough time between readings? 2 seconds - check datasheet)

robtillaart:
this length should not give such problems.
Which library do you use?

Used your library DHTlib, with the test program dht11_test :frowning:

I just get DHTLIB_ERROR_ACK_H from it.

Edit: just tried again with another board i have (Jeenode v6) and was able to get it working with your library. Still it baffles me why it would not work with Arduino UNO v3. Any ideas? I must be overlooking something stupid

Please use the attached version 0.1.13 which is most stable version

dht 0.1.13.zip (2.17 KB)

robtillaart:
Please use the attached version 0.1.13 which is most stable version

Strangely enough, with that version if keep getting the "timeout" error with Arduino UNO R3 :confused:

Timeout error has been refined to some more detailed errors incl DHTLIB_ERROR_ACK_H

The DHTLIB_ERROR_ACK_H indicates that the sensor does not react on its initial handshake any more.

Can it be that you switched +5V and GND and/or blew the sensor otherwise?

please double check wiring.