I'd like to use the Raspberry Pi to measure AC frequency. To keep the circuit as simple as possible, I wonder how much abuse the GPIO pins will handle.

PIC and AVR microcontrollers have protection on all their inputs, in the form of a pair of diodes from ground to pin, and pin to Vcc. This is from the ATmega328P:

ATmega328 input pin

These diodes make it safe (if unadvisable) to connect the pin directly to a higher voltage AC supply, with just a single high-value resistor.

I would still limit the voltage with an external zener, but that leaves the waveform in the range -0.6 to +5.1 V. I'd rather not divide it down with resistors, as this would lower the input impedance and make it less sensitive.

Does the Raspberry Pi have clamping diodes on each GPIO pin? If so, what is the maximum current that they can take? If not, what is the safe input voltage range - is it only 0 to 3.3 V, or can it be -0.5 to 3.3 V?


The best source I'm aware of is GPIO Electrical Specifications. Raspberry Pi input and output pin voltage and current capability.

That suggests that a negative voltage is a no, and that you should current limit any overvoltage to less than 0.5 mA.

  • Thanks. I suspect when they say do not connect a Voltage Source, they mean a low-impedance one. There are diodes in the pin circuit diagram. I will try a few uA on my oldest pi and see what happens. – tomnexus May 18 '15 at 22:51

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.