diff --git a/adafruit_mcp9808.py b/adafruit_mcp9808.py index 46e1a00..c48c28c 100644 --- a/adafruit_mcp9808.py +++ b/adafruit_mcp9808.py @@ -75,16 +75,16 @@ def __init__(self, i2c_bus, address=0x18): self.buf = bytearray(3) self.buf[0] = 0x06 with self.i2c_device as i2c: - i2c.write(self.buf, end=1, stop=False) - i2c.readinto(self.buf, start=1) + i2c.write_then_readinto(self.buf, self.buf, + out_end=1, in_start=1) ok = self.buf[2] == 0x54 and self.buf[1] == 0 # Check device id. self.buf[0] = 0x07 with self.i2c_device as i2c: - i2c.write(self.buf, end=1, stop=False) - i2c.readinto(self.buf, start=1) + i2c.write_then_readinto(self.buf, self.buf, + out_end=1, in_start=1) if not ok or self.buf[1] != 0x04: raise ValueError("Unable to find MCP9808 at i2c address " + str(hex(address))) @@ -94,8 +94,8 @@ def temperature(self): """Temperature in celsius. Read-only.""" self.buf[0] = 0x05 with self.i2c_device as i2c: - i2c.write(self.buf, end=1, stop=False) - i2c.readinto(self.buf, start=1) + i2c.write_then_readinto(self.buf, self.buf, + out_end=1, in_start=1) # Clear flags from the value self.buf[1] = self.buf[1] & 0x1f