Negative temperature measures
-
Hi Charles-Henri,
I am using your excellent TH02 library on Moteino. I have one sensor outside my house, with minus degrees celsius. However the TH02 lib reports the absolute value, without the minus prefix. E.g. “6.5” instead of “-6.5″. Please advise on what I am doing wrong.
Merci beacoup,
KarimFrom the Arduino sketch:
int16_t temp, rh, rh_comp; //uint8_t status; Serial.print(F("Starting Temperature conversion.")); sensor.startTempConv(); sensor.waitEndConversion(); Serial.println(F(".done!")); // Get temperature calculated and rounded temp = sensor.getConversionValue(); // Display unrounded value (raw) Serial.print(F("Temperature = ")); // this call does not do any I2C reading, it use last reading Serial.print(sensor.getLastRawTemp()/100.0); Serial.print(F(" C => ")); // Display now rounded value returned by 1st call Serial.print(temp/10.0); Serial.println(F(" C"));
-
Karim,
Would you try to modify the following line (261 to 269) to the library th02.cpp
if(result >= 5000) { result -= 5000; } else { result -= 5000; result = -result; }
by
result -= 5000;
Let me know if it works, I don’t understand why I’ve done like that
-
Changes done to th02.cpp. Thanks! Seems to be working fine ::
NEGATIVE TEMP:
Starting Temperature conversion..done!
Temperature = -7.00 C => -7.00 CStarting Temperature conversion..done!
Temperature = -5.82 C => -5.80 CStarting Temperature conversion..done!
Temperature = -2.10 C => -2.10 CStarting Temperature conversion..done!
Temperature = -0.79 C => -0.80 CPOSITIVE TEMP:
Starting Temperature conversion..done!
Temperature = 1.43 C => 1.40 CStarting Temperature conversion..done!
Temperature = 2.87 C => 2.90 C -
Excellent,
I will modify the lib on github
Charles