4
\$\begingroup\$

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

\$\endgroup\$
8
  • 2
    \$\begingroup\$ It's more likely that the transistor is dead. Have you tried a different transistor? \$\endgroup\$
    – dirac16
    Commented Oct 20, 2017 at 19:22
  • \$\begingroup\$ 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. \$\endgroup\$
    – Transistor
    Commented Oct 20, 2017 at 19:55
  • \$\begingroup\$ 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? \$\endgroup\$
    – jonk
    Commented Oct 20, 2017 at 20:04
  • 1
    \$\begingroup\$ 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"). \$\endgroup\$
    – mguima
    Commented Oct 20, 2017 at 20:26
  • 1
    \$\begingroup\$ Also remember commons.wikimedia.org/wiki/… \$\endgroup\$
    – KalleMP
    Commented Jan 3, 2020 at 20:09

5 Answers 5

9
\$\begingroup\$

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.

\$\endgroup\$
12
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jan 3, 2020 at 15:10
  • 1
    \$\begingroup\$ @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". \$\endgroup\$
    – mguima
    Commented Apr 12, 2020 at 4:53
  • 1
    \$\begingroup\$ @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). \$\endgroup\$ Commented Jun 21, 2020 at 16:03
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ Commented Jun 21, 2020 at 16:05
  • \$\begingroup\$ @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, ... \$\endgroup\$
    – tlfong01
    Commented Oct 3, 2020 at 3:39
8
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ Welcome to EE.SE John and thanks for a good answer! \$\endgroup\$ Commented Jan 4, 2020 at 20:47
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Transistor
    Commented Jan 4, 2020 at 20:49
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – John Laker
    Commented Jan 6, 2020 at 11:22
6
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jan 4, 2020 at 20:32
5
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – crichavin
    Commented Oct 20, 2017 at 19:42
3
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – crichavin
    Commented Oct 20, 2017 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.