1

I want to use I2C software instead hardware I2C. Because a buggy parto of the I2C related with clock stretching.

I can enable in boot.txt adding this:

dtoverlay=i2c-gpio,bus=3

It would create a /dev/i2c-3.

Now I want to access using wiringpi library, but I don't know how to choose bus 3 instead of default bus. The wiringpi library saids...

The ID is the I2C number of the device and you can use the i2cdetect program to find this out. wiringPiI2CSetup() will work out which revision Raspberry Pi you have and open the appropriate device in /dev.

Is there a way to specify which bus do you want to use?

  • Looking the code I believe that the answer is easy, I've to use fd = wiringPiI2CSetupInterface ("/dev/i2c-3", DEV_ADDR) instead of wiringPiI2CSetup ....; – Mquinteiro Dec 22 '18 at 20:13
  • Welcome. If you've found a solution that works for you, please consider writing it up as an answer (you may have to wait 24 hrs, unfortunately). – goldilocks Dec 22 '18 at 20:16
  • @goldilocks I don't know if it works... I will have to wait 2 days to check if it works or not... – Mquinteiro Dec 22 '18 at 20:29
0

As you say in your comment just use the wiringPiI2CSetupInterface function.

This function is actually called by wiringPiI2CSetup.

E.g. rather than

fd = wiringPiI2CSetup(0x31);

Use

fd = wiringPiI2CSetupInterface("/dev/i2c-3", 0x31);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.