I'm working on detecting whether or not an external 5v supply is on or off and found a few helpful related questions, specifically this one: Detecting 5V output from USB charger via Raspberry Pi

From the recommendations, I've come up with a simple voltage divider circuit, with a capacitor in parallel with one of the resistors and a zener in parallel with the entire circuit. The 5v source will be from a 5v wall transformer rated at 1 amp.


simulate this circuit – Schematic created using CircuitLab

I'm just wondering since there isn't any load on the 3.3v end of the voltage divider, do I need some sort of current limiting resistor in line with the 3.3v to protect the GPIO input?

3 Answers 3


It seems over engineered to me, but then I am not an electrical engineer, just software.

I'd just use a resistor divider with say a 50k and 25k resistor, no capacitor, no zener. The resistors would naturally limit the current. Even if the wall wart was over 5V the current should be small enough to be handled by the GPIO protection circuitry.

  • Definitely over engineered. I ended up using a somewhat simpler relay circuit instead.
    – nageeb
    Dec 5, 2017 at 20:57

The voltage divider circuit you have should work fine. However, it offers very limited over voltage protection. Upon a high voltage condition, if the Zener opens, then your board will likely be damaged.

It would be better to have the 5V supply trigger a transistor which causes a GPIO pin to go low.


DO NOT do this!!

Connecting a zener diode to a voltage source will release the magic blue smoke!

It is unclear WHY you have most of these components.

The capacitor will just increase the likelihood of damaging the GPIO (although the low impedance will probably protect it).

If you are concerned about the possibility of exceeding the input voltage (which the capacitor almost guarantees) use a diode clamp to 3.3V OR just use 2 equal value resistors, which will give 2.5V - well above the threshold of the GPIO. (I am an electrical engineer ;-)

  • I've seen this sort of configuration before... There's usually a high wattage 1Ω resistor on the input side acting as a fuse. Dec 3, 2017 at 23:41

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.