Commit 59a95097 authored by Damien George's avatar Damien George
Browse files

esp8266/modules/ds18x20.py: Add support for DS18S20 devices.

parent 8e9b98e9
......@@ -11,7 +11,7 @@ class DS18X20:
self.buf = bytearray(9)
def scan(self):
return [rom for rom in self.ow.scan() if rom[0] == 0x28]
return [rom for rom in self.ow.scan() if rom[0] == 0x10 or rom[0] == 0x28]
def convert_temp(self):
self.ow.reset(True)
......@@ -35,4 +35,12 @@ class DS18X20:
def read_temp(self, rom):
buf = self.read_scratch(rom)
return (buf[1] << 8 | buf[0]) / 16
if rom[0] == 0x10:
if buf[1]:
t = buf[0] >> 1 | 0x80
t = -((~t + 1) & 0xff)
else:
t = buf[0] >> 1
return t - 0.25 + (buf[7] - buf[6]) / buf[7]
else:
return (buf[1] << 8 | buf[0]) / 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