simulate this circuit – Schematic created using CircuitLab

I am taking the 3V from Pi and giving it to COM of a relay. The NO goes to GPIO 13 of the same Pi.

I have a 120V line that triggers the relay, which then connects the 3V to GPIO 13.

It was working fine for a couple of days. However, suddenly its rebooting everytime the relay triggers and connects the 3V to GPIO 13.

This happened when I was doing something else and my code to open GPIO 13 for input was not even executed. Can it be because of that? I am not explicitly setting the GPIO 13 to output, its in the default state after reboot (which I believe is Input)

I dont have immediate access to the Pi as its at a remote location. So I haven't been able to try it with some other pins yet.

Can this be a magnetic field issue when the relay gets triggered?

  • What do you mean by give 3V? You can't power the Pi via the GPIO. Do you mean you are using the GPIO to test if the relay is on or not?
    – joan
    May 25, 2018 at 9:39
  • Yes, in a nutshell, I'm checking if the relay is ON or not. I'm using it as a signal, which is detected in my code, then I act on it May 25, 2018 at 9:56
  • 1
    As long as it is no more than 3V3 then that is fine. That should not have caused a problem.
    – joan
    May 25, 2018 at 10:01
  • You might want to elaborate about how it is getting those 3 volts. Also, if at any point that pin is set as an output set low you are potentially sourcing too much current (unless an appropriate resistor is being used).
    – goldilocks
    May 25, 2018 at 12:38
  • @goldilocks, My first statement says I'm giving Pi its own 3v on GPIO 13. Not sure what you want me to elaborate. I'm not setting the pin as an output, because it happens even when I dont run any script. From what I read, default on reboot is Input May 25, 2018 at 13:48

1 Answer 1


There is nothing special about GPIO13 (including all 3 possible interpretations of the pin) which would cause the Pi to reboot, although the absence of any code leaves this indefinite.

The circuit however is poor design.

  1. You should always use a small series resistor (to prevent problems if the GPIO is configured as output).
  2. The input "floats" - you should use a pullup (or in the listed circuit a pulldown) - while the default has a pulldown this is very high impedance.
  3. There is no filtering or debounce - debounce can be done in software, but a hardware solution is needed to minimise interference.

Without detail of the wiring - in particular the physical layout/length it is possible the circuit would be subject to interference; at a minimum you should use low impedance terminations to minimise this.

A final point, naive users seem to assume that a pin should be connected to HIGH to trigger - most professional circuitry would connect between GPIO and GND; with CMOS circuitry there is no technical difference in performance, but running 3.3V supply over long external cabling is dangerous, and subjects the whole circuitry to additional risk of shorts/interference.

  • All this happened even before I executed my code. I need the thing to work normally if my code does not start. So the GPIO is in the default state. I have put debounce in my code, but like I said, the issue occurs even before I execute it. May 29, 2018 at 7:33
  • Are you saying that I should use GND instead of 3.3v? Will it trigger the GPIO.RISING event? May 29, 2018 at 7:34

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.