|
Raspberry Pi I2C configuration for the BNO055
|
|
This page explains how to set up the i2c on a Raspberry Pi 3B or Zero W so it can
communicate with the BNO055 sensor. |
 |
Please note that the BNO055 sensor will not operate with a Raspberry Pi unless the
following change is made. The Raspberry Pi hardware i2c device /dev/i2c-1 has to be disabled and replaced with
a device tree overlay device /dev/i2c-3. Software requiring /dev/i2c-1 will therefore no longer work after this
change. |
|
|
The Raspberry Pi i2c hardware does not implement the i2c standard fully as it does
not support clock stretching. The BNO055 sensor requires that clock stretching be supported by i2c for it to transmit
data. Therefore the standard i2c hardware has to be disabled and a device tree overlay enabled to replace it. This
process is explained below. |
From the command line enter the command sudo raspi-config to start the Raspberry
Pi software configuration tool as shown below. Select option 5 Interfacing options. |
|
Then select option P5 i2c as shown below. |
|
Select No to having the i2c interface enabled as shown below. Then follow the instructions
to finish and close the program. |
|
Next enter sudo leafpad /boot/config.txt from the command line to edit the
config.txt file. Go to the bottom of the file and add the following line:
dtoverlay=i2c-gpio,bus=3,i2c_gpio_sda=02,i2c_gpio_scl=03
This device tree overlay creates an i2c_gpio module which is essentially a bit banged i2c device that supports
clock stretching. This takes the place of the Raspberry Pi i2c hardware and uses the same GPIO pins. |
|
Save and Close the file. Then reboot with command sudo reboot. After the system
has restarted use the command ls -l /dev/i2c* to show the i2c device setting. If the procedure has been
successful you should see that the /dev/i2c-3 device is present as shown below. |
|
To confirm that you are able to communicate with the BNO055 run the command i2cdetect
-y -r 3 from the command line. This should show the BNO055 is present at i2c address 0x28 as shown below. |
|
You will now be able to run our BNO055 example
code on your Raspberry Pi. |
|
BNO055 IMU output being used to animate an OpenGL cube.
|
|
Usage with WiringPi and other i2c source code |
The change described above replaces the Raspberry Pi hardware i2c device /dev/i2c-1
with the device /dev/i2c-3. This change means that any software that runs expecting to find /dev/i2c-1 will no
longer work. For this reason if you wish to develop software for the GPS-PIE slice you may wish to install the
interface example source code we provide on a new micro SD card to avoid any conflict with software you may already
have installed or written.
For programs that use WiringPi the only change needed is in the initialisation where the i2c device needs to be
changed as follows:
const char *device;
uint8_t devID = 0x28; // Your slave I2C device
device = "/dev/i2c-3"; // select i2c-3 port
wiringPiI2CSetupInterface (device, devID); |
|
|
© The BlackBoxCameraTM Company Limited
2019
|
|