To do an I2C scan on a Raspberry Pi the
i2cdetect command is used. If not already done, be sure to enable I2C on the Raspberry Pi via
raspi-config. If the
i2cdetect command is not found, install it with:
And then to run a scan, use
i2cdetect with the following command line parameters:
On modern Raspberry Pi OS releases, you do not need to run the command with
-y disables interactive mode, so it just goes ahead and scans. The
1 specifies the I2C bus.
If all goes well, you should get a list of addresses for each device found. In the example below, an Adafruit BMP280 breakout is attached to a Raspberry Pi 4.
The BMP280's I2C address of
0x77 shows up as expected.
If the device is disconnect and/or the pull up resistors are missing, the results will look like this:
The scan runs fine, but no addresses are shown. Keep in mind that Raspberry Pi's include pull up resistors on the SCL and SDA pins.