Enable Secondary I2C Bus of Raspberry Pi Hardware
Raspberry Pi® hardware uses the ARM® I2C-1 as the default bus interface to communicate with various I2C peripherals such as sensors and actuators. This I2C controller uses Serial Data pin (SDA) on GPIO 2 and Serial Clock pin (SCK) on GPIO 3 of your Raspberry Pi hardware board to drive the I2C peripheral devices. To enable the I2C1 interface on your Raspberry Pi hardware, see Enable I2C Interface on Raspberry Pi Hardware Kernel.
Using the Simulink® Support Package for Raspberry Pi Hardware, you can enable the VideoCore I2C-0 bus interface to connect multiple I2C peripherals with the same address to your Raspberry Pi hardware. This interface uses the SDA pin on GPIO 0 and SCK pin on GPIO 1 of your Raspberry Pi hardware board.
Note
Raspberry Pi CSI camera and touch display may not function as expected after you enable the I2C0 bus interface on your Raspberry Pi hardware.
Follow these steps to enable the I2C0 bus interface on your Raspberry Pi hardware.
On your Raspberry Pi terminal, execute this command to open the
/boot/config.txt
file in a text editor.nano /boot/config.txt
In the
config.txt
file, add this device tree parameter in a new line.dtparam=i2c_vc=on
Optionally, you can configure the baud rate for the I2C bus. For example, to set the baud rate for the I2C bus at 100 Kbps, execute this command.
dtparam= i2c_vc_baudrate=100000
Connect an external pull-up resistor of 1.8 KΩ between the Raspberry Pi power supply and the GPIO pins 0 and 1.
Save the
config.txt
file.Reboot your Raspberry Pi.
reboot
Open MATLAB®. From the support package, open a block that utilizes I2C to communicate with peripherals, for example open the I2C Controller Write block. Observe that the I2C module parameter is populated with options
0
and1
.
Note
Prefer using I2C1 module over I2C0 module especially when only a single I2C interface is needed.
In a Simulink model, after you enable both the I2C0 and I2C1 bus interfaces, you can configure the blocks from the Simulink Support Package for Raspberry Pi Hardware for both I2C1 and I2C0.
Once you enable I2C0 bus interface, Raspberry Pi camera serial interface would be non-operational.
See Also
Enable I2C Interface on Raspberry Pi Hardware Kernel | Enable Secondary SPI Bus of Raspberry Pi Hardware | I2C Controller Read | I2C Controller Write