# Transistor resistor calculation help (design revision 1)

I posted my original design yesterday and got many comments about my errors. This is revision 1 of my design. I am now pretty sure I have the load resistors calculated correctly, but still unsure about the base resistor for the transistor.

To find the base resistor value I used the calculator on this site . On the right side of my image you can see I used these values:

1. hFE = 100 (Based on comments on my previous post and highlighted on the data sheet.)
2. RL = 70 (This where I'm not sure. It doesn't seem to make sense this would impact it.)
3. Vcc = 5 V (5 V supply pin on my Pi Zero W)
4. Vi = 3.3 V (3.3 V GPIO pin supply)

For reference, the post that I have revised the design was this one here.

My goal is to get as many of these IR LEDs powered off of the 5V supply using the 3.3 V GPIO to control it on/off using the materials I have available (PN2222A transistor, IR333A LEDs).

• Your three LEDs in series will be a problem for a 5V supply voltage. If they are red LEDs, each will need a minimum of 1.8V (likely 2 volts) so the series will need 5.4 to 6 volts to light up (plus 0.5v to 1V for reliable current limiting resistor). If they are white or blue LEDs, you'll have even more trouble with 2.7 to 3.2v across each. Commented Oct 29, 2021 at 14:57
• They are IR leds, with a forward voltage of 1.2V, you can see this on the data sheet and in my calculation. Commented Oct 29, 2021 at 15:01
• How many total LED's do you have? Do you want to use them all? If you want to make a Joule Thief, you can put all 12 in series, and replace the 1K resistor with a potentiometer (or a digipot - a digital potentiometer) to control how much brightness / energy / infrared your LED's are throwing. Strictly what's on hand, or are you willing to buy an inductor for a few USD? (and add a second winding?) Commented Oct 30, 2021 at 21:29

The rule of thumb for base current calculator on a bjt used as a switch - base current = 10% of collector current.

• with total collector current = 80mA
• Base current should be 10% if collector = 8mA

Then I/o pin voltage = 3.3 and Vbe = 0.6v so voltage drop from pin to base = 2.7v.

Therefore, base resistor = 2.7v/0.008A = 330 ohms.

The Base current should not be limiting the collector current. The transistor is a switch on this design (not a current limiter). Your resistor in series with the LEDs should limit the current.

The Ib=10*Ic rule is overkill. The 2N2222 can be driven into saturation Ic=150mA with Ib=3mA. See https://www.onsemi.com/pdf/datasheet/p2n2222a-d.pdf, Figure 4. The required drive for 80mA will be about half that.

As it is, it's best not to draw more current from the R.pi GPIOs than absolutely necessary. The 3.3V rail is only 50mA total. More here: https://raspberrypi.stackexchange.com/questions/9298/what-is-the-maximum-current-the-gpio-pins-can-output

Not knowing what else is using 3.3V power in your system (including other R.pi GPIOs), this could be a problem in the making if you demand too much GPIO current driving the 2N2222 base.

How to address this? Your simplest option is to use a FET. A common device like a BSS138 can easily handle 80mA, and it's available in an SOT-23 package. This will provide adequate drive and not load the R.pi GPIO at all. Even better, here's one that's specified for 2.1A, also in SOT-23: https://www.onsemi.com/pdf/datasheet/mgsf1n03lt1-d.pdf

Another MOSFET tip: the higher you drive Vgs, the lower the 'on' resistance. Add a 3.3V-to-5V level shifter (use another n-FET), then drive the power FET Vgs to +5V for even greater efficiency.

Finally, Here's another approach to consider: a DC-DC regulator. This one will accept 5V and step down to the LED drive voltage, at a current determined by a sense resistor: https://www.diodes.com/assets/Datasheets/PAM2804.pdf

• Would this one do the trick? I want one I can use in a breadboard and then solder into a perforated circuit board. cdn-shop.adafruit.com/datasheets/irlb8721pbf.pdf Commented Oct 30, 2021 at 8:34
• It would, but it’s more than you need. For the space and cost of that device, the LED driver IC I linked could do it for less. Commented Oct 30, 2021 at 18:31
• Problem for me with the one linked is that its surface mount, not through hole. Is there a through-hole one that you are aware of, better spec'd than what I just linked? Commented Nov 1, 2021 at 7:48

Save yourself the hassle and use a MOSFET instead of the NPN. They need no gate resistor and don't demand current from your GPIO pin. If you would need to go shopping for an appropriate base resistor, you could just as well buy a MOSFET. Also with a MOSFET there is virtually no limit to the number of LEDs. With NPN you are limited to whatever your GPIO pin can source multiplied by $$\h_{FE}\$$.