Pages: [1]   Go Down
Author Topic: [Solved]using robs dht11 library c to f conversion is this the best way?  (Read 506 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
Serial.print(DHT.humidity, 1);
  Serial.print(",\t");
  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:
Serial.print(DHT.humidity,1);
to
Code:
Serial.print(DHT.humidity,0);
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.
« Last Edit: January 17, 2013, 08:15:33 pm by grendle » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12487
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 -

Logged

Rob Tillaart

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

Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 148
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: