# Driving a relay with a Teensy 4.1

#### haldex

##### New member
Hi everyone,

I want to control a relay (SRD-03VDC-SL-C) using the teensy 4.1. However the current limit on the teensy GPIO pins is 4mA (or not?) and the minimum current required to energize the coil in the relay according to the datasheet is about 150mA. It's obvious that I cant control the relay directly from the GPIO pins so I found this guide as a solution: https://www.electronics-tutorials.ws/transistor/tran_4.html

Since I had all the components on hand I assembled the circuit with the following components:

2N2222 transistor
1N4007 diode
SRD-03VDC-SL-C relay
Rb = 650ohm (for a current limit of 4mA I used the formula : Rb = (Vin - Vbe)/Ib, Vin = 3.3, Vbe = 0.7, Ib = 0.004)
R = 10k ohm

https://tinyurl.com/2jypqwgr

According to the simulation, the transistor should saturate at Rb = 650ohm, however in reality it doesn't. The transistor will saturate at a value of Rb ≈ 470ohm, which means a current draw ≈ 5.5mA from the GPIO pin. My question is what am I doing wrong? I want to use a higher value resistor to minimize the current draw from the teensy but after testing the circuit with multiple Rb value it only seems to work with Rb = 470ohm. Why is there an extra resistor R in the circuit? apart from drawing extra current and sinking it, I don't see the use of this extra resistor (R). Maybe there is a better way of solving my problem?

Thanks for the help

Transistors in saturation have a gain of about 5 to 20 only, the hfe or beta parameter does not apply at all to saturation mode (saturation is very different from using a transistor as an amplifier). You need a darlington or a MOSFET to boost the 4mA of the Teensy to 150mA. Darlingtons have about 1000x gain at saturation, FETs are voltage operated so steady-state current is negligible.

You need a free-wheel diode to drive an inductive load like a relay, otherwise you'll fry the transistor/darlington/MOSFET.

Transistors in saturation have a gain of about 5 to 20 only, the hfe or beta parameter does not apply at all to saturation mode (saturation is very different from using a transistor as an amplifier). You need a darlington or a MOSFET to boost the 4mA of the Teensy to 150mA. Darlingtons have about 1000x gain at saturation, FETs are voltage operated so steady-state current is negligible.

You need a free-wheel diode to drive an inductive load like a relay, otherwise you'll fry the transistor/darlington/MOSFET.

Thanks for the recommendation, do you have any specific MOSFET p/n in mind? I'm not really sure how to choose the correct one for my application, or what criteria I should be looking for. For my needs it has to carry up to 200mA of current and switch with a voltage of <= 3.3v while drawing less than 4mA from the GPIO pin. Thanks

You could use one of these. It even includes the diode to go across the relay coil.
Designed for the job.

Thanks for the recommendation!

According to the datasheet this would fit my needs