3

Is it safe to connect a GPIO output to a GPIO input??

For example: Set the GPIO input to GPIO.PUD_UP and connect it to GPIO output. Then when the output is HIGH, then the input is logic 1, and when the output is LOW then the input is logic 0.

Will it work?

Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
user28282
  • 107
  • 2
  • 7

2 Answers2

9

Yes, that will work.

I suggest you have something like a 1 kΩ resistor in series. That will limit the maximum current to 3.3 mA.

That will save the day when by mistake you set both GPIOs as outputs, one as a 1 and the other as a 0. Without the resistor that would result in a damaging short circuit.

Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
joan
  • 71,024
  • 5
  • 73
  • 106
4

It is perfectly ok to do this. After all it does not matter whether two digitial pins (one input, one output) of different devices or the same device are connected to each other.

The one important thing is to consider that the maximum ratings of the GPIO pins are not exceeded - especially the current drawn from the pin. This holds true for any setup but more importantly so for configurable pins (GPIO pins that can be both input and output). As the state of the pin might change either during boot-up or accidentially due to bugged software the series resistor (as mentioned in joan's answer) is important to limit the current if both pins are set as outputs.

Ghanima
  • 15,855
  • 15
  • 61
  • 119