I want to turn a white LED on and off via my microcontroller GPIO. The ESP-01S board that I have uses an ESP8266 chip, which has a limit of 12 mA GPIO output current. However, I want to drive this LED with about 25 mA.

The transistor I have is a S8050C NPN transistor. I'm using resistor R1 to limit current for the LED and resistor R2 to limit current for the GPIO pin.


Edit here: https://www.circuit-diagram.org/circuits/8a2aa3cfd1e04356b4099cee6f851846

I know that I will have to scale R2 according to the value given for minimal current gain in the S8050C datasheet, so the current for the LED is high enough.

However, what I'm still unsure about, are the voltages: The supply voltage for the LED is 5 V. My microcontroller uses 3.3 V. Let's say the LED becomes defective and behaves like a wire - will the GPIO pin see the 5 V? Or will the transistor from collector to base function as a diode? So as long as 5 V is below the breakdown voltage, the pin is fine?

  • 1
    \$\begingroup\$ That's generally considered safe. Most (all?) MCUs today include protection diodes at the pin and the inclusion of R2 is likely high enough of a value that these protection diodes won't be over-burdened. In one processor family I recall, the maximum protection diode current is 2 mA. Others may vary. \$\endgroup\$
    – jonk
    Oct 27, 2021 at 18:23
  • 1
    \$\begingroup\$ No, only your transistor will see the supply voltage. You’re fine. \$\endgroup\$
    – winny
    Oct 27, 2021 at 18:23
  • 1
    \$\begingroup\$ Circuit is safe. NOTE Jonk is almost always right. In this case his comment on allowing current in protection diodes is bad advice. I have a longish answer on that on site. Protection diode current can get into unintended modes and wreak utter havoc. \$\endgroup\$
    – Russell McMahon
    Oct 27, 2021 at 19:01
  • 3
    \$\begingroup\$ In general, an NPN transistor almost always fails with the C-E junction partially or fully shorted (not a diode drop.) In my experience, the base is never affected. PNP is a different story however, as the Vcc always wants to come out of the base at one diode drop, whether E-C is shorted or not. \$\endgroup\$
    – rdtsc
    Oct 27, 2021 at 19:37
  • \$\begingroup\$ @RussellMcMahon Thanks for the correction. Protection diode current is only an "Absolute Maximum" specification (I didn't mention that fact.) It's not something "to do." However, I have seen many professional designs that intentionally allow up to about about 25% of it. Just saying. \$\endgroup\$
    – jonk
    Oct 28, 2021 at 19:42

2 Answers 2


Absolutely no problems at all.

Your design is correct.

The collector/drain of the external transistor will take care of the external VCC/VDD voltage.

Read the datasheet of your transistor and, in the very first page, you will find the maximum value of Vce/VDD.

Example: Vcemax = 40 V

  • \$\begingroup\$ I thought the worry was about Vcb? (which is 40 in this case, so it's fine) \$\endgroup\$ Oct 27, 2021 at 19:44
  • \$\begingroup\$ Since the emitter is connected to ground in all tests made by the manufacturer, all absolute maximum ratings are referenced to ground. \$\endgroup\$ Oct 27, 2021 at 20:00

No, you don't.

The VIO0 = Vbe + Ib*R2

if VIO0=3.3V

so Ib = (VIO0 - Vbe)/R2

You must take in account Ib that it is the output current. How much ESP-01S can gives.

With that:

Ic = Hfe Ib = (5V - Vled - Vce) / R1

  • \$\begingroup\$ Vce = Vcb+Vbe. If Vbe=0.7, So Vcb= 5-0.7. There is not problem. if Vbe=0, so Vcb=5, there is not problem \$\endgroup\$ Oct 28, 2021 at 11:54

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.