BeagleBone Black I2C References logo

BeagleBone Black I2C References

Free

I2C bus reference for BeagleBone Black

FreeFree tier
Type
Open Source

About BeagleBone Black I2C References

A technical blog post by Josh Datko providing reference notes on using I2C buses on the BeagleBone Black (BBB). Covers identification of three I2C buses (i2c0, i2c1, i2c2), their memory addresses, Linux device mapping, enabling the third bus via device tree overlay, and programming I2C devices using C with code snippets for opening the bus, initiating communication, and reading data. Includes links to kernel documentation and related tutorials.

Key Features

Identifies three I2C buses on BeagleBone Black with memory addresses
Shows how to map hardware buses to Linux device files (/dev/i2c-*)
Provides complete C code examples for I2C programming (open, ioctl, read)
Explains enabling the third I2C bus via device tree overlay (BB-I2C1)
References official Linux kernel documentation on I2C device instantiation
Links to external tutorials and community resources

Pros & Cons

Pros
  • Provides detailed mapping between hardware I2C buses and Linux device names
  • Includes practical C code snippets for common I2C operations
  • Shows how to enable the third I2C bus that is not exported by default
  • References official kernel documentation and community resources
  • Written based on hands-on experimentation with real hardware
Cons
  • Information may be outdated (blog post from 2013-2014)
  • Some details (e.g., device tree overlay paths) may differ on newer kernel versions or board revisions
  • Assumes familiarity with Linux, embedded systems, and C programming

Best For

Developing BeagleBone Black capes requiring I2C communication (e.g., CryptoCape)Interfacing I2C sensors (e.g., TMP102 temperature sensor) with BBBEmbedded systems education and experimentation with Linux I2C subsystem

FAQ

How many I2C buses does the BeagleBone Black have?
Three: i2c0, i2c1, and i2c2. However, not all are exposed on the expansion headers by default; i2c0 is not exposed, i2c1 is on pins P9 17,18 (and 24,26), and i2c2 is on pins P9 19,20 (and 21,22).
How can I enable the third I2C bus on the BeagleBone Black?
Use the command 'echo BB-I2C1 > /sys/devices/bone_capemgr.8/slots' (the number after bone_capemgr may vary). This loads a device tree overlay that exports i2c1.
How do I program I2C in C on the BeagleBone Black?
Open the appropriate /dev/i2c-N file, set the slave address using ioctl with I2C_SLAVE, then use standard read()/write() calls to communicate with the device. Code snippets are provided in the blog post.