Skip to content

Commit dddf6b8

Browse files
ryespytannewt
authored andcommitted
Update adafruit_mcp9808.py (#5)
This change corrects an error in the temperature function that causes it not to return negative values for the temperature when below 0 degrees Celsius. Fixes #4
1 parent 846490f commit dddf6b8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

adafruit_mcp9808.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def temperature(self):
9696
self.buf[1] = self.buf[1] & 0x1f
9797
if self.buf[1] & 0x10 == 0x10:
9898
self.buf[1] = self.buf[1] & 0x0f
99-
return 256 - (self.buf[1] * 16 + self.buf[2] / 16.0)
99+
return (self.buf[1] * 16 + self.buf[2] / 16.0) - 256
100100
else:
101101
return self.buf[1] * 16 + self.buf[2] / 16.0
102102

0 commit comments

Comments
 (0)