Commit e5f06559 authored by ernitron's avatar ernitron Committed by Damien George
Browse files

esp8266/modules: Fix negative temperature in ds18x20 driver.

parent 10bde693
......@@ -43,4 +43,7 @@ class DS18X20:
t = buf[0] >> 1
return t - 0.25 + (buf[7] - buf[6]) / buf[7]
else:
return (buf[1] << 8 | buf[0]) / 16
t = buf[1] << 8 | buf[0]
if t & 0x8000: # sign bit set
t = -((t ^ 0xffff) + 1)
return t / 16
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment