I2C scanner
Posted: Mon Oct 08, 2018 10:44 am
Hello,
This snipped of code lists all connected devices to the I2C bus.
The bus can manage 128 devices.
The first seven are reserved, so 120 are available.
This code is intended for I2C devices with a 7 bit address.
However, newer devices have a 10 bit address.
As the ezsbc1 seems to handle 10 bit addresses, you can increase the address range (tested and working).
I2CINIT(100000)
I2CTIME(10)
FOR address=8 TO 120
I2CWR(address,0x00,"",0)
IF I2CBUSY(address)=0 THEN
PRINT hex$(address)
ENDIF
NEXT address
END
This snipped of code lists all connected devices to the I2C bus.
The bus can manage 128 devices.
The first seven are reserved, so 120 are available.
This code is intended for I2C devices with a 7 bit address.
However, newer devices have a 10 bit address.
As the ezsbc1 seems to handle 10 bit addresses, you can increase the address range (tested and working).
I2CINIT(100000)
I2CTIME(10)
FOR address=8 TO 120
I2CWR(address,0x00,"",0)
IF I2CBUSY(address)=0 THEN
PRINT hex$(address)
ENDIF
NEXT address
END