主要内容

scanI2CBus

Scan I2C buses on NVIDIA Jetson board

Since R2026a

    Description

    Add-On Required: This feature requires the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms add-on.

    availableDevices = scanI2CBus(hwObj) scans available I2C buses on the specified NVIDIA® Jetson™ device and returns I2C addresses for the connected devices.

    example

    availableDevices = scanI2CBus(hwObj, busID) scans the specified I2C bus on the Jetson device for connected devices.

    example

    Examples

    collapse all

    Create a connection to the Jetson board by using the jetson function.

    hwObj = jetson;
    ### Checking for CUDA availability on the target...
    ### Checking for 'nvcc' in the target system path...
    ### Checking for cuDNN library availability on the target...
    ### Checking for TensorRT library availability on the target...
    ### Checking for prerequisite libraries is complete.
    ### Gathering hardware details...
    ### Checking for third-party library availability on the target...
    ### Gathering hardware details is complete.
    Board name              : NVIDIA Jetson Nano Developer Kit
    CUDA Version            : 10.2
    cuDNN Version           : 8.2
    TensorRT Version        : 8.2
    GStreamer Version       : 1.14.5
    V4L2 Version            : 1.14.2-1
    SDL Version             : 1.2
    OpenCV Version          : 4.1.1
    Available Webcams       :  
    Available GPUs          : NVIDIA Tegra X1
    Available Digital Pins  : 7  11  12  13  15  16  18  19  21  22  23  24  26  29  31  32  33  35  36  37  38  40

    Scan the I2C buses connected to the board.

    availableDevices = scanI2CBus(hwObj);
    Devices on i2c-0: .
    Devices on i2c-1: 2D, 3E.
    

    Access the structure that contains the addresses for i2c-1.

    availableDevices{2}
    ans = 
    
      struct with fields:
    
            Bus: 'i2c-1'
        Devices: {'2D','3E'}

    Scan a known bus ID on the Jetson board.

    Create a connection to the Jetson board by creating a jetson object. Use the AvailableI2CBuses property of the jetson object to check the I2C buses on the board.

    hwObj = jetson;
    hwObj.AvailableI2CBuses
    ans =
    
      1×2 cell array
    
        {'i2c-0'}    {'i2c-1'}

    Scan the i2c-1 bus.

    availableDevices = scanI2CBus(hwObj,"i2c-1");
    Devices on i2c-1: 2D, 3E.
    

    Input Arguments

    collapse all

    NVIDIA Jetson hardware, specified as a jetson object.

    I2C bus ID, specified as a string.

    Example: scanI2CBus(hwObj,"i2c-0")

    Output Arguments

    collapse all

    Available device addresses, returned as a cell array. If you do not specify a bus ID, the function returns the addresses as a cell array of structures, where each structure contains these fields:

    FieldDescription
    BusI2C bus ID
    DevicesI2C device addresses in hexadecimal format

    If you specify a bus ID, the function returns a cell array of character vectors, where each vector is a device address in hexadecimal format.

    Version History

    Introduced in R2026a

    See Also

    |