John Public
Posts: 90
Joined: Thu Jan 16, 2014 2:16 pm

Protection GPIO pins

Thu Aug 03, 2017 11:34 am

I am connecting from GPIO12 from one RPi3 (sender) to another RPi3's GPIO12 (receiver). Then I'm sending data by setting (bitbanging) the sender's GPIO high or low. So the sender has GPIO 12 as "output" and the rerceiver as "input".
I've got just a straight wire and everything works fine. But I am thinking that I should have some sort of voltage protection. What if I accidentally set both GPIOs as INPUT? I'd like to put a very simple and rudimentary protection. I've have zeners and resistors and transistors. Would a zener do it?

User avatar
karrika
Posts: 1316
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: Protection GPIO pins

Thu Aug 03, 2017 12:53 pm

One way to protect the input pin is to add a diode between 3.3V and the data wire. If the voltage on the wire exceeds the max voltage it will be fed into the 3.3V line instead of breaking the GPIO input.

You could also add another diode between the GND and the input pin. If the voltage on the input pin drops below zero the pin is again protected. Just put the diodes in the right way. You don't want to put them so that the 3.3V is shorted to GND through 2 diodes.

User avatar
Burngate
Posts: 6427
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Protection GPIO pins

Thu Aug 03, 2017 5:38 pm

It might also be worth putting a resistor in series - or two, one at each end - so that no damage will occur if you accidentally set both as output.
Anything above 200R would work, 1k would be a reasonable value, and keep it below 100k anyway.

John Public
Posts: 90
Joined: Thu Jan 16, 2014 2:16 pm

Re: Protection GPIO pins

Thu Aug 03, 2017 6:26 pm

With a simple 2K resistor in the between like this:

Rpi3 (sender) GPIO (physical pin 32) -------->2K------>Rpi3 (receiver) GPIO (physical pin 32)

Just to bring down the voltage? Can you explain how that help (I'm a noob)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13696
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Protection GPIO pins

Thu Aug 03, 2017 7:38 pm

It helps because putting any voltage above say 4 Volt will blow up your PI!

A PI is NOT tolerant to higher voltages than it is powered with (3.3Volt).
This is the first thing you should know when handling GPIO's!

dwelch67
Posts: 1002
Joined: Sat May 26, 2012 5:32 pm

Re: Protection GPIO pins

Thu Aug 03, 2017 8:10 pm

this is between two PIs though so as long as the ground reference is tied properly and you dont make both an output at the same time, then you are good.

User avatar
Burngate
Posts: 6427
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Protection GPIO pins

Fri Aug 04, 2017 8:53 am

Accidents do happen.
At some time in the future, you will set both GPIO's to OUTPUT, and set one High and the other one Low.
Or some-one else's software will.
Or your kid brother takes a pair of scissors to the interconnecting cable, shorting both GPIOs to ground.

The reason I suggested two resistors is that, if the Pis are separated by by any distance, both Pis are protected from accidents in between - and it would look neater.

Return to “Bare metal, Assembly language”