使用I2C时报错OSError: [Errno 5] EIO
-
from pyb import I2C, Pin i2c = I2C(2, I2C.MASTER) data = i2c.mem_read(0x5a, 0x07, 2) print( ustruct.unpack('<H', data)[0])
Traceback (most recent call last):
File "", line 6, in
OSError: [Errno 5] EIO
MicroPython: v1.13-r22 OpenMV: v3.8.0 HAL: v1.9.0 BOARD: OPENMV4P-STM32H743
Type "help()" for more information.
-
你的i2c设备连接好了吗?
-
连接好了啊
-
@kidswong999 连接好了,电路图也贴出来了
-
from pyb import I2C i2c = I2C(2, I2C.MASTER) # The i2c bus must always be 2. print(i2c.scan())
运行这个代码,看看打印出来的设备的地址。
-
@kidswong999
MicroPython v1.12-omv OpenMV v3.6.8 2020-09-28; OPENMV4-STM32H743
Type "help()" for more information.
‘>>> [ ]