Go Down

Topic: I2C scanner + detector (Read 338 times) previous topic - next topic

bitbank

I just released a new Arduino sketch to Github which not only scans an I2C bus for devices, but can automatically identify the devices it finds (currently supports 15 common sensors/displays).

Larry's I2C detector on Github

Instead of making assumptions about the device address, It reads the register contents and looks for specific identifiers (e.g. Who_Am_I or DeviceID registers work best). I could only test the devices that I personally have, so please help improve this project by adding support for recognizing more devices and then do a pull request.

Library? We don't need no stinkin' library...we write our own

pert

Thanks for sharing. It sounds very useful! I'll definitely give it a try the next time I'm having trouble with an I2C device.

bperrybap

FYI,
Addresses 0 to 7 are reserved.
https://www.i2c-bus.org/addressing/
http://dlnware.com/theory/I2C-Address

7 bit address scanning should start above address 7.

On some processors like the pic32 it will hang the processor.

In terms of identifying slave devices, if you haven't already, you may want to take a look at the i2c address allocation table.
http://simplemachines.it/doc/IC12_97_I2C_ALLOCATION.pdf

You can see how devices are grouped together and that given the limited address space, several different devices were assigned to the same group which can make it difficult or even impossible to reliably identify specific devices within a group.

--- bill

6v6gt

I guess that you have also considered that some I2C devices may be disturbed by attempts to probe them.
For example, you may not want an I2C EEPROM to have bits written to them as a side effect of an effort  to identify them.
The original I2C scanner was very passive so it posed no risk in this respect.

Go Up