Go Down

Topic: [Solved]using robs dht11 library c to f conversion is this the best way? (Read 1 time) previous topic - next topic


is this the easiest/best way to do C to Farenheit conversions?

Code: [Select]
Serial.print(DHT.humidity, 1);
 Serial.println(DHT.temperature*1.8+32, 1);

also, storing each in eeprom, will one byte hold the data? say 76.1? best way to do that would be appreciated thanks!

solution. changed
Code: [Select]
Code: [Select]
for the whole number. the first one gives a one place decimal point. moral of story, i learned a bit more by reading around. thank you all. kudos to rob for library, i couldnt use the dht22 library couldnt figure out conversion for life of me. this is small and compact, keep up good work you arduino folks.


Hi Grendle,

This is an easy way to convert an Celsius to a Fahrenheit temperature.
It is slow as it uses floating points math, it is relative fast as it does not use division.
Because it uses floating point is is quite accurate.
The formula works for integer and float values of Celsius. Note the DHT11 only produces integer values for temp.

A far more elaborate C2F discussion can be found here - http://arduino.cc/forum/index.php/topic,139006.0.html -

Rob Tillaart

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


thank you so much, i will read your link, appreciate all your efforts and library!


will one byte hold the data? say 76.1?

Will one byte, that holds an integral value in the range 0 to 255, hold 76.1? What do you think?
The art of getting good answers lies in asking good questions.


sigh, well put it that way, no. maybe i asked wrong, how can i store 76.1 in eeprom, doable? no? then how to round up and down in code?


Given that the sensor only returns integer values, why would you want to store a 4 byte float in EEPROM instead of a 2 byte int? Storing a 2 byte int is easy - use highByte() and lowByte() to get the bytes.
The art of getting good answers lies in asking good questions.


ok thank you, that makes sense. i appreciate the response. i think i am confusing myself and making it more difficult than it is. i will take your advice and experiment with this. thanks again for helping, Rob and Paul.

Go Up