Go Down

Topic: Can't get proper value from DHT11 (Read 515 times) previous topic - next topic

waterboy550

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.

pocketscience

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: [Select]
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.
Is life really that serious...??!

waterboy550

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!

Go Up