def read(pin): _onewire.reset(Pin(pin)) _onewire.writebyte(Pin(pin), 0xcc) #skip rom _onewire.writebyte(Pin(pin), 0xbe) #read scratchpad #read raw temperature tlo = _onewire.readbyte(Pin(pin)) thi = _onewire.readbyte(Pin(pin)) _onewire.reset(Pin(pin)) #convert raw values to human eye readable temp = tlo + thi * 256 if temp > 32767: temp = temp - 65536 temp = temp * 0.0625 return (temp)
def read(self, count): buf = bytearray(count) for i in range(count): buf[i] = _ow.readbyte(self.pin) return buf
def readbyte(self): return _ow.readbyte(self.pin)
def readinto(self, buf): for i in range(len(buf)): buf[i] = _ow.readbyte(self.pin)
def read_bytes(self, count): buf = bytearray(count) for i in range(count): buf[i] = _ow.readbyte(self.pin) return buf