NPN to trigger relay not working

I’ve got a standard “how to control a relay” problem. The coil on the relay is 5v and takes 71mw. No problem, can’t drive it directly off a pin so, enter the NPN transistor. So, wire that up according to all the standard tutorials I can find. They are all more or less the same. Some use the optional flyback diode so the collapsing field doesn’t feedback into the micro, some don’t. Some use a 1k (or 2.2k) resistor on the base, some don’t. By and large tho, it’s all pretty identical. So, I wire it up. doesn’t work. I try a different transistor, still no joy. OK, test with an LED, it’s working. I can blink the LED on/off/on/off no problem. Back to the relay, no joy still. The LED uses 20mw, OK, so let’s try 71mw+ worth of LEDs. Doesn’t work. I try 2 LEDs (40mw), it works. 3 LEDs (60mw) and bingo, doesn’t work. OK, so SOMEWHERE between 40mw and 60mw this transistor isn’t working, so that would probably explain why my 71mw coil on the relay isn’t working either.

This is BASIC stuff. This SHOULD Just Work™. It doesn’t tho, and I’ve not a clue as to why. I’ve tried reversing the collector and emitter. I’ve tried using a different Arduino, different wires, 3 different NPN transistor types (2N2222, 2N4401 and 2N3904), different relays, every singular component in fact has been swapped with another to eliminate any specific component failure. I’ve tried driving the Arduino off of battery (3 AA’s for a 4.95v pack) and just the transistor off of battery in case the amount of USB power was an issue. I’ve duplicated the problem with the relay with a secondary device type (LEDs) so I know it’s not just the relay, but a general issue I’m having over 40mw’s worth of power… under 40mw the NPN is working just fine as a controller for switching to ground, over that, nadda.

I haven’t a CLUE as to WHY it’s not working tho, or what to do about it.

HELP!

arduinorelay.jpg

Let R1 be 150 Ohm to ensure transistor saturation. Increase voltage to coil to 6V. .. or even better: use a MOSFET transistor

knut_ny:
Let R1 be 150 Ohm to ensure transistor saturation.
Increase voltage to coil to 6V.

So your saying, swap out the 1k resistor, with a 150? So far I’ve tried it with a 1k, a 2.2k, and without a resistor at all… none of those three experiments worked. I’ll see if I can find a way of getting the array of resistors I have on hand to net me 150 ohm tho. I’d certainly be shocked it that got it working, but I’ll try!

As for the second recommendation of changing to 6v, the coil in the relay is a 5v coil. While I don’t suspect that 6v would destroy it, that suggestion of a solution confuses me… as same with the LEDs, they stopped working well before the transistor hit it’s max rating of 200mw or 600mw. Why would upping the the transistors voltage make any change?

As for using a MOSFET, I have used FETs in the past with relays, usually for 24v systems. I had figured with the 5v nature of this relay and the fact that it’s a pretty low voltage circuit (plus the NPN transistor solution is noted on HUNDREDS of tutorials) that this should just work. Changing out to a MOSFET won’t help me understand why it’s not working.

got a multimeter ? I guess Ubc > .5V (transistor not driven to saturation) ..and as an indicator for this situatuation: the transistor gets hot.. Voltage (gnd reference) at base should be near 0.7 .. 0.8V. Voltage at collector should be well below 1V

I would say reduce the value of the base resistor too. It seems that the transistor is not at the saturation. As you like of do experiments, reduce the value of the resistor an see when the relay starts to work. Any resistor with a value slower than that sould work.

Das_Wookie: They are all more or less the same. Some use the optional flyback diode so the collapsing field doesn't feedback into the micro, some don't.

The free-wheel diode is never optional, always include it.

luisilva: I would say reduce the value of the base resistor too. It seems that the transistor is not at the saturation. As you like of do experiments, reduce the value of the resistor an see when the relay starts to work. Any resistor with a value slower than that sould work.

Didn't work.

I tried with the recommended 150 Ohm (well, 147) and no change. I tried with the 100 and 47 each individually as well, and still no joy. This seems little different than just using a different length of wire but, I tried none the less. These results were the same as using no resistor at all... still no joy. The NPN will quite happily complete the circuit and blink 1 (20mw) or 2 (40mw) LEDs no problem, but can't seem to be able to provide enough current to trigger the coil (71mw) on the relay, or power 3 (60mw) or 4 (80mw) LEDs.

I also tried the recommended 6v (6.6v actually with four 1.65v AA batteries) as well, just to exhaustively test the recommended changes. None worked. I'm unable to either power 3 or 4 LEDs (for a second device with which to test) or the coil in the relay.

MarkT:

