Skip to content

Understanding I2C

Protocol for sending data back and forth. Used in microcontrollers, different memories, temperatrue sensors, ADCs, and integrated circuits.

SImple impl, one master 1 slave. Only 2 pins (SCL) clock (SDA) data. Clock is used to align data so slave know when to sample it. Can also have multiple slaves on a single bus. You could be sending commands to a DAQ, or an ADC, or another microcontroller.

Advantages/disadvatnges

Ad: low pin count ad: addressing built in ad: ubiquitius

dis: half-duplex, 400 kbps max, half duplex means limited on bandwidth, not as fast as SPI dis: careful consideration of hardware dos: more complicated than spi or UART

Notes:

  • The slave uses the clock to know when to sample the data line

CLI

On linux you can interact with I2C buses using the i2c-tools program suite.

i2cdetect -l lists the I2C busses available on the system.

useful tools in this suite include i2cdetect, i2cget, i2cset, i2cdump, i2ctransfer.

TODO: Create a separate file for linux commands with i2c