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?

  • A short 5 years late, even if connected properly this will most likely not work reliably, depending on your requirements of course. The pi is not good for precise timing operations. There is plenty of stuff written all over the web about it. For this purpose you might want to look into AVR chips.
    – php_nub_qq
    Apr 16, 2020 at 17:50
  • @php_nub_qq I found it good enough. Time tagging to a microsecond or two with the excellent PIGPIO library (by Joan, below), and a GPS PPS as a reference. Yes an AVR would do 10 times better.
    – tomnexus
    Apr 17, 2020 at 6:13

1 Answer 1


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, 2015 at 22:51
  • Any news on this? I am running into the same issue, need to read and write a signal that is 0.5mA@5V and the level converters that I have do not work with such a low current.
    – brainwash
    Dec 1, 2019 at 22:35
  • @brainwash I doubt anything official will be given. I'd add another resistor to try to keep the current as low as possible consistent with still being detected reliably.
    – joan
    Dec 1, 2019 at 23:01

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.