Das_Wookie: They are all more or less the same. Some use the optional flyback diode so the collapsing field doesn't feedback into the micro, some don't.

The free-wheel diode is never optional, always include it.

In general, sure. However, even you would admit it's not REQUIRED to make an LED blink. Will it shorten the life of the components, yes. It isn't NECESSARY however. For the point of the test, I'm including it, even with the LEDs, just to have it there... however I've done the testing without it as well, to the same (null) effect. Having it there, or not, has no impact on being able to blink 3 or 4 LEDs, or get the coil on the relay to energize.

knut_ny: got a multimeter ? I guess Ubc > .5V (transistor not driven to saturation) ..and as an indicator for this situatuation: the transistor gets hot.. Voltage (gnd reference) at base should be near 0.7 .. 0.8V. Voltage at collector should be well below 1V

Yes, I have a multimeter.

Sorry, you are losing me a little here with my ability to understand the direction to take with your guess as I don't know what "Ubc" is or if it's "> .5V" or not... and google wasn't any help either. The transistor is not hot.

Voltage at Base: 0.69v Voltage at Collector: 1.44v Voltage at Emitter: 4.65v

I've also tried swapping the collector and emitter around 180, just in case I'm being dense and using it 180 backwards, but I'm getting the same results either way I orient the transistor / colletor & emitter sides.

So this would imply that the (too high?) voltage at the collector is a problem??? I can't even fathom what I could do about that, or how to adjust it in such a way that it would make the circuit function as designed / laid out in every schematic I've seen for wiring up an NPN transistor to trigger a relay coil.

Voltage at Emitter: 4.65v

This is a problem! It must be 0V.

luisilva:

Voltage at Emitter: 4.65v

This is a problem! It must be 0V.

I might have screwed up the measurement there.... but in any event, even if it's correct, that doesn't tell me what's needed to fix it. You can see the breadboard wiring in the initial post. Do you see something horribly mis-wired that could be causing it?

If the assembly is what is in the breadboard of the picture, it’s ok. I’ve look to it very carefully.
You said that you use 4 batteries. Do you connect the “-” of the batteries to the GND of the Arduino board?
Don’t change the Emitter with the Collector. In NPN the Emitter must be connected to GND (0V) and the Collector must be connected to 5V (with the relay or led or whatever in between). It only work like this.

If you think that your measurement is incorrect, you can measure the Vce (voltage drop between the collector and the emitter, with the black probe in the emitter and the red probe in the collector).
I only have one more question. The values of the measurements that you post is the you have connected the relay (and it don’t work) or the led (and it is working)?

Could driving the relay in this way be asking too much of the Arduino power supply. When you are powering two LED’s use your multimeter on current to see how much current is being drawn. This is the only logical explaination from what you are saying. When you add the third LED they arent lighting, the only thing you are lacking to light the LED’s is more current.

sampazzer:
Could driving the relay in this way be asking too much of the Arduino power supply. When you are powering two LED’s use your multimeter on current to see how much current is being drawn. This is the only logical explaination from what you are saying. When you add the third LED they arent lighting, the only thing you are lacking to light the LED’s is more current.

I believe that is not. I have a shield with 8 relays, powered from one Arduino MEGA board. At least if the voltage regulator of the Arduino UNO is less powerful than the one in the MEGA. The MEGA regulator can source 800mA of current, in this case (71mw and 5V) he only need 14mA. I don’t think is this.

It’s a bad transistor or it’s not an npn! (Test the coil’s resistance while at it)

A 150ohm to base, gnd to emitter etc…

cjdelphi: It's a bad transistor or it's not an npn!

100% agree! At least is what it seams. But they are NPN (at least the part numbers that Das_Wookie gives are from NPN transistors) and he said that he test various transistors.

EDIT: BTW, I check if the pinout from the 2N3904 and 2N4401 are the same, and they are.

You don't show how you connected the relay.

I think the Uno has slightly less output capacity but yeah as you say I worked it out to be about 14.2mA also which shouldnt be a problem.

I’d check the coil resistance of the relay aswell. Also try and switch the relay external to the rest of the circuit.

Is that relay 71mW or 71mA? Try testing its coil resistance with a multimeter. Is the npn big enough to supply that? Could that have damaged your first one? Is the base of the npn getting enough mA ? You could always set up with a first npn to keep the arduino d_out much less than 1mA to supply 3mA from a 1k resistor and 5V to the base of a second transistor which supplies the relay coil.

I've had a bit more of a think about this. My arduino powered off USB only has 4.6V where it should be 5. Insert a transistor and that would be down to about 4V. Does your relay work with 4V instead of 5? The suggestion of giving it a 6V supply might not be such a bad idea.