# 2n2222 for relay switching

Discussion in 'General Electronics Chat' started by Dritech, Jun 22, 2014.

1. ### Dritech Thread Starter Well-Known Member

Sep 21, 2011
761
5
Hi all,

I am using a 2n2222 transistor for switching a 5V 185mA 27ohms relay. I calculated that the base resistor should be 270ohms. Why am I getting approximately 3.2V at the relay terminal and not a value close to 5V? 3.2V are not enough for switching my relay.
Also, the 2n2222 transistor is getting quite hot.

Any help or suggestion would be highly appreciated.

2. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,923
601
Got schematic?

3. ### inwo Well-Known Member

Nov 7, 2013
2,441
315
What is the base current or voltage ahead of the base 270ohm.

4. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,070
With the transistor saturated, you should have a voltage at the collector of ~0.3V, meaning that the relay should get 5V-0.3V= 4.7V.

An logic-level NFET would be a better choice for a relay driver.

Last edited: Jun 22, 2014
5. ### AnalogKid AAC Fanatic!

Aug 1, 2013
5,584
1,584
Is the transistor connected as an emitter follower or a saturated switch?

ak

6. ### Dritech Thread Starter Well-Known Member

Sep 21, 2011
761
5
Hi, the 2n2222 have a base resistor of 270ohms which is connected to a micro. The collector is connected to the relay and the emitter is connected to ground.

5V from a microcontroller.

7. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,923
601
(5-.6)/270=.0163 A=16.3 mA

Assuming Vcc=5 volts.
(5-.4)/27=0.1704 A=170.4 mA

8. ### Papabravo Expert

Feb 24, 2006
11,083
2,159
Except the microprocessor cannot source 16 mA. It can probably only put the transistor into the linear range and that is why it is not turned on. What voltage is the processor putting out ahead of the 270 ohm base resistor?

9. ### Dritech Thread Starter Well-Known Member

Sep 21, 2011
761
5
Thanks for the replies. The PIC18f I/O can supply up to 25mA.

10. ### Dritech Thread Starter Well-Known Member

Sep 21, 2011
761
5
Note that when I changed the transistors to TIP122, the circuit worked (using same base resistor etc.). The problem is that I have a PCB design with the 2N2222 package so i cannot fit a TIP122.

11. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,070
But not at 5V. When sourcing 25mA, the PIC pin wont even make it to 4V. Look at the data sheet.

absf likes this.
12. ### absf Senior Member

Dec 29, 2010
1,654
443
TIP122 is an NPN darlington transistor. There are some darlington NPN in TO92 foot print eg. BC517. Just do a google search and see which one is easily available to you.

Did you try MOSFET? I think that should be the right choice for your job.

Allen

Last edited: Jun 23, 2014
13. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,906
1,789
Guess again. While it may be rated to put out such a current without damage it does not mean the output will stay at 5V when doing so.

Measure the PIC pin when doing this. Actually drawing the schematic and noting the voltage at every node is the best way to go.

Nov 7, 2013
2,441
315
Measured?

15. ### Papabravo Expert

Feb 24, 2006
11,083
2,159
It is easier for a pin to sink current than to source current. Are you sure it can source the required current and maintain the output at or near Vcc?

16. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,923
601
We don't actually know what Vcc is. OP never said what it is.

17. ### inwo Well-Known Member

Nov 7, 2013
2,441
315

..................................................................................................................

Jul 18, 2013
12,937
3,559

+1
After all the previous posts here on the subject, I am surprised why some still opt for a bi-polar for Pic or μp outputs?
Max.

19. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,923
601
My guess, based on my own education, is that we just follow our education. My curriculum spent a lot of time on BJT in lectures, homework and lab experiments. I had some instruction in FETs, but not anywhere as much as BJT and I don't remember doing any lab experiments with FETs.

And inexperienced people like me don't really know the pitfalls of uC. We read on paper that it will do: "5 volts and 25 mA" and we take it for complete truth. Many times I look at datasheets and I know that I don't know what most of the stuff in the tables actually mean.