Raspberry Pi i2c Read/Write Error

喜欢而已 提交于 2019-12-12 11:34:15

问题


Like many people, I've had a Pi for a while but never really done anything with it. I've finally got round to hooking up an MPU6050 IMU to play around with. It uses i2c for communication so I followed the guide by Adafruit regarding enabling i2c shown here Adafruit i2c.

I then hooked up the MPU6050 to the i2c bus, and using i2cdetect -y 1 I was able to see a device at 0x68.

However, when trying to read or write from the device I got a permission denied error, so I followed this post to solve that problem /dev/i2c-x permission. It told me to modify /lib/udev/rules.d/60-i2c-tools.rules with

KERNEL=="i2c-0"     , GROUP="i2c", MODE="0660"
KERNEL=="i2c-[1-9]*", GROUP="i2c", MODE="0666"

This worked, but then when actually trying to read or write using C++, I get "Input/output error". Similarly, using smbus in Python I get [Errno 5] Input/output error When connected to an Arduino I can get this device to work perfectly.

I've exhausted every forum post I can find. Hopefully I've just done something stupid. Anyone got any ideas?

Original model B RPi running Raspbian, if that's of any help.

Cheers

来源:https://stackoverflow.com/questions/38815505/raspberry-pi-i2c-read-write-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!