device
R2026bConnection to device on I2C bus on Arduino or ESP32 hardware
Description
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
This object represents a connection to the I2C device on Arduino® or ESP32 hardware. Attach an I2C device to the appropriate pins on the Arduino or ESP32 hardware. You can interact with the I2C device using the functions listed in Object Functions.
Creation
Description
creates an object that represents the connection between an I2C peripheral connected to
the central Arduino or ESP32 hardware. The Arduino or ESP32 hardware is represented by an deviceObj = device(arduinoObj,'I2CAddress',I2CAddress,Name=Value)arduino object.
You can also customize the connection further using one or more name-value arguments. The
'I2CAddress' name-value argument is mandatory for creating the I2C device
connection.
Input Arguments
Name-Value Arguments
Properties
Object Functions
read | Read data from I2C bus |
readRegister | Read data from I2C device register |
write | Write data to I2C bus |
writeRegister | Write data to I2C device registers |
Examples
More About
Alternative Functionality
App
Use Arduino Explorer to configure the I2C peripheral and read from and write to I2C peripherals connected to Arduino or any other supported hardware. You can use the app in the installed version of MATLAB and MATLAB Online™. For more information, see Connect to I2C Device Using Arduino Explorer App.
Version History
Introduced in R2019a