主要内容

I2C 设备

R2026b
读取和写入连接到 Arduino® 硬件的 I2C 设备

在使用 I2C 函数之前,请使用 arduino 创建一个 Arduino 对象。有关详细信息,请参阅Connect to Arduino Hardware。您可以使用 Arduino 资源管理器以交互方式配置 I2C 通信接口,并使用该接口在 MATLAB® 和 MATLAB Online™ 中对连接到 Arduino 和其他受支持硬件的 I2C 设备读取和写入数据。有关详细信息,请参阅 Connect to I2C Device Using Arduino Explorer App。

有关安装版 MATLAB 中支持的硬件的完整列表,请参阅Supported Hardware。有关 MATLAB Online 支持的板、工作流和平台的详细信息,请参阅Get Started with MATLAB Online for Arduino。

注意

除 scanI2CBus 之外的所有函数都使用 MATLAB Function 模块生成代码。有关详细信息,请参阅Deploy Arduino Functions to Arduino Hardware Using MATLAB Function Block。

函数

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

主题