Home » BeagleBone Black » Beaglebone Black I2C Tutorial
beaglebone black i2c

Beaglebone Black I2C Tutorial

I2C is a popular communications protocol and is used by a lot of sensors and devices. This is why most microcontrollers, including Arduino, PICs and STM32 have I2C support. In this tutorial, we will look at how to use the I2C protocol on the BBB and create a simple Beaglebone Black I2C application.

Beaglebone Black I2C Bus

There are three I2C buses on the Beaglebone Black according to the AM335X Technical Reference Manual and their memory addresses are:

  • i2c-0: 0x44E0_B000
  • i2c-1: 0x4802_A000
  • i2c-2: 0x4819_C000

The i2c-0 bus is not accessible on the header pins while the i2c-1 bus is utilized for reading EEPROMS on cape add-on boards and may interfere with that function when used for other digital I/O operations.

beaglebone black i2c pinouts

The i2c-2 bus is the one that is free for use so we'll be using that in this tutorial.

Linux I2C Tools

Thankfully, Linux has built-in i2c tools that make our life easier (unlike with BBB PWM). To check which of the three buses are enabled we can use i2cdetect:

Mine's showing two i2c devices. But again we can't use i2c-0 so we'll go with i2c-2.



To detect the devices connected to i2c-2:

Those addresses with UU are reserved address. Noticed there is a 68. That's because I connected a device with an I2C address of 68 to my Beaglebone Black.

Writing and Reading from the I2C Bus

Now, to write to the I2C bus, we can use:

The first hex number is the I2C device address followed by the specific data address and the byte to be written. You can read more about the i2cset at https://linux.die.net/man/8/i2cset.

To read the registers from the device connected to the I2C bus, the i2cdump command can be used:

Read more about i2cdump here: https://linux.die.net/man/8/i2cdump

Finally, we can acquire the data from a specific register on the I2C device using i2cget:

Here's more information for i2cget: https://linux.die.net/man/8/i2cget.

On the next part of this tutorial, we'll be reading data from the MPU6050 gyroscope + accelerometer and display it on the Beaglebone Black terminal. Follow this blog for updates!

Check Also

Adding Location to Microcontroller Projects: GPS Tutorial

Global Positioning System (GPS) has been around since the 80's and is still one of …

Leave a Reply

Your email address will not be published. Required fields are marked *