Scan for I2C peripheral devices connected to controller board
i2cAddress = scanI2CBus(controller) scans for connected I2C
peripheral devices on the NI™ USB-845x or Total Phase®
Aardvark™ controller specified by
controller. It returns a list of the peripheral devices' I2C addresses
as a string scalar or an array of string scalars.
controller is the
controller connection, specified as an
Scan for I2C Peripheral Devices on NI USB-845x Controller
Connect to an NI USB-845x controller board and scan it for connected I2C peripheral devices.
Connect to the NI USB-845x using its serial number. In this example, the NI USB-845x controller board that is connected to the computer has a serial
controller = ni845x("01F26E0A");
Make sure that your I2C peripheral devices are physically connected to the
controller. Scan for connected I2C peripheral devices. The
scanI2CBus function returns a list of the I2C addresses of these
i2cAddresses = scanI2CBus(controller)
i2cAddresses = 1×2 string array "0x48" "0x53"
In this example, two peripheral devices are connected. You can now create a
connection to one or more of them using the
device function with
one of the listed I2C addresses. Refer to your peripheral device's datasheet to
determine its I2C address.
Introduced in R2023a