How can I interface an I2C device with BeagleBone Black running Embedded Linux
Hello guys, how can I interface an I2C device with BeagleBone Black running Embedded Linux for my home automation system?. I have connected the I2C device to the appropriate pins on the BeagleBone Black, enabled the I2C interface on the BeagleBone Black, wrote a C program to communicate with the I2C device using the I2C bus. But keep encountering
Failed to open the I2C bus.
this is my code
@Middleware & OSSolution:Jump to solution
@Boss lady if the devices exist, then the next thing I would check are the permissions. Having just taken a quick look on mine...
```
debian@BeagleBone:~$ ls -l /dev/i2c-*
crw-rw---- 1 root gpio 89, 0 May 17 12:23 /dev/i2c-0
crw-rw---- 1 root gpio 89, 1 May 17 12:23 /dev/i2c-1...
5 Replies
@Boss lady Do you have the i2c devices showing up in
/dev
yet? If not, the code will never run.Can I check it using
ls /dev/i2c
Yes - though use
ls /dev/i2c*
Yes the i2c devices are present
Solution
@Boss lady if the devices exist, then the next thing I would check are the permissions. Having just taken a quick look on mine...
Then that shows me they are only readable by the root user and anyone belonging to the
gpio
group.
First thing to try is therefore running you program with sudo
. If that works, then it is likely to be a permission issue. If it works, then the simplest solution would be to add yourself to the gpio
group.