如何修复树莓派 i2c IOError?

时间:2021-06-02 08:35:10

标签: python raspberry-pi i2c ioerror

我正在尝试在 raspberry pi 3b+ 和磁力计 (MMC5883MA-B) 之间建立连接

我正在使用原型板:https://www.mouser.fr/datasheet/2/821/MEMSIC_03052018_MMC5883MA-B%20User%20Guide-1310797.pdf

我可以使用带有输出的“i2cdetect -y 1”来设置它

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

从此我使用了代码

import smbus
DEVICE_BUS = 1
DEVICE_ADDR = 0x30
bus = smbus.SMBus(DEVICE_BUS)
bus.write_byte_data(DEVICE_ADDR, 0x00, 0x01)

并得到错误

Traceback (most recent call last): File "i2c.py", line 5, in <module> bus.write_byte_data(DEVICE_ADDR, 0x00, 0x01) IOError: [Errno 121] Remote I/O error

0 个答案:

没有答案
相关问题