0

I have relay that requires 20mA to operate, which is a bit more than the pi can give from one pin. I as wondering if t was safe to connect 2 GPIO pins together to power the relay. I would use a diode on each pin so I don't short anything out, but do I need to do anything else to protect it or should I just get a transistor?

EDIT-

I am using trying to use a JZC-11F relay.

  • Transistor should be better because if your program crashes halfway between setting both pins, only one might be left on and that's a problem. – Unsigned_Arduino Jul 25 '20 at 19:18
  • 1
    You haven't specified what "relay" but you are probably using one of the poorly-designed relay boards which are on the market. These are unsuitable for the Pi. See https://raspberrypi.stackexchange.com/a/100014/8697 – Milliways Jul 25 '20 at 23:49

1 Answers1

4

I would recommend a transistor - not only does it reduce the current required but it isolates the Pi from the relay which helps to ensure that the Pi is less likely to suffer damage.

Is this just a relay that you plan to drive directly? Don't forget about the reverse EMF that occurs when the relay is de-energised - it will generate a high enough voltage to destory sensitive components. Appropriate precautions need to be taken. It may be easier to buy a PCB with relay and logic level drive.

PeteC
  • 341
  • 1
  • 3