1

I have a several questions regarding pigpio I2C functions as below.

  1. how to check if a I2C device is connected with pigpio? I would like to just check if a device is connected without read/write operation. i could implement the same feature with following code in Arduino. when error == 0, a device is connected.
Wire.beginTransmission(address);

error = Wire.endTransmission();

  1. does "i2cZip" function support "repeated start"? there is no "start", "stop" command codes exist. bit-banged "bbI2CZip" supports "repeated start" but i need H/W function.
[i2cZip Example]

Set address 0x53, write 0x32, read 6 bytes

Set address 0x1E, write 0x03, read 6 bytes

Set address 0x68, write 0x1B, read 8 bytes

End

0x04 0x53 0x07 0x01 0x32 0x06 0x06

0x04 0x1E 0x07 0x01 0x03 0x06 0x06

0x04 0x68 0x07 0x01 0x1B 0x06 0x08

0x00

1 Answers1

2

The only way to check if a particular device is connected to the I2C bus is to send it a legal command and check the expected result.

i2cZip uses the underlying Linux I2C/SMBus driver. I do not know if the current driver properly supports repeated starts.

The bit bang bbI2CZip does support repeated starts.

joan
  • 71,024
  • 5
  • 73
  • 106
  • First of all, Thank you for making such a nice library joan. I would test if a i2c device is connected by sending byte array of [start][address][stop]. i hope this a legal command. for the second issue, i don't have much knowledge of linux i2c driver. It seems raspberrypi linux kernel supports repeated start but i am not sure https://stackoverflow.com/questions/35078131/why-repeated-start-based-i2c-operation-are-not-supported-in-linux – YoungMin Kim Oct 25 '22 at 23:50
  • If you look at man page for i2cdetect you will see that there is no general safe way to probe for a device. Of course if you are sure that a particular device will be present or no device will be present you can tailor the query for that device. – joan Oct 26 '22 at 08:44
  • i agree. i better find a device specific way. thanks. – YoungMin Kim Oct 28 '22 at 10:05