Transistor Driven Relay

Hey,

So I've been reading and learning as much as I can about transistors and relays so that I can properly implement them into my project. I've got 4 (5V) relays that require 20mA to operate. Instead of operating directly from the arduino output pin, I am using a 2n3904 transistor. I've got one of them working no problem. I used a 10k resistor from the arduino pin to the base of the 2n3904. 5v to relay coil with flyback diode. Relay coil to collector pin, emitter to ground.

The problem I have is when I want to use more than one relay will my current draw be too high for the arduino to handle? The hFE of the transistor seems to vary from 30 to 100 according to the datasheet. If I do actually get an hFE of 100 that puts the current to the coil at 50mA. Spread across 4 relays that puts my current draw at 200? Or am I understanding this wrong?

If the relay coil draws 20mA at 5V that is what it will draw no matter how hard that the transistor is turned on. In fact, I would use more like a 220 ohm base resistor to make sure that the transistor is fully saturated (turned on). A 10K base resistor is way to high. 4 such relays will draw 80mA. The hfe of the transistor, in this circuit, has little bearing on current as long as the transistor is saturated. The relay coil resistance is the controlling factor.

Ok thanks! So if I only need to be able to turn all the relays on and off at the same time, can I use the the 220hm resistor to the base of the transistor and connect all the relays to the collector of the same transistor?

Using a standard NPN transistor for switching

A 2N3904 can drive 4 relais in parallel if a single relais consumes 20mA.

The 2N3904 can handle a max. current of 200mA. In your case you need only 80mA. The voltage
drop between collector and emitter will be 0.4 Volts at 100mA.
The maximum power rating is 200mW. In your case you will have 0.08A * 0.4V = 0.032W (32mW).

This is true when your transistor is fully switched on. The amplification factor (hfe) is 200 upwards. So for your 80mA you need a base current of 0.4mA. Assuming your Arduino only gives you 4.8V and the base-emitter voltage drop is up to 0.8 volts you should use a 1K resistor.

Now you are absolutely on the save side with more than 4mA base current.

A 220 Ohms resistor might load our Arduino output theoretically with 20mA. A 1K resistor will give you a little bit more than 4mA (you only need 0.4mA). Small resistor values are required for high speed switching to compensate for the base-emitter capacitance. In that case a special HF transistor would be the better choice. You will probably not do any high speed switching with your relais.

If your 4 relais are placed closely together you will need only one flyback diode.

Wow thanks so much, that really clears up so much for me! I think I'm good to go