I have a very back to basics question. I've been using a 5v relay with the raspberry pi. The relay trigger is connected directly to an output pin and the other side is connected to the ground of the board. I've been counting on the internal coil resistance to serve as over-current protection, and so far in small application it worked out fine. But I've have been told that this is not a good idea and i might damage the board if the output is held HIGH for too long. Any confirmation on this would be appreciated.

  • 1
    \$\begingroup\$ How big and chunky is the relay? Anyway, I'm afraid that you'll need a transistor of some sort for driving the relay. \$\endgroup\$
    – Dzarda
    Jan 13, 2014 at 0:03
  • \$\begingroup\$ The relay is small, and I can drive it fine with the 3.3V output. I was just worried about the long term implication of not having any resistor is between. I seems to be fine for small applications. \$\endgroup\$ Jan 13, 2014 at 0:05
  • 1
    \$\begingroup\$ Cross check the Pi's current capabilities with the relay's consumption. That's all I can say. \$\endgroup\$
    – Dzarda
    Jan 13, 2014 at 0:11
  • \$\begingroup\$ Also add a Flyback diode to the relay coil if you haven't added one already. I found a relevant question in Raspberry Pi What is the maximum current the GPIO pins can output? \$\endgroup\$
    – alexan_e
    Jan 13, 2014 at 0:14
  • \$\begingroup\$ possible duplicate of How can i drive a 5v 120VAC 80mA with 15A contacts with a raspberry pi? \$\endgroup\$ Jan 13, 2014 at 10:23

1 Answer 1


It might work at the moment, but you are running a risk not checking the various specs out and making sure you work within them. So I would use a transistor and the correct voltage.

I haven't used an R-pi, nor do I know the relay part number you are using, but if you are determined to go ahaead without a transistor, then what I would do is:

  • Read the R-pi datasheet for it's pins maximum working current, and the general advice surrounding safe use of the pins.

  • Measure the relay coil with a multimeter to check it's DC resistance (and read it's datasheet for other specs such as working voltage range, etc), work out the current drawn from your pin using Ohm's law. See what value resistor you would need to lower current to a safe level.

  • Make sure there is a reverse diode across the coil to protect the pin from kickbacks.

Having said the above, I would again really advise against trying to power a relay directly from an R-pi's pin, especially the wrong voltage.
There are loads of simple tutorials on using a transistor controlled from an IO pin to switch the relay. Even if you don't want to use a 5V supply, at the very least still use the transistor with the 3.3V supply - any general purpose one will do.

Basically, if you are running outside the specs with stuff like this, it may work, may work for a while then blow, cause seemingly unrelated issues, etc. That's why it's never a good idea to ignore them.


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.