Main Content

scanI2CBus

Scan I2C bus on Arduino hardware for device address

Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.

Description

addr = scanI2CBus(a,bus) scans the specified bus on the Arduino® hardware in object a and stores it in the variable addr.

example

Examples

collapse all

Create a connection to an Arduino Due and scan the specified bus number. You can specify bus 1 only if you are using Arduino Due or Nano33BLE boards.

a = arduino('COM5','Due','Libraries','I2C');
scanI2CBus(a,1)
ans = 1×1 cell array
    {'0x48'}

Input Arguments

collapse all

Arduino hardware connection created using arduino, specified as an object.

I2C bus number specified as a number.

Output Arguments

collapse all

I2C bus address returned as a character vector or a cell array of character vectors.

Note

For more details on creating the I2C device object using address returned by the scanI2CBus function on Bus 1 on the Arduino Due board, ArduinoBLE, and, ArduinoBLE Sense, see Board Specific Issues.

Version History

Introduced in R2014b