0

I'm new to electronics. I'm trying to control an an LED with a PNP transistor (Tested with both an S9012 and an S8550).

My circuit is as below:

enter image description here

The base voltage is controlled by an ESP32 GPIO which is either GND or 3.3 V. The result is that in both cases apparently the transistor is saturated and the LED is on!

Can anyone please tell me what is wrong with my circuit? Is 3.3 V too low to cut off the transistor? If so, what circuit should I use to control the transistor with an ESP32 GPIO (GND/3.3 V)?

ocrdu
  • 8,705
  • 21
  • 30
  • 42
AKTanara
  • 261
  • 1
  • 8
  • 2
    Not really the best schematic, because the 12 V "can" be applied to the GPIO used ... And then "sorry" for the ESP32 ? – Antonio51 Jan 09 '22 at 13:03
  • 2
    Is using an NPN transistor an option? – ocrdu Jan 09 '22 at 13:04
  • 2
    Keep in mind that whether the transistor is "on" or not depends on the voltage between the base and the emitter. You're using an ESP32 to set that voltage to either 12 V or 8.7 V. As you've discovered, changing between 12 V and 8.7 V doesn't really make a difference: both of those voltages are high enough to make the transistor be "on." – Cassie Swett Jan 09 '22 at 16:19
  • @Antonio51 Yep, lucky me that have checked the schematic and asked you guys before connecting it to the poor ESP... – AKTanara Jan 09 '22 at 16:57
  • @ocrdu it would be hard to implement the low-side switch but possible – AKTanara Jan 09 '22 at 16:58
  • @TannerSwett Thanks for the comment and explanation. I'm happy that I didn't try it on my poor ESP. – AKTanara Jan 09 '22 at 17:00

2 Answers2

6

In order to turn that PNP transistor off, you must raise the base voltage to around 12V. The 3.3V output of the ESP32 is not enough to stop the base current of the PNP transistor.

A simple solution is to use a low-side switch instead, with an NPN transistor. Or if you absolutely need a high-side switch you can use a second transistor (NPN) and a pull-up resistor, something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

Klas-Kenny
  • 4,283
  • 5
  • 24
  • First of all thanks for your prompt response. I have tested your first solution successfully. But I couldn't calculate resistors for the second solution. Is there any typical value for those? – AKTanara Jan 09 '22 at 13:33
  • 1
    @AKTanara R2 can be almost anything. I'd use something like 10k-47k. R3 and R4 should be calculated depending on the load and the transistor hFE, but for this specific case you can probably use something like 1k for both R3 and R4. – Klas-Kenny Jan 09 '22 at 13:38
  • Now that I review your schematic with the values you suggested for resistors, I get the rationale behind it... R2 is pull-up resistor for Q1 base and R3/R4 are current limiting resistors for Q1/Q2 bases. THANK YOU VERY MUCH – AKTanara Jan 09 '22 at 15:49
1

Using an NPN transistor is the easiest way out:

schematic

simulate this circuit – Schematic created using CircuitLab

See other answer if you must use a PNP transistor.

ocrdu
  • 8,705
  • 21
  • 30
  • 42
  • Thanks, Yes, I have tested this solution and worked but it would be better if I could have my switch in high-side and your last question is mine too... Isn't there any simpler circuit for high-side switch with GND/3v3 as command and 12V as power source? – AKTanara Jan 09 '22 at 13:39
  • 2
    To make a simple schematic smaller, stick a little unused wire off to the side, as above. – Spehro Pefhany Jan 09 '22 at 13:48