Contents Up Previous

Second I2C Bus

For Raspberry Pi Model B Revision 2 boards and Model A boards a second i2c bus is avaliable.

This is I2C0 and is setup by default for use with the Raspberry Pi Camera Module. The Camera Module connects to the S5 connector as noted in the bottom right quarter of the following picture:

Alternatively you can setup the I2C0 bus as a second i2c bus for your own usage. It follows that you can only have one or the other - either you can have the I2C0 bus support the Raspberry Pi Camera module or you can dedicate it for your own use - but not both.

For alternative use the I2C0 bus is broken out to GPIO pins on the P5 header. This header has no connector attached during manufacture so if you want to use it you must solder a connector yourself. The P5 pad is designed to accept a connector on the reverse side of the Raspberry Pi board. There is not enough room next to the GPIO Pad 1 pins to mount connectors in the standard way. (This is by design).

You can see from the above picture that I have soldered pins next to the GPIO 1 Pad rather than in the manner the P5 header was designed for, on the reverse of the board. These are usable because I have soldered them at an angle to lean away from the GPIO 1 header. If you do this too, remember that the pins are effectively the 'wrong way around' from left to right (top to bottom in the picture).

The Pin out diagram for P5 is:

Wiring GPIO Name Raspberry Pi Name GPIO Wiring
-------- ------ ---------- ---- ---- ---------- ------ --------
- - 5V0 1 2 3V3 - -
17 28 GPIO_28 3 4 GPIO_29 29 18
19 30 GPIO_30 5 6 GPIO_31 31 20
- - GND 7 8 GND - -

If pins GPIO 28 and GPIO 29 are set to use the ALT0 function then they become I2C0_SDA and I2C0_SCL respectively. Because I have effectively soldered pins for P5 to the 'wrong' side of the board, then to map the above table to the picture of the P5 header you must first rotate the picture 90 degrees clockwise then swap the position of the pins right to left.( that is, Pin 1 5v0 swapped with Pin 2 3v3, Pin 3 GPIO 28 swapped with Pin 4 GPIO 29, and so on )

You can set up the second I2C0 bus directly in code with:

use HiPi::BCM2835;
my $dev = HiPi::BCM2835->new;

Similarly you can disable the I2C0 bus and restore its operation on the S5 camera connector with:


If you are running as an unprivileged user you can enable the I2C0 bus using the hipi-i2c utility.

hipi-i2c e 0 1

or to disable

hipi-i2c e 0 0

This may prove useful if you want to access the I2C0 bus using the standard kernel i2c device drivers. After the kernel module is loaded you can call hipi-i2c e 0 1 to make the I2C0 bus available on the P5 header pins.

Finally, you can also use the HiPi Control GUI application to enable and disable the I2C0 bus on the P5 header manually.

Contents Up Previous

HiPi Modules Copyright © 2013 Mark Dootson