# How to calculate the required base resistor for this BJT-relay circuit?

I'm trying to design a relay circuit for my first PCB and have come up with the following:

• The 10K value for R7 is just a placeholder. R7 is what I'm trying to determine.
• The transistor should turn the relay on and off based on whether D2 is at 5V or GND.
• The relay is a 5V relay and has a coil resistance of 63 Ohms, so the coil current is 79.4mA.

How do I determine what value the base resistor (R7) should have for the circuit to work?

Datasheets: Relay, Diode, Transistor

My attempt:

Ic = 80mA (relay current) + [5V-Vce]/10K (current through LED)
Ic = 80mA (relay current) + [5V-0.5]/10K (current through LED)
Ic = 80mA + 0.45mA = 80.45mA

Ic = hFE*Ib
Ib = Ic/hFE
Ib = 80.45mA/120 = 670uA

Ib = [5V (D2 high voltage) - 1.2V (base-emitter saturation voltage from datasheet)] / R7
R7 = [5V-1.2V]/Ib
R7 = 3.8V/670uA
R7 = 5672 Ohms

So, according to my calculations, the base resistor should be ~5.6 kOhms. However, I have no idea whether did this correctly or not.

• I think there is no need to calculate Ic this way. read datasheet to get saturation current of transistor, rest is same. Commented May 20, 2014 at 15:25
• Good job, your calculations are correct. You won't have anywhere near 1.2V VBE since that spec is with a base current of 80mA or something like that. It will be closer to .7V. However, assuming 1.2V won't hurt, it will give you some margin for variations in beta due to temperature and collector current. Commented May 20, 2014 at 15:26
• I think you'll want a much lower value resistor in series with the LED - the LED will be very dim with only 0.45 mA. I'd suggest 560 - 1K ohm to give around 5 mA through the LED. Commented May 20, 2014 at 15:56

Yes, that's essentially correct.

However, you should actually over-drive the base of the transistor in order to make sure that it stays in saturation even if conditions change a bit (particularly transistor current transfer ratio, which is difficult to control precisely). This is called a "design margin".

So, assume that in the worst case, the hFE of your transistor is 1/2 or even 1/3 the "nominal" value, and redo your resistor calculation accordingly. There's no harm in introducing more current than needed (within limits, of course) to the base of a transistor.

• If I over-drive the transistor, won't that cause more current to flow through the transistor and in turn the relay coil? Would that be bad for the relay since the datasheet says "Coil Current: 79.4mA"?
– Nate
Commented May 20, 2014 at 15:35
• No, the load current is determined by the load voltage and load resistance. The transistor can't "cause" more current to flow than that. Commented May 20, 2014 at 15:41
• Doesn't the equation Ic = hFE*Ib indicate Ic is "driven" by the base current? Meaning that if the base current is increased, the collector current must also be increased? It seems like what you're saying contradicts that?
– Nate
Commented May 20, 2014 at 16:02
• No, The collector current is limited to that value -- it can be less, but it cannot be greater. Commented May 20, 2014 at 16:05

To ensure the transistor saturates fully, it's normal to use a "forced beta" in the range of 10~20. The higher beta is more applicable to low collector currents compared to the maximum. If you read the datasheet you can see that the saturation voltage is guaranteed at 80mA base current and 800mA collector current.

If we use the 20 figure, since your relay current << 800mA, then the base current should be 4mA, and the resistor about 1K (your 5V may not be able to get quite to 5V with a 4mA load, so it's best to be a bit on the conservative side).