1

I am trying to configure a sensor connected to Rpi over an i2c bus. I am using PiGPIO library with Python to do this. To configure the sensor, I need to write a certain value to some registers and that doesn't seem to be working.

I am doing the following to write value to a register.

pi.bb_i2c_zip(SDA, [4, i2c_address, 2, 7, 1, register_address, 2, 7, 1, value, 3)

Register address could be 0x0A, and value being 0x04.

When I read the register back, it reads the default value that the sensor came with. So I know the writing doesn't work but reading does. For reading, I do the following and it works

pi.bb_i2c_zip(SDA, [4, i2c_address, 2, 7, 1, register_address, 2, 6, 1, 3)

I haven't been able to find any documentation about how to write to registers using PIGPIO library. Does anyone have had any success in doing something like this? Thanks for your help!

  • Does your sensor work when you connect it to dedicated I2C pins? – Dmitry Grigoryev Jun 13 at 7:20
  • Why aren't you using standard I2C? Please edit the question and include the full test code. – joan Jun 13 at 7:27
  • The Raspberri Pi model 3 has a hardware bug that doesn't allow for clock stretching. The bitbang library is a workaround to do that on a Pi. The sensor works when I connect it to dedicated pins. – abhay gupta Jun 13 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.