I'm working with a simple circuit using an infrared breakbeam sensor and a Raspberry Pi. Here's my best attempt to diagram how I have the circuit set up.

enter image description here

The Raspberry Pi will also supply both power and ground. I noticed in the Raspberry Pi 2 User Manual I got with the Pi (from Vilros) that there is a short section where it is mentioned that the Pi's GPIO pins can momentarily be set to outputs when the Pi starts up, and that if you have a circuit which connects one of the pins (as an intended input) to ground it could cause a short circuit and damage the Pi if/when the pin gets reset to an output on reboot. They recommend a 300 ohm resistor between the GPIO pin and ground pin. So I'm wondering if I can/should just put a 330 ohm resistor between the black wires (the transmitter and receiver share the same ground pin) and the ground pin to prevent a possible short circuit on startup. I was also wondering if maybe putting a diode on the white wire of the receiver would also prevent this issue.


3 Answers 3


You've misunderstood a couple of things, but i'll address the overall question first - Protection of the Raspberry Pi's GPIO from over-current conditions

The GPIO on the R-Pi can be subject to over-current conditions for multiple reasons, not just a start-up glitch where what should be a high-impedance (aka. resistance) input is an output instead, and could possibly be an output LOW meaning it's essentially a short-circuit to ground inside the R-PI.

As a general guideline for interfacing with ANY fancy logic/computer board like the R-Pi, CompactRIO, or pretty much any logic board that can have access to the outside world and doesn't already have its own ruggedized inputs/outputs (some boards do! always check datasheets/schematics to see how rugged they really are) you want to add some cheap protection yourself.

Typical external protection components are simply series resistors on every single GPIO in that interacts with the outside world or external voltage sources. So in this situation, a series 330 Ohm resistor between the R-Pi's GPIO pin and the rest of your circuits, as a middle-man.

The role of the series resistor is to prevent total current into, or out of, the pin to be limited and will never be able to 'short'.

The next major protection element people use to protect logic boards like these from the outside world is ESD and over-voltage (like TVS diodes) clamping diode arrays. Every single pin can benefit from having an ESD clamp from the pin to ground, to absorb static discharge events - and TVS diodes or zeners with additional resistors to allow permanent 'over voltage' situations without ever harming the logic boards on the other side of the circuit.

For your circuit you actually won't have the dangerous short-circuit condition on that pin, you have already got a pull-up resistor to the 3.3V rail which acts as the current limiting element. There is no other path to ground in your simple example to worry about, except maybe the IR sensor's output if that happens to have a proper high-current driver output (unlikely, it's most likely to be a variable resistance).

If you wanted to be super careful, and to follow the general guidelines I ranted on about earlier, you can do something like this (and add the resistor for every other GPIO which interfaces with the real world).


simulate this circuit – Schematic created using CircuitLab

With the 330 ohm resistor in there, the maximum input current to the GPIO pin if it was accidentally set to OUTPUT and LOW, assuming a 3.3V rail is connected directly to the input (but we still have the resistor there!) for whatever reason, then the maximum current will be only 10mA (3.3V/330R= 0.01A).


They recommend a 300 ohm resistor between the GPIO pin and ground pin.

If it is written that way, I don't think that is what they want. Also do not put a 300 ohm resistor in the black wires! They are your ground connectors and you want to have a good ground. Just put a series resistor it in the white wire. A GPIO input has an impedance of about 60KOhm so adding an extra 1k (or 330 ohm as they mention) is not noticeable.


If you want to permanently configure a GPIO input pin for logic LOW—i.e., the logic level at that input pin never changes: it is always logic LOW with no external circuitry actively driving a voltage onto the GPIO pin, then it appears to me that the Vilros manual recommends you NOT connect the GPIO input pin directly to GROUND. Instead, connect the GPIO input pin through a 330 Ω current-limiting resistor to GROUND. This is a sensible precaution, in my opinion. (n.b. A GPIO input pin having no external circuitry connected to it reads logic HIGH by default; therefore, there is no need to provide an external 330 Ω pull-up resistor when "constant logic HIGH input" is desired at the GPIO input pin.)

As far as I can tell, you are not permanently connecting the GPIO input pin to GROUND. Your GPIO input pin is connected to an external circuit that actively drives a voltage onto the GPIO input pin. It is very likely, then, that your external circuit places components between the GROUND bus, the 3V3 power bus, and the GPIO pin. Those external components probably suffice to safely limit the current flowing into or out of the GPIO pin at power up. Therefore, the comment in the Vilros manual regarding the 330 Ω current-limiting resistor is not automatically applicable in your case.

That being said, it is a good idea to verify and ensure your external circuitry does not provide a low-impedance path from the GPIO pin to GROUND or to the 3V3 power bus when the external circuit powers up—and I assume this is the situation you are wondering/asking about. This is difficult to answer without knowing more about the IR transmitter and IR receiver parts you are using.

Can you provide the part numbers for the IR transmitter and IR receiver parts you are using?

And for what it's worth, after the Pi powers up and your program is running, you need to ensure your external circuitry does not sink or source excessive current via the GPIO output pin—e.g., the GPIO output pin that is powering the IR transmitter; otherwise you risk damaging the GPIO output pin. (sink := current flowing into the GPIO pin; source := current flowing out of the GPIO pin) If the IR Transmitter is nothing more than an infrared LED, then you must insert a current-limiting resistor in series with the GPIO output pin and the LED to limit the amount of current that's being sourced by the GPIO output pin into the LED. The resistor's value needs to be calculated based on the GPIO pin's electrical specifications AND information obtained from the IR LED's data sheet.

  • \$\begingroup\$ This is the IR sensor I'm using adafruit.com/product/2167. It's kind of hard for me to decipher the datasheet for it. \$\endgroup\$
    – Josh2566
    Dec 20, 2017 at 3:52
  • \$\begingroup\$ My best guess is, the IR receiver has an NPN open-collector output. In that data sheet the figure for the IR receiver part seems to have two separate examples. Example 1 is a single 5.1k pull-up resistor (digital output). Example 2 is an LED in series with a 1k (current limiting) resistor. The OEM uses 5.1k with VCC=5V, which is ~1 mA through the internal NPN transistor. The RPi is a 3.3 Volt system, so as a starting point use 3.3V/1mA = 3.3kohm for your pull-up resistor. \$\endgroup\$ Dec 21, 2017 at 6:21
  • \$\begingroup\$ P.S. Google Translate is helpful for translating data sheets that are published in Chinese, if you haven't already discovered this. \$\endgroup\$ Dec 21, 2017 at 6:23
  • \$\begingroup\$ To clarify, resistor R2 in your figure should be 3.3k, not 10k. Testing of the IR Receiver part would need to be done to ensure it does not present a low-impedance path to ground upon being powered up. If you wanted to keep the 330 ohm resistor in series with the GPIO input pin as a "better safe than sorry" measure, I /think/ that should be okay. \$\endgroup\$ Dec 21, 2017 at 6:38
  • \$\begingroup\$ Yes, it is an open collector. The reason I chose a 10K resistor is because in the description section for the sensor (on the page I posted the link to above) it says: "Most microcontrollers have the ability to turn on a built in pull up resistor. If you do not, connect a 10K resistor between the white wire of the receiver and the red wire." Granted, they also talked about powering it with 5V and I'm using 3.3V. So maybe the 10K resistor was more for 5V. I'm thinking I'll put a 330 ohm resistor in series with the input pin just to be safe. \$\endgroup\$
    – Josh2566
    Dec 22, 2017 at 3:26

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.