Main Content

Arduino I2C Interface

I2C, or Inter-Integrated Circuit, is a chip-to-chip protocol for communicating with low-speed peripherals. MATLAB® Support Package for Arduino® Hardware includes the I2C library, which creates an interface to communicate with I2C devices. Each Arduino board has specific pins for the I2C interface. Refer to your hardware specifications to locate the correct pins.

You can use I2C devices in many applications, including:

  • Real-time clocks

  • Digital potentiometers

  • Temperature sensors

  • Digital compasses

  • Memory chips

  • FM radio circuits

  • Input/output expanders

  • LCD controllers

  • Amplifiers

Note

To create a custom I2C code, see Create Custom Arduino Add-On Library

Arduino devices have one or two I2C buses. Each bus has an I2C Central connected to two bidirectional lines, serial data line (SDA) and serial clock (SCL). These two lines are connected to a pair of pins on the hardware. You can connect multiple I2C devices, such as ADCs, LCDs, and sensors, to the I2C pins on the Arduino hardware. Each I2C device on an I2C bus must have a unique address. Most devices have a default address assigned by the manufacturer. If the address is not unique, refer to the device data sheet and reconfigure the address. Often, you can reconfigure the address using a pair of jumpers on the device. MATLAB Support Package for Arduino Hardware supports only 7-bit addressing.

For more information on Arduino I2C devices see https://reference.arduino.cc/reference/en/language/functions/communication/wire/