Skip to content
Arduino library for scanning I2C bus for devices
C++
Branch: master
Clone or download
mcauser Swap printf for sprintf
Serial.printf works on ESP8266, but not Arduino HardwareSerial
sprintf works on both
Latest commit 5681bdb Mar 2, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Initial Mar 2, 2016
i2cdetect.cpp Swap printf for sprintf Mar 2, 2016
i2cdetect.h Initial Mar 2, 2016
keywords.txt Initial Mar 2, 2016
library.properties Initial Mar 2, 2016
license.txt Initial Mar 2, 2016
readme.md Swap printf for sprintf Mar 2, 2016

readme.md

i2cdetect

Arduino library for scanning I2C bus for devices.

Outputs a table similar to the linux program of the same name.

Each cell will contain one of the following symbols:

  • "--" when the address was probed but no chip answered
  • An address in hexadecimal, e.g. "1e", when a chip was found at the address

The optional parameters first and last restrict the scanning range (default: from 0x03 to 0x77).

Example

#include <Wire.h>
#include <i2cdetect.h>

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("i2cdetect example\n");
  Serial.print("Scanning address range 0x03-0x77\n\n");
}

void loop() {
  i2cdetect();  // default range from 0x03 to 0x77
  delay(2000);
}

Serial monitor output

i2cdetect example
Scanning address range 0x03-0x77

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Tested on devices

You can’t perform that action at this time.