We are attempting to use the Raspberry Pi as an embedded software platform. We are writing this in python, but currently we have it wired up to use 3 separate I2C busses. We have two of them wired to the normal I2C pins, but we require the use of a normal bog-standard GPIO pin to wire this third bus to.

We have pull-up resisters included in the electrical writing, is it possible to simple have Raspberry Pi treat these pins as I2C pins?

I found other answers on this site, but nearly all tell the user to simply daisy chain their devices onto one bus. I'm not quite sure of the reason why, but that is not currently an option for us. Is Bit-Banging the only option in this situation? Or can Raspberry Pi handle this?


1 Answer 1


You can use any spare pair of GPIO to create a software I2C bus. As you have noted you will need to use external pull-ups to 3V3 on the chosen GPIO.

You need to add an entry to /boot/config.txt

For details see /boot/overlays/README

Name:   i2c-gpio
Info:   Adds support for software i2c controller on gpio pins
Load:   dtoverlay=i2c-gpio,<param>=<val>
Params: i2c_gpio_sda            GPIO used for I2C data (default "23")

        i2c_gpio_scl            GPIO used for I2C clock (default "24")

        i2c_gpio_delay_us       Clock delay in microseconds
                                (default "2" = ~100kHz)

E.g. to use GPIO 17 for SDA and 23 for SCL add the following entry to /boot/config.txt


A new bus will then be available. I'm not sure of the number but I think the first new bus will be /dev/i2c-3, the next (if any) /dev/i2c-4 etc.

This bus may be used in exactly the same way as the hardware buses, e.g. i2cdetect -y 3 will show devices on the new bus.

  • And using the overlays like this will cause them to work the same way as the normal I2C pins? I've seen it mentioned elsewhere that bit banging is the only proper way to do it since the gpio pins don't support open drain, but that may have been for an older version of the Raspberry Pi
    – Tyler
    Aug 27, 2019 at 12:26
  • I don't think any of the GPIO actually support open drain even when using the GPIO capable of being used by the Pi's I2C hardware. The line will be set to a low output to set 0 and set as a input to set 1 (relying on the pull-up to pull the GPIO high).
    – joan
    Aug 27, 2019 at 12:30
  • Final question before accepting this as the answer, are you able to specify which pins you would like to send the message on? For example, if I have three i2c buses running, am I able to specify that I want to send the message on a specific bus/pin, or would it be broadcasted every time you would like to send a message?
    – Tyler
    Aug 27, 2019 at 12:37
  • I'll edit the answer.
    – joan
    Aug 27, 2019 at 12: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.