Main Content

I2C Devices

R2026b
Read and write to I2C devices connected to Arduino® hardware

Create an Arduino object using arduino before you use I2C functions. See Connect to Arduino Hardware for more information. You can use Arduino Explorer to interactively configure the I2C communication interface and use the interface to read and write data to I2C devices connected to Arduino and other supported hardware in MATLAB® and MATLAB Online™. For more information, see Connect to I2C Device Using Arduino Explorer App.

For a complete list of hardware supported in the installed version of MATLAB, see Supported Hardware. For more information regarding supported boards, workflows, and platforms supported on MATLAB Online, see Get Started with MATLAB Online for Arduino.

Note

All functions, except scanI2CBus, generate code using the MATLAB Function block. For more details, see Deploy Arduino Functions to Arduino Hardware Using MATLAB Function Block.

Functions

deviceConnection to device on I2C bus on Arduino or ESP32 hardware
scanI2CBusScan I2C bus on Arduino hardware for device address
readRead data from I2C bus
writeWrite data to I2C bus
readRegisterRead data from I2C device register
writeRegisterWrite data to I2C device registers

Topics