I'm creating a board which takes an external power source to drive motors which are controlled by a ULN2003A connected to the Raspberry Pi GPIO.

It would be nice if when the external power source is connected it could provide power to the Raspberry Pi itself through the 5V GPIO pin.

I appreciate this would require a voltage regulator, a polyfuse (to replace the one I'm bypassing that would normally protect the Micro B USB power input) and an ultrafast rectifier for reverse polarity protection.

My question is whether or not it is possible to detect that the Pi is already powered through USB and therefore block the back powering feature (to avoid having two sources connected).

Ideally if the user were to yank the Micro B USB cable the back powering would just kick in and take over. And likewise if the Micro B USB cable we re-inserted to disable it again. I don't really see how that could be possible so maybe it isn't!

  • \$\begingroup\$ You can sense if there is voltage on the Pi by sensing a default HIGH GPIO or the 5V rail it self? If there is no voltage there it means you can supply. But if they plug another power supply in you might not be able to sense that... \$\endgroup\$
    – Piotr Kula
    Commented Sep 17, 2013 at 14:41

1 Answer 1


It seems that what you are attempting is quite similar to what is implemented in the Arduino. See e.g. Arduino Uno's schematics. It requires a few external component (a MOSFET to serve as a switch, a diode, etc). to be implemented. I'm not familiar enough with the Raspberry Pi, so I dont know if this scheme could be implemented without modifying the board.

  • \$\begingroup\$ The Arduino actually implements the opposite of what is asked in the question: In the Arduino, the higher voltage source is used, so when an external 6-12 Volt supply is connected, it no longer draws from the USB, even if the USB remains connected. \$\endgroup\$ Commented Jun 19, 2013 at 10:09
  • \$\begingroup\$ @AnindoGhosh the Arduino uses an opamp as a comparator which can be arbitrarily trigger a pchannel mosfet. It does exactly what OP wants, regardless of the voltages used or the source of the voltages. \$\endgroup\$
    – Passerby
    Commented Oct 17, 2013 at 11:56

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.