Go Down

Topic: yet another DHT11 Class for Arduino (Read 16 times) previous topic - next topic

robtillaart


Posted another DHT11 class on the playground - http://arduino.cc/playground/Main/DHT11Lib

The class is based upon earlier work of George Hadjikyriacou and augmented by SimKard and RobTillaart. The main difference with other DHT11 classes is the support of two dewpoint() formulas, one as used by the NOAA and another faster and smaller one. The price for this is an inaccuracy of max 0.6544 C which is lower than the accuracy of the DHT11 sensor itself. The library is tested on an MEGA2560.

For positive temp values the library might be compatible with the DHT22, but this is not tested.

As allways comments and remarks are welcome.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

GaryP

Great! Just few hours ago ordered two of them, even not being sure if I can handle them!
Now there's a hope!

Cheers,
Kari
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

robtillaart

Hi Kari,

What platform do you intend to use it? The lib is just released and not tested on an UNO/2009. I hope you will provide feedback so I can improve the lib if needed.

Tia,
Rob
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

GaryP

Rob,
I have Mega 1280, Nano, Duemilanove and Pro mini. I will tell how it goes, asap, after I just got that part.
:|
Thanks in advance!

Cheers,
Kari
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

robtillaart

An updated version 0.3.2 is posted on the playground.

Major changes:
- read() function does not stall anymore
- temperature and humidity back to int as DHT11 does not support decimal fraction.
- dewpoint() and other non DHT11 specific functions are removed from the class (but kept in the demo sketch),

This results in a smaller lib as no floating point is used in the lib anymore.

feedback welcome
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Vahan

The new 0.3.2 version is giving erroneous results:

Code: [Select]

Read sensor: OK
Humidity (%): 11110
Temperature (oC): 11100
Temperature (oF): 82.40
Temperature (K): 301.15
Dew Point (oC): 8.83
Dew PointFast (oC): 8.79

robtillaart

#6
Apr 03, 2011, 10:38 am Last Edit: Apr 03, 2011, 10:51 am by robtillaart Reason: 1
@Vahan
Which platform do you use? UNO/ MEGA?

Strange that both values read as BINARY. When I make a decimal representation of they are realistic values. I'think it is a minor issue in the test application, I'll dive into it.

Humidity (%): 11110 = 30
Temperature (oC): 11100 = 28

This is confirmed by the value for Fahrenheid() and Dewpoint()

is 28 C a reasonable value for you? I don't know where you live, but for me it is not an extreme

Update

It is a bug in the example sketch. The integer value is presented as BINARY as the value 2 in the println statement is interpreted as the BINARY flag for integers iso 2 decimal places for a float. A cast is needed.

replace the corresponding lines in the test app to :  

Code: [Select]
 Serial.print("Humidity (%): ");
 Serial.println((float)DHT11.humidity, 2);

 Serial.print("Temperature (oC): ");
 Serial.println((float)DHT11.temperature, 2);


I will fix the code in the playground article,
Thanx for this feedback,
Rob
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

thom--s

Hi Rob,

I'm working with Arduino mega 2560 and dht11 sensor. I have tried the code (0.3.2 version). It work without error, but, unfortunately the measurement don't work and seem to be constant all the time (also the temperature reading is out of measurement range). Here is the results of my measurement (from serial monitor).

______________________
Read sensor: OK
Humidity (%): 66.00
Temperature (oC): 60.00
Temperature (oF): 140.00
Temperature (K): 333.15
Dew Point (oC): 51.24
Dew PointFast (oC): 51.29
______________________


I bought the sensor 2 weeks ago, and I have used it since yesterday. I tested the sensor using this code http://www.dfrobot.com/wiki/index.php?title=DHT11_Temperature_and_Humidity_Sensor_%28SKU:_DFR0067%29
before I tested your code on dht11 sensor. I don't know, may be something happen to my sensor or i miss something in the code.
Perhaps someone can help me clearing this problem. I would be thankful  :)

Regards,

Thoms :)

robtillaart

Thanx for this feedback,

A few questions:
- what was the real temperature? / how far was the measurement off ?

- was the humidity right?

- what was the output of the other sketch from dfrobot?

- if you breath to the sensor does the values change?
  if so how?

- can you measure the voltage applied to the sensor?

- are you sure you have a DHT11? A DHT22 looks the same, talks the same but data must be interpreted differently
  you can test this with - http://arduino.cc/playground/Main/DHTLib -

These questions help me to get a better picture what could cause the readings.
regards,
Rob
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

thom--s

Hi Rob, thanx for the response.

- what was the real temperature? / how far was the measurement off ?
# the real temperature is about 25OC, and the measurement off is about 60 - 25 C = 35 C. 

- was the humidity right?
# the real humidity is about 80%.

- what was the output of the other sketch from dfrobot?
# The output was error status, because I didn't use sensor shield as the recommendation.

- if you breath to the sensor does the values change?
  if so how?
# I have tried to do that, but the reading temperature and humidity doesn't change, even I use my laptop exhaust.

- can you measure the voltage applied to the sensor?
# Ya, I checked the sensor voltage (GND & Signal) and the power pin (VCC & GND). Both of them had same voltage, about 4.96 V.

- are you sure you have a DHT11? A DHT22 looks the same, talks the same but data must be interpreted differently
  you can test this with - http://arduino.cc/playground/Main/DHTLib -
# I am pretty sure that my sensor is DHT11 (as written in the sensor board). I have tried DHTLib from http://arduino.cc/playground/Main/DHTLib, and the result didn't change at all, temperature 60 C and humidity 66 %.

I also read digital signal from the sensor using basic example from arduino DigitalReadSerial (without delay), and the result in serial monitor is 1111111 all the time.

I wonder if the problem come from the sensor.

Regards,

Thoms :)

robtillaart

As the lib proofed to work with other sensors everything points to the sensor.

Q: Do you have a chance to try the sensor with an UNO board?

Q2: Have you tried other pins on the MEGA?
     have the pins you used other functions?    // don't have a MEGA myself
     or internal pullups or so?

Rob
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

thom--s

Hi Rob,
Thanks for your help and guidance.
Yesterday, I did the measurement using Arduino Duemilanove, but the results still didn't change at all. Also, it didn't work with another pin on my MEGA.
Luckily, another dht11 sensor came yesterday. I tried the new dht11, and voila! it works  :)
I think the problem is the sensor. When I uploaded code from DFrobot (that suggest to use sensor shield), I forgot to unplug my dht11 signal wire from arduino digital pin. And my guest, the dht11 ADC was damaged when I uploaded the code. I don't want to verify my guess, but if that (the problem) happen to someone, please let the others know for verification by posting in this forum. I would be thankful :D

regards,

thoms

robtillaart


Sorry for the broken sensor, on the datasheet there is a procedure to recalibrate, might be a last resort to get life back in.

As the sensor never worked you might send it back to get a refund/new one (depends on the shop)

You can also try to disect it ....

Did you use my DHTlib on the good sensor?  I like all - esp. positive - feedback ;)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

thom--s

Ya, I use your DHTlib on the good sensor :D
So that, I don't need to buy sensor shield for my simple project. :)
Btw, thanks a lot for sharing.


Regards,

thoms

arcs_n_sparks


I don't know, may be something happen to my sensor or i miss something in the code.
Perhaps someone can help me clearing this problem. I would be thankful  :)

Regards,

Thoms :)


You've installed the required pull-up resistor on the sensor?

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview