Skip to content

Commit c35c41a

Browse files
authored
Merge pull request #228 from isaul32/fix-neg-temp-values
Fix negative temperature values
2 parents dbf94ad + 308b4f9 commit c35c41a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

DallasTemperature.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,9 @@ int32_t DallasTemperature::calculateTemperature(const uint8_t* deviceAddress,
710710
*/
711711

712712
if ((deviceAddress[DSROM_FAMILY] == DS18S20MODEL) && (scratchPad[COUNT_PER_C] != 0)) {
713-
fpTemperature = ((fpTemperature & 0xfff0) << 3) - 32
713+
fpTemperature = (((fpTemperature & 0xfff0) << 3) - 32
714714
+ (((scratchPad[COUNT_PER_C] - scratchPad[COUNT_REMAIN]) << 7)
715-
/ scratchPad[COUNT_PER_C]);
715+
/ scratchPad[COUNT_PER_C])) | neg;
716716
}
717717

718718
return fpTemperature;

0 commit comments

Comments
 (0)