4

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.

[![

schematic

simulate this circuit – Schematic created using CircuitLab

]3]3 [enter image description here]4

crichavin
  • 141
  • 4
  • 2
    It's more likely that the transistor is dead. Have you tried a different transistor? – dirac16 Oct 20 '17 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. – Transistor Oct 20 '17 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 '17 at 20:04
  • The 1 ohm resistor isn't connected to anything and that's the reason why the led lighst up. Connect the base to ground using a 10K resistor. By the way, 1 ohm is almost nothing, it will fry your ESP8266 output. When you connect to ESP8266, use a higher resistance, about 4K7. – mguima Oct 20 '17 at 20:20
  • 1
    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"). – mguima Oct 20 '17 at 20:26
  • Just to point out some remote possibilities (not likely here, given the clear indication that this is a PN2222 BJT), some RF transistors have very low \$V_{CEO}\$ values. For example, I've got a container of 2N5770 RF BJTs and these have \$V_{CEO}=15\:\textrm{V}\$. Also, if for some reason the transistor's emitter gets treated as the collector, the very low \$V_{EBO}\$ spec might become the issue. – jonk Oct 20 '17 at 22:17
  • 1
    Also remember https://commons.wikimedia.org/wiki/File:2N2222,_PN2222,_and_P2N2222_BJT_Pinout.jpg – KalleMP Jan 03 '20 at 20:09
  • I have found that unconnected inputs can act as an antenna. Even if you have no broadcasting radio- or tv-antennas nearby, there's always electrical noise, and especially the ever-present line-hum (50 Hz or 60 Hz). If you have an oscilloscope, and another 1-Ohm resistor, place the resistor between Q1 emitter and ground, and take a look at the signal. If it's DC, then it's not line hum or electromagnetic interference (EMI), but one of the other explanations here. If there's any wiggle at all, it could be your Wi-Fi or the line-hum, etc. And you've just invented something like a crystal radio. – MicroservicesOnDDD Jul 17 '21 at 03:52

5 Answers5

9

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:

schematic

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.

mguima
  • 1,425
  • 11
  • 20
  • 1
    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*. – user253751 Jan 03 '20 at 15:10
  • 1
    @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". – mguima Apr 12 '20 at 04:53
  • 1
    @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). – MicroservicesOnDDD Jun 21 '20 at 16:03
  • 1
    @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. – MicroservicesOnDDD Jun 21 '20 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, ... – tlfong01 Oct 03 '20 at 03:39
  • / continue, ... This is necessary in MOSFET circuit where Rg (gate) similarly lets charges escape. Just thinking aloud. I have no knowledge or practical working experience in high frequency circuits, so I am only 50% sure my wild guess is correct. – tlfong01 Oct 03 '20 at 03:40
  • @tlfong01 I learned about this resistor in practice. I remember that when I was a teenager I found one specific BC549 transistor with a high-gain and so sensible that even with nothing connected to the base it could "sense" the approach of my hand (almost as if was a FET). But besides that, I somewhat incorrectly associated this resistor with the name "polarization" (polarização in my language), and that's where came the incorrect term "polarized" that I used in this answer. After your comment, I revisited the term and finally discovered, a few decades after, that this name is wrong. – mguima Oct 04 '20 at 00:08
  • Today (better late than never) I saw that this name is reserved to the resistors which, most of times in a voltage divider, keeps the base voltage at some level, in order to permit the feeding of a AC signal in the transistor. I changed the answer accordingly. – mguima Oct 04 '20 at 00:14
  • @user253751 although some years have passed, I revised the text, I changed "you must" for "it would be adviseable". In my home language the words for "you should" and "you must", in some situations, are the same, and now I see that the answer could be improved using a less impositive form. There are times when we can go on withouth this resistor; but, in this case, I suggested using it because it seemed to me that it could solve OP's problem. – mguima Oct 04 '20 at 00:29
  • @mguima, just a quick question: What do you mean by "impositive"? – tlfong01 Oct 04 '20 at 01:09
  • It should have been **"mandatory"**, or even better, "imperative", instead of "impositive". Portuguese and English have a lot of words that share the same latin root, but this was not the case (that are many English words ended with the suffix "ive", and most of them have a Portuguese cousin with the suffix "ivo"). – mguima Oct 04 '20 at 01:21
  • @mguima could you please also contribute to [this](https://electronics.stackexchange.com/questions/534791/lcd-delamination-and-lamination-process) as your previous contribution on LED posts were highly informative. – metron Nov 30 '20 at 14:51
7

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.

John Laker
  • 71
  • 1
  • 2
  • Welcome to EE.SE John and thanks for a good answer! – try-catch-finally Jan 04 '20 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. – Transistor Jan 04 '20 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. – John Laker Jan 06 '20 at 11:22
5

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

enter image description here

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.

Transistor
  • 168,990
  • 12
  • 186
  • 385
  • 1
    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. – crichavin Oct 20 '17 at 19:42
5

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.

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842
  • 1
    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. – Sredni Vashtar Jan 04 '20 at 20:32
3

From what I see on your breadboard it's likely that the transistor is dead and allows about 2.5mA current to flow.

You said that Vce=7.6V. This together with the fact that the forward voltage drop of the red led is 2V, the voltage drop across the 1k resistor will be about 2.5V. Therefore 2.5/1k=2.5mA current is flowing into the collector. But in normal situation this corresponds to a 0.7V drop across the base-emitter junction. So the transistor is probably dead.

dirac16
  • 1,774
  • 2
  • 12
  • 17
  • 1
    Thanks. I only have 2 at the moment, and they were both doing the same thing. Was hoping one would work. More arriving tomorrow so I can try again. – crichavin Oct 20 '17 at 19:50