LinuxCommandLibrary

i2cdetect

Detect I2C devices on a bus

TLDR

List active I2C buses

$ i2cdetect -l
copy

Scan devices on an I2C bus
$ i2cdetect [i2c_bus]
copy

Scan devices on an I2C bus without asking for confirmation
$ i2cdetect -y [i2c_bus]
copy

SYNOPSIS

i2cdetect [OPTIONS] BUS
i2cdetect -l
i2cdetect -F BUS

PARAMETERS

-y
    Assume yes to all queries. Prevents interactive prompts, useful for scripting.

-r
    Read-only mode. Performs a scan without writing to the I2C bus, making it safer for production systems.

-a LOW HIGH
    Scan a specific address range from LOW to HIGH (inclusive, in hexadecimal).

-q
    Quick mode. Reduces the number of probes for faster detection, but might be less reliable.

-F
    List the capabilities and features of the specified I2C bus, such as supported protocols and functions.

-l
    List all detected I2C buses on the system, showing their bus numbers and descriptions.

-V
    Display the version information of the i2cdetect command.

-d
    Enable debug output, providing more verbose information during execution for troubleshooting.

-I ADDRS
    Ignore specified I2C addresses (comma-separated list) during the scan, preventing probes to known problematic devices.

DESCRIPTION

The i2cdetect command is a powerful utility within the i2c-tools package, designed to scan an I2C bus for connected devices and report their corresponding hexadecimal addresses. It's an essential tool for embedded systems development, hardware debugging, and verifying device presence on an I2C bus.

Users can specify the I2C bus number to scan, or list all available buses. The command offers various modes, including a safe read-only mode (-r) to prevent accidental writes, and options to scan specific address ranges. Its output typically displays a matrix of I2C addresses, marking detected devices, addresses in use by kernel modules (UU), or empty slots (--). It requires root privileges to operate, as it directly interacts with low-level hardware. Caution is advised, especially when not using the read-only flag, as probing certain addresses can potentially interfere with active devices.

CAVEATS

Requires root privileges (or sudo) to access I2C bus devices.
Probing addresses without the -r (read-only) flag can potentially interfere with or disrupt actively communicating I2C devices.
Addresses marked as UU indicate that a kernel module is already using that address, and i2cdetect will not probe it.
Some I2C devices may not respond correctly to the general call address probe, or may respond in unexpected ways.

OUTPUT FORMAT

The output is typically a grid where rows represent the higher nibble and columns represent the lower nibble of the I2C address.
-- indicates no device found at that address.
UU indicates the address is in use by a kernel driver.
XX may indicate a conflict or multiple devices.
A two-digit hexadecimal number (e.g., 48) indicates a device was detected at that address.

BUS NUMBER

The BUS argument typically corresponds to /dev/i2c-N, where N is the bus number. You can use i2cdetect -l to list available buses and their corresponding device paths.

HISTORY

i2cdetect is part of the i2c-tools package, a suite of utilities for communicating with I2C/SMBus devices. The package and its tools have been developed over many years to provide essential user-space access to I2C buses on Linux systems, evolving with kernel I2C subsystem changes to support a wide range of hardware platforms.

SEE ALSO

i2cdump(8), i2cget(8), i2cset(8), i2c-tools(7)

Copied to clipboard