OpenWrt Forum Archive

Topic: How can I use a 3.3v GPIO to drive a relay?

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm trying to drive a relay with a 3.3v GPIO. From what I've read, I could either use a solid state relay or use a NPN transistor and a 5v relay. I'm no expert at computer engineering, so I was wondering if someone could explain how I would connect a transistor, relay and resistor (if necessary). I'm also wondering what the exact specs on the parts I need would be. Thanks!

Connect the base of the transistor to the GPIO through a resistor (1k is a good starting value, 470R for more current). Connect the emitter to ground and the collector to the relay coil. Connect a diode in inverse parallel to the coil to absorb voltage spikes. Connect the other end of the coil to the power supply.

There are reed relays with 500 ohm coils.  I have some, but they are quite
old so I've no idea where they came from.  I have driven one of them
directly from 3.3v logic output in open-drain mode.  You still need the
diode though.

Thanks for the info guys.  I will try it out.

Have a look into opto-isolators. It will also protect your router from voltages in the circuit you are driving.

(Last edited by R0b on 31 Oct 2007, 14:03)

The discussion might have continued from here.