I2C 设备
R2026b在使用 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。
函数
device | Connection to device on I2C bus on Arduino or ESP32 hardware |
scanI2CBus | Scan I2C bus on Arduino hardware for device address |
read | Read data from I2C bus |
write | Write data to I2C bus |
readRegister | Read data from I2C device register |
writeRegister | Write data to I2C device registers |
主题
- Communicate with an I2C EEPROM Device
Learn how to store and retrieve data from an I2C EEPROM device.
- Measure Temperature from I2C Device on Arduino Hardware
Learn how to measure temperature from an I2C device on your Arduino hardware.
- Arduino I2C Interface
Learn how Arduino hardware interfaces with the I2C protocol.
- Use Arduino Explorer App
Learn how to use the Arduino Explorer app to configure GPIO pins and communication protocol interfaces and visualize data.
- Connect to I2C Device Using Arduino Explorer App
I2C (Inter-Integrated Circuit) is a two-wire serial communication protocol that uses a serial data line (SDA) and a serial clock line (SCL) to exchange data between a controller and one or more peripheral devices.