https://github.com/mcauser/i2cdetect
Arduino library for scanning I2C bus for devices
https://github.com/mcauser/i2cdetect
arduino-library i2c i2cdetect
Last synced: 12 months ago
JSON representation
Arduino library for scanning I2C bus for devices
- Host: GitHub
- URL: https://github.com/mcauser/i2cdetect
- Owner: mcauser
- License: mit
- Created: 2016-03-02T14:01:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-02T15:19:21.000Z (over 10 years ago)
- Last Synced: 2025-04-04T15:50:44.173Z (about 1 year ago)
- Topics: arduino-library, i2c, i2cdetect
- Language: C++
- Size: 2.93 KB
- Stars: 29
- Watchers: 5
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# i2cdetect
Arduino library for scanning I2C bus for devices.
Outputs a table similar to the [linux program](http://linux.die.net/man/8/i2cdetect) 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
#include
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
* [Arduino UNO R3 - ATmega328P](https://www.arduino.cc/en/Main/ArduinoBoardUno)
* [WeMos D1 mini - ESP8266](http://www.wemos.cc/wiki/doku.php?id=en:d1_mini)