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:


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
    Commented Dec 22, 2018 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
    Commented Dec 22, 2018 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
    Commented Dec 22, 2018 at 20:29

1 Answer 1


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);


fd = wiringPiI2CSetupInterface("/dev/i2c-3", 0x31);
  • 1
    Dude you saved my life :)
    – Dumbo
    Commented May 3, 2021 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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