Code: Select all
import machine as mc
import ustruct
timebuf = bytearray(7)
i2c = mc.I2C(scl=mc.Pin(5), sda=mc.Pin(4), freq=100000)
ustruct.unpack("<h", i2c.readfrom_mem(104,timebuf,0))[0]
>> TypeError: can't convert bytearray to int
Code: Select all
import machine as mc
import ustruct
timebuf = bytearray(7)
i2c = mc.I2C(scl=mc.Pin(5), sda=mc.Pin(4), freq=100000)
ustruct.unpack("<h", i2c.readfrom_mem(104,timebuf,0))[0]
>> TypeError: can't convert bytearray to int
Code: Select all
readfrom_mem(addr, memaddr, nbytes, *, addrsize=8)