Working With I2C using c++
n this article, I will explain C++ libraries that enable to work with these protocols on a Raspberry Pi. For each protocol, I researched useable libraries, and give a short explanation and code exampl
I2C can be supported with the help of the SMBus protocol, which is described as a specific variant of the I2C bus. This protocol is available as Linux Kernel module. To use it, you need to configure your Raspberry Pi. In a terminal, run raspi-config
, select 3 Interfacing Options
and P5 I2C
.
Following the code example from kernel.org, you will need to open the device file that represents the connected I2C device, and then send SMBus commands by writing to the devices registers.
Last updated