I2C Scanner sample


This sample sends I2C messages without any data (i.e. stop condition after sending just the address). If there is an ACK for the address, it prints the address as FOUND.


As there is no standard I2C detection command, this sample uses arbitrary SMBus commands (namely SMBus quick write and SMBus receive byte) to probe for devices. This sample program can confuse your I2C bus, cause data loss, and is known to corrupt the Atmel AT24RF08 EEPROM found on many IBM Thinkpad laptops. See also the i2cdetect man page

Building and Running

# On Linux/macOS
cd $ZEPHYR_BASE/samples/drivers/i2c_scanner
mkdir build && cd build

# On Windows
cd %ZEPHYR_BASE%\samples\drivers\i2c_scanner
mkdir build & cd build

# Use cmake to configure a Ninja-based build system:
cmake -GNinja -DBOARD=nrf52840_blip -DCONF_FILE="prj.conf overlay-nrf52.conf" ..

# Now run ninja on the generated build system:
ninja flash