Go Down

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


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.


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.

Is life really that serious...??!


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

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131