# Why does this transistor circuit light the LED?

I'm trying to drive a 5v relay from an esp8266-12e via one of its digital outs (3.3v). However it doesn't produce enough current to trigger the relay. So I read how to do that from here and here.

I'm using a PN2222a transistor with an LED on a bread board to try this out, but it is not working as expected. Since the base in the NPN transistor doesn't have any power applied to it, I'd expect that the circuit would be open and the LED would not light. But it is lighting as seen in the pic. What am I missing (likely a lot)? Shouldn't it only light if I apply + voltage to the base?

If I test the transistor, assuming, the left most pin is the emmiter (e) (-) and then next is the base (B) and finally the collector (C), I am getting Veb = 7v and Vce = 7.6v.

[![

simulate this circuit – Schematic created using CircuitLab

]3]3 []4

• It's more likely that the transistor is dead. Have you tried a different transistor? Oct 20, 2017 at 19:22
• Good photo. Note that your base resistor is only connected to the base so the other end will not necessarily be 0 V but rather whatever the base voltage is. Oct 20, 2017 at 19:55
• Are you still wanting an explanation for the LED being on, on your protoboard there? Or are you looking for a circuit to activate a 12 V relay from a 3.3 V I/O pin on the ESP8266? I can't tell. (You provide two links you read and I'm not sure if this means you feel you can implement them, or if you are just curious now about an odd behavior unrelated to those links.) What's the real question, exactly?
– jonk
Oct 20, 2017 at 20:04
• As a rough general rule for begginers, never use resistors less then 4k7 in digital signals. The exception to this rule is if you know very exactly what and why you're doing this. (The load resistor for the led isn't "digital signal"). Oct 20, 2017 at 20:26
• Also remember commons.wikimedia.org/wiki/… Jan 3, 2020 at 20:09

Shouldn't it only light if I apply + voltage to the base?

No. If the base is disconnected (or the 1K resistor attached to the base is disconnected), is it still possible that the led lights up, even if there's no base current, due to leakage current in the transistor die, or due to the digital output from the eps8266-12 not being exactly at 0V.

It would be adviseable to connect a resistor (about 10k) from the base to 0V. This resistor provides a path for the leakage carriers to escape to ground, and this will stop the transistor conduction when there's no voltage applied to the 1K resistor.

Also, you're connecting the led incorrectly. The led connects the 12V directly to the transistor's collector, this is wrong. If the transistor conducts (if there is base current), the led will fry. You should put a load resistor (about 470 ohms) in series with the led. This is my suggestion of improvement to your circuit:

simulate this circuit – Schematic created using CircuitLab

Thanks to the user tlfong01 for pointing an error in the words that I used to describe the base-resistor.

Since English is not my home language, I ask for any suggestions to improve the text and thank you in advance.

• I've never heard that you must connect this resistor. I know it can be useful, in some situations, but I didn't think it was required. Jan 3, 2020 at 15:10
• @user253751 This depends on WHO is requiring. There's no an absolute requirer. I think that this resistor IS required, I would not go on without one, since the absence of this resistor could lead to improper function of this circuit; and I'm sure I'm not alone with this opinion. Surely there are persons (most of them are wiser than me) that do not think that this resistor IS "required". Apr 12, 2020 at 4:53
• @user253751 -- If the 1K input is going to be floating part of the time (unconnected), then the 10K pull-down resistor is recommended to keep the transistor from turning on from stray voltages - such as static electricity, or signals coming in from radio waves, or EMI electromagnetic interference. You act like a big antenna, and the ever-present 60-Hz line-hum is also present as radio waves that can turn the LED on just be touching the 1K input with your finger -- possibly -- it depends on your exact environment, which is also constantly changing (the EMI). Jun 21, 2020 at 16:03
• @user253751 -- If you have the 1K resistor attached to a microcontroller pin, but the pin is configured as an input, then it is for all practical purposes floating. Then you would need the 10K pull-down if that is how you have things working. Jun 21, 2020 at 16:05
• @mguima, I also read that the Rb 10k to ground is required, especially in high frequencies. But it is a bit vague to say the Rb is to polarize the base. What I read is the since current/charges leaks through CB junction and Rb provides a path for the charges to escape to ground, otherwise the leaked charges would be blocked and crowded at the base which becomes a pole of a dipole. In other words, I would say Rb is there to avoid polarizing Rb. / to continue, ... Oct 3, 2020 at 3:39

