This page describes how to use the I2C devices on the BeagleBone and the BeagleBone Black.
On the BeagleBone Black, it's not all of the /dev/i2c-* devices that are enabled by default. The other i2c devices must be enabled before they can be used.
To enable the I2c-1 on the BeagleBone Black Rev A, B and C:
After reboot, the device is present in the device list:
Note: The I2C devices do not map one-to-one with the devices in /dev/. I.e. I2C-1 does not necessarily map to /dev/i2c-1, it could just as well be one of the other devs, e.g. /dev/i2c-2.
You can use the standard Linux i2c tools to test your i2c setup:
List all the enabled devices:
Scan all addresses on one device:
Write one byte to a device and an address:
Read one byte from a device and an address:
- npm install i2c
- npm install bonescript
I've had some problems with crashes in the i2c module (segmentation faults).
If you just need to read and write single bytes, you can also do this using normal file system (open /dev/i2c-1 for read+write) and set the device address using the "ioctl" module:
- npm install ioctl
The code sequence:
1. Open /dev/i2c-1 for read+write
2. Use ioctl to set slave address: ioctl(fileHandle, I2C_SLAVE, address)
(I2C_SLAVE = 0x0703 )
Using the BeagleBone >