The bcm2835 library works directly on the SPI/I2C devices. It is not using any Linux device drivers. When relevant Linux drivers are loaded or activated then it can create unexpected behavior from other software like 'i2cdetect'. So a I created a bcm2835 version of i2cdetect, I2CDetectGL.
Raspberry Pi I2C bus scan detection program. Detects I2C 7-bit address and prints them to screen. Scan for I2C devices, to see if any slaves are present on the I2C bus. Uses bcm2835 Library v1.7.5 dependency. Provides low level I2C bus, delays and GPIO control.
Install the dependency bcm2835 Library if not installed (at time of writing latest version is 1.7.5) Install the C libraries of bcm2835, Installation instructions here
Enter your Downloads folder, then type in terminal. To download, build , install and test.
curl -L -O https://github.com/gavinlyonsrepo/I2CDetectGL/archive/main.zip
unzip main.zip
cd I2CDetectGL-main
make
sudo make install
To print help message
sudo i2cDetectGL -h
Flag | Description |
---|---|
-h | print help message |
-v | print version numbers |
-m | Scan I2C bus and print table |
-s | Scan I2C bus and print detected devices |
-a I2C_ADDRESS | Probe a 7-bit I2C address passed as 2nd argument eg 0x3C |
Error number | Description | Solution |
---|---|---|
1201 | Cannot open bcm2835 library | Run as sudo |
1202 | Cannot start I2C bus | run as sudo |
1203 | Unsupported option | |
1204 | No i2c address specified for -a option | Enter an I2C Address eg i2cDetectGL -a 0x3C |
1205 | Invalid I2C address passed for -a option | Enter a valid 7-bit I2c Address range 0x00 to 0x7F |
1206 | Reserved Address chosen for -a option | 0x00 to 0x07 and 0x78 to 0x7F are reserved |
Detecting an SSD1306 I2C OLED on i2C Bus at address 0x3C.
- @ = Detection of device on bus.
- . = No detection
- R = Reserved address