My life as a 50 something Shed-dweller has led me to the fascinating world of electronics, and recently I've been hoovering up as much information as I can about transistors.

I see this is an old post but having experienced and then Googled exactly the same problem I landed here. I tried a few of these solutions which didn't work for me, then in a desperate last ditch I randomly turned my transistor the other way around. It worked perfectly.

I noticed the post here refers to a 2N2222 in the schematic and a PN2222A in the picture. As far as I understand these are 2 different transistors and more importantly the pins are the opposite way around. Looking at the flat side the 2N2222 pinout is cbe left to right and the PN2222AA is ebc.

I've also recently understood that testing these transistors using a DMM in diode mode will give a higher reading across b to e than b to c, hence you can identify the emitter by the higher reading.

Anyway I'm a total novice and I confused the pins on my 2N2222 thinking it was a PN22222A, and the LED lit with nothing going to the base. Swapped it and it worked perfectly. If in the unlikely event that anyone else is as pinoutly challenged as I am, then I'm very glad to have given something back in return for the massive amounts of fascinating information I've consumed lately.

• Welcome to EE.SE John and thanks for a good answer! Jan 4, 2020 at 20:47
• Note to moderators. John has reposted his answer from yesterday which, I believe, was deleted in error. He does answer the question and came to the same conclusion as Spehro regarding pinout. Jan 4, 2020 at 20:49
• Thank you, my deleted answer was very brief, I edited the original but could not publish so added the new one. It's good to see so much care and attention in a forum to ensure quality of content. Jan 6, 2020 at 11:22

You are missing a current limiting resistor for the LED for a start. If the transistor turns on your LED will be destroyed.

Figure 1. A typical NPN LED (or relay) switch can be used to switch a higher current or higher voltage (or both) load. Note the conventional orientation of the schematic with positive to the top and negative to the bottom, reading from left to right. Source: Driving LEDs from higher voltage..

I'm using a PN2222a transistor with an LED on a bread board to try this out, but it is not working as expected. Since the base in the NPN transistor doesn't have any power applied to it, I'd expect that the circuit would be open and the LED would not light. But it is lighting as seen in the pic. What am I missing (likely a lot)? Shouldn't it only light if I apply + voltage to the base?

Your understanding is correct. You must have something else wrong. Post a photo of your setup.

If I test the transistor, assuming, the left most pin is the emmiter (e) (-) and then next is the base (B) and finally the collector (C), I am getting Veb = 7v and Vce = 7.6v.

It sounds as though you have a pinout error, a wiring error or a dud transistor.

• Sorry, a couple of errors in my post. a.)I originally uploaded a picture, but somehow it got lost after editing the diagram. It is there now. b.) my schematic is wrong, I actually do have a resistor in the emitter side. Sounds like a bad transistor. Oct 20, 2017 at 19:42

Given the voltage measurements you have, it looks to me like the part is not a PN2222A. If it came from some dubious source, then maybe it's marked wrong or was put in the wrong bag.

A PNP transistor with Japanese standard pinout (E-C-B) such as 2SA1015 would explain the measurements.

Usually when a transistor is severely damaged it will be either open or shorted, not exhibiting the relatively large voltage drop you are seeing, nor the "working" junction difference of 0.6V you are seeing. Reverse emitter-base breakdown voltage can be in the 7-9V range typically for jellybean silicon transistors.

Before continuing your experimentation, be sure to increase that base resistor to something reasonable such as a few K, and 2K is okay for the LED series resistor.

• Yeah, it's probably a P2N2222A as noted in the comment by KalleMP above. It is said Sauron himself proposed the naming for the different pin order, in order to throw Middle- and Virtual-Earth in an unspeakable chaos. Jan 4, 2020 at 20:32