File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -745,10 +745,17 @@ float DallasTemperature::rawToCelsius(int16_t raw) {
745745
746746}
747747
748- // convert from Celsius to raw
748+ // Convert from Celsius to raw returns temperature in raw integer format.
749+ // The rounding error in the conversion is smaller than 0.01°C
750+ // where the resolution of the sensor is at best 0.0625°C (in 12 bit mode).
751+ // Rounding error can be verified by running:
752+ // for (float t=-55.; t<125.; t+=0.01)
753+ // {
754+ // Serial.println( DallasTemperature::rawToCelsius(DallasTemperature::celsiusToRaw(t))-t, 4 );
755+ // }
749756int16_t DallasTemperature::celsiusToRaw (float celsius) {
750757
751- return static_cast <uint16_t >( celsius * 128 .f ); // this just discards of the decimal part (rounds towards zero)
758+ return static_cast <uint16_t >( celsius * 128 .f );
752759}
753760
754761// convert from raw to Fahrenheit
You can’t perform that action at this time.
0 commit comments