Pages: [1]   Go Down
Author Topic: Can't get proper value from DHT11  (Read 455 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using the code shown here (http://sheepdogguides.com/arduino/ar3ne1humDHT11.htm) with the DHT11 temperature / humidity sensor. This code works great and print the output to the serial port without a problem. I want to change the code and plug the values into variables. I have no idea where to start as the data is currently stored in a byte (i think). Any knowledge about this subject would be great.
Logged

Sydney, Australia
Offline Offline
Full Member
***
Karma: 3
Posts: 230
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What are you actually trying to achieve? To pull the results out into some variables is trivial based on how I think it works.

Code:
float humidity;
...
ReadDHT();//This is the "heart" of the program.
...
humidity = dht_dat[0] + dht_dat[1] / 100;

That should give you a floating point value corresponding to the current humidity returned. You could print that back out to ensure you're getting the same value...

Never having used that sensor, nor read its datasheet, the above might not be exact, but it'll be close.


G.
Logged

Is life really that serious...??!

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

WOW... I feel very stupid. This works great! I was trying to use int and double and this would fail. Float seemed to do the trick. Thanks!
Logged

Pages: [1]   Go Up
Jump to: