I'm confused. I typically grab whatever GPIO pin is handiest when wiring components -- which is often GPIO 2 & 3. If I enable I2C but don't use an I2C component, can I still use GPIO 2 & 3? Are the special considerations I have to consider with default LOW/HIGH values?


When the Pi boots it checks to see if I2C bus 1 is enabled and if so sets GPIO 2 and 3 to mode ALT0. When in mode ALT0 the two GPIO are internally connected to the I2C hardware.

If you change the mode of one of those GPIO you disconnect it from the I2C hardware. As the connection is broken I2C messages can not be sent or received. The I2C hardware may be busy but there is no route to the outside world - messages are just discarded.

You will automatically change the GPIO mode and break the connection to the I2C hardware when you use GPIO 2 or 3 in a script. E.g. in a Python script you will normally set the GPIO to be in INPUT or OUTPUT mode.

The only special consideration is that GPIO 2 and 3 have hard-wired 1k8 pulls to 3V3 (they are needed when functioning as an I2C bus). You need to be aware of those comparatively strong pulls with any circuit you design.

By the way you can restore the I2C functionality (without rebooting) by setting the GPIO back to mode ALT0.

E.g. with my pigs utility

pigs m 2 0 m 3 0 # set GPIO 2/3 to mode ALT0

  • I'm going to have to think about this a bit. So... if I configure a Pi for I2C (as part of a standard setup process) but don't use any I2C devices, I can happily GPIO.setup(PIN,GPIO.OUT) and use that pin (2/3; 3/5) in the same way as if I hadn't config'd I2C. Right? That seems like a no brainer. – MACE Oct 12 '20 at 20:40
  • That is correct (as long as by don't use you also mean don't connect any I2C devices to the bus). – joan Oct 12 '20 at 21:05
  • Most excellent. Thank you. – MACE Oct 13 '20 at 22:42

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.