# Power efficient IR LED driver for ATmega328p

I want to use a high power IR LED such as a Vishay TSAL6200 with a 3.3V ATmega328P. Since an output pin of that MCU can provide 'just' up to 20 mA I can't directly connect that LED but have to connect some transistor circuit. So the goal is to drive the LED with 200 mA, under a 38 kHz PWM scheme (say, 23 % to 50 % or so duty cycle).

What I figured from reading up on transistors is that in order to use a transistor for on/off switching I should saturate its base.

The 2N2222 transistor seems to be a common choice and allow for sufficient switching power. And it should be saturated when the base (I_B) is powered with 1/10 th of the collector power (I_B). Thus, for my use case, I_B should be 20 mA, right?

Looking at the ATmega328P output voltage figures (Figure 35-23, page 608) I understand that I should use V_OH (i.e. 2.2 V) when calculating the base resistor. Ok, the figure is for VCC = 3 V and not 3.3 V but perhaps this is close enough. Is this a fair approach?

Also, when computing the base/LED resistor values, I understand that I should subtract the voltage drop in the transistor. Looking at some datasheets/posts I think the drop is 0.6 V for that transistor.

So in my calculations I'm using the following variables:

VCC       =  3.3 V # circuit voltage
I_LED     = 200 mA # TSAL6200 LED peak forward current
I_B       =  20 mA # 2N2222 transistor base current
V_F       = 1.45 V # LED forward voltage
V_OH      = 2.2  V # ATmega328P output pin voltage at 20 mA
V_BE(sat) = 0.88 V # Base/emitter voltage drop at I_C=0.2 A when saturating
V_CE(sat) = 0.15 V # Collector/emitter voltage drop at I_C=0.2 A when saturating


So I arrived at this schematic:

simulate this circuit – Schematic created using CircuitLab

I calculated the resistor values like this:

R1 = (V_OH - V_BE(sat) / I_B = 66 Ohm
=> P1 = (V_OH - V_BE(sat)) * I_B = ~ 0.03 W

R2 = (VCC - V_F - V_CE(sat)) / I_LED =  8.5 Ohm
=> P = (VCC - V_F - V_CE(sat)) * I_LED = 0.34 W


See also an onsemi 2N2222A datasheet (i.e. Figure 2 and Figure 3 on page 3) for the used transistor parameters.

My main question regards power efficiency of such a circuit - can it be improved?

For example, is there perhaps another transistor part which saturates at lower current and thus would save some energy?

Is leakage current (when the output pin connected to the base is low) something to worry about? Or do such transistors usually have low leakage current?

Or are there more power efficient IR LEDs?

Re: Logic Level MOSFETS The consensus in the answers is to use a LL Mosfet for switching the IR LED for better power efficiency. Thus, I've searched a bit around and found a few candidates:

Part          Package      LL R_DS(on)             I_D@V_GS=3.3V  Q_g(nC)   Notes
IRF3708PbF    TO-220AB     14.5 mOhm/V_GS=2.8V     100 A            24      obsolete
IRLB8721PbF   TO-220AB     not tabulated/plotted    10 A             7.6    sold by adafruit for 3.3V logic
FQP30N06L     TO-220       not tabulated/plotted    10 A            15      sold by sparkfun for 3V logic
IRLZ44NPbF    TO-220AB     not tabulated/plotted    30 A            48
PSMN022-30PL  TO-220AB     40 mOhm/V_GS=3.3V(plot)  10 A             4.4
PSMN4R3-30PL  TO-220AB     7 mOhm/V_GS=3.3V (plot)  80 A            19
IRL40B209     TO-220AB     6 mOhm/V_GS=3.3V (plot)  30 A           180
IRLB8314PbF   TO-220AB     6 mOhm/V_GS=3.3B (plot) 100 A            40


So I filtered for through-hole parts, for easier experimentation (e.g. on bread boards). Unfortunately, this excludes many parts when targeting a logic level of <= 3.3 V.

Sources I used:

What surprises me is that Adafruit/Sparkfun are marketing the IRLB8721PbF/FQP30N06L explicitly also for 3.3 V logic levels when their datasheet doesn't specify a a R_DS(on) value for that level!

After RTFMing a bunch on MOSFETS, useful selection criteria seem to be:

• V_GS(th) is below 3.3 V (necessary condition)
• R_DS(on) is specified in a table for V_GS <= 3.3V, or
• a R_DS(on)/V_GS plot contains a data point for V_GS <= 3.3V
• otherwise, it's unclear if the Mosfet even fully switches at the 3.3 V logic level
• the total gate charge Q_G(tot): smaller is better (-> faster switching)

This process is a bit tricky, since only a few tabulate R_DS(on) for lower V_GS values. And the R_DS(on)/V_GS plot is usually relatively small and the curve often just starts at 3.3 V or so.

The IRF3708PbF looks like a good match because it has R_DS(on) tabulated for 2.8 V but it's EOL/obsolete. Also its Q_G is higher than others (i.e. it switches after 2.4 µs or so when limiting the output pin to 10 mA - i.e. 24 nC / 10**9 / 0.01 A = 2.4 µs). With 38 kHZ PWM, this would move the duty cycle by 9 % of the pulse width.

A high R_DS(on) shouldn't be a problem, since it's in the order of milli-Ohms and if necessary we could even adjust the LED series resistor (R2). Vishay has some ll Mosfets with R_DS(on) tabulated for <= 2.5 V and very low Q_G - but only in crazy SMT packages.

Thus, further concentrating on Q_G, the PSMN022-30PL with Q_G=4.4 nC seems to be the best choice for the target circuit, in a convenient package. It's gate should be loaded in 0.4 µs then when limiting the output pin current to 10 mA.

I sketched the Mosfet circuit like this:

simulate this circuit

Design notes:

• The purpose of R1 is to limit the gate current to 10 mA in order to reduce RF noise when discharging and possibly other weird effect. Its value is smaller than the recommended 330 Ohm since the voltage at the ATmega328P output pin drops to 2.6 V when 10 mA is consumed from it.
• R3 is a pull-down resistor to avoid that the gate is in a undefined/floating state during microcontroller reset.
• the source of the Mosfet is connected to ground and the load is connected to the drain, the only useful configuration for such a Mosfet, as I understand
• R2 protects the LED such it's limited to 200 mA (i.e. R2 = (VCC - V_F) / I_LED - R_DS(on) = (3.3 V - 1.45 V) / 0.2 A) - 0.04 Ohm)

Re: power efficient IR LEDs The radiant intensity (I_e in mW/sr) (under a fixed current and pulse-width) seems to be the primary property of an IR LED that shows how efficient it is. IOW, the higher mW/sr (at constant I_F and t_p) the better since you get more IR power under the same power budget. LEDs with a smaller angle of half intensity tend to have higher mW/sr values, thus, the selected part should have a angle only as wide as necessary.

Of course, the wave-length must match the receiver, i.e. the peak spectral sensitivity of consumer IR receivers such as the TSOP4438 is at 940 nm to 950 nm.

A few candidates I found using above selection criteria:

Part          I_e(mW/sr)     deg(half)   peak_wave(nm)   I_F(mA)  I_FM(mA)  I_Fp(mA)   V_F(V) V_F(V)@200mA V_F(V)@400mA
VSLY5940      600             3          940             100      200       400        1.65   1.8          2.25
SFH 4544      550            10          950             100      180       350        1.6    1.8          2.5
SFH 4545      550             5          950             100      199       410        1.5    1.6          1.8
TSAL6100      170            10          940             100      200       na         1.35   1.43         1.75
SFH 4546      130            20          950             100      199       400        1.5    1.6          1.75
HR5P-N4CA     115            15          940             100      na        na         1.52   na           na
HR5P-N4CB     121            15          940             100      na        na         1.42   na           na
TSAL6200       72            17          940             100      200       na         1.35   1.45         1.8
SFH 4547       50            30          950             100      199       400        1.5    1.6          1.9

I_FM -> tp/T = 0.5, tp = 100 μs
I_e  -> IF = 100 mA, tp = 20 ms
V_F  -> IF = 100 mA, tp = 20 ms
IFp  -> D=0.2, tp=10^-5


Sources I've used:

Since these LEDs are high powered, the question of eye safety might come up. Looking at the datasheets those parts doesn't seem to reach one significant threshold (4 W/sr) for an extended time frame. It might be possible to reach that at 1 A with a low duty-cycle/high carrier frequency, but it seems for safety, one may consider the average intensity, then.

So, the SFH 4546 looks like a good trade-off between relatively high degree of half-intensity and still high radiant intensity. Also, when doing 38 kHz PWM, it's specified to be fine at 400 mA. The only difference to the SFH 4546-AWBW variant seems to be the guaranteed minimal radiant intensity (i.e. 112 mW/sr vs. 71 mW/sr).

Re: SMT MOSFETs When not being restricted to through-hole components, there is definitely more choice in suitable ll MOSFETs. The still (relatively) easily usable SMT packages in that context are perhaps SOT-23 and SOT-89 ones. Since breakout boards are available for those (a.k.a. surfboards, DIP adapters - cf. e.g. Adafruit/Sparkfun) they can also be used for prototyping, although it requires some extra intricate soldering.

A small selection of such components for comparison with above's TO-220AB ones:

Part          Package      LL R_DS(on)             I_D@V_GS=3.3V  Q_g(nC)   Notes
PSMN022-30PL  TO-220AB     40 mOhm/V_GS=3.3V(plot) 10 A              4.4    for comparison
PJA3436       SOT-23       680 mOhm/V_GS=2.5V      2.5 A             0.9    ESD protection
PJA3434       SOT-23       350 mOhm/V_GS=2.5V      0.750 A           1.4    ESD
DMN3730U      SOT-23       560 mOhm/V_GS=2.5V      0.700 A           1.6    ESD
Si2300DS      SOT-23        70 mOhm/V_GS=2.5V      0.4   A           2
AO3400        SOT-23        24 mOhm/V_GS=2.5V      0.5   A           6
TSM210N02CX   SOT-23        25 mOhm/V_GS=2.5V      0.5   A           2.7
PMV30UN2      SOT-23        39 mOhm/V_GS=2.5V      1     A           6.2


So there are some parts available with even lower total gate charges.

And some parts feature internal ESD protection. Since the IRLED isn't an inductive load, the drain-source TVS diode looks superfluous. I'm not sure if the gate-source TVS diode is nice to have, in such a circuit - since I don't know how much of ESD one should expect. However, these parts have relatively higher R_DS(on) than others.

Curiously, the Panjit datasheets don't include safe operation area plots.

• ”Or are there more power efficient IR LEDs?” There is a constant stream of ever more efficient LEDs on the market for every wavelength. Feb 12, 2022 at 21:49
• In your calculation for R2 (marked R3 in the diagram!) you use V_drp this is the base-emitter voltage. What you should use is VCE_sat at the given I_B and I_LED taken from the data sheet of whatever transistor you are using. Feb 12, 2022 at 22:29
• Have you considered using a logic level FET? As the name implies they can be driven directly from a logic output (usually via a 10K resistor) Feb 12, 2022 at 22:34
• All 3 of the answers are telling you to use a FET, so they must know something! Just google logic level fet and possibly add Arduino to narrow it down. That's what I did when doing it for the first time. There's lots of information out there. Feb 13, 2022 at 0:03
• @maxschlepzig The 2N2222 is a generic part made by many different manufacturers. There is a basic JEDEC specification that any such transistor must meet in order to be sold as a 2N2222, but I guess that there are tolerances specified and some parameters not defined at all. See en.wikipedia.org/wiki/2N2222. Hence there are going to be differences between batches of 2N2222s made in different plants or even at different times in the same plant. Feb 20, 2022 at 22:54

Select an N-channel MOSFET with a logic-level gate voltage instead of the BJT.

That requires no static gate current in place of the fairly high base current you have for the your circuit.

It does require a transition gate current, to charge and discharge the gate capacitance during switching. Use a series resistor to limit this initial current while maintaining a fast transition time.

This resistor also decouples the MOSFET's gate-drain capacitance from the MCU I/O pin. This becomes significant when, for example, switching pulling-up loads through cables operating from a higher voltage than your MCU supply. When the MOSFET is turned on, this small charged capacitance produce a negative-going spike on your MCU I/O pin. I have seen this knock over MCUs and logic ICs in such applications. The series resistor prevents this.

The exact resistor value depends on the MOSFET you choose and its specific gate-to-source capacitance. A guide value is 330R, which limits the MCU I/O pin current to under 10 mA while achieving good switching at 38 kHz for typical low-current MOSFETs.

Update now PSMN022-30PL MOSFET added to question

The PSMN022-30PL is a good choice. Fig. 6 of its datasheet shows ID of 7.5 A with a Vgs of 3 V, a lower Vgs than your circuit will drive.

The ATmega328P datasheet Fig. 29-9 on p271 shows its I/O pin HIGH output current to be VDD-0.5 V worst case when IOH is 10 mA. IOH(max) is 20 mA so a 220R gate resistor would draw 11 mA at the same 2.5 V when the gate is discharged.

As the gate charges, the voltage across the series resistor falls and so does the drawn current. This means the gate voltage will approach something like VDD-0.15 V (stretching that graph's precision a bit) if there's sufficient mark time in the frequency cycle. It'll be a better case when discharging.

• I've updated my question with an updated circuit that uses a concrete Mosfet. I've also described my selection process. To limit the current at the gate I used 260 R instead of 330R since there is a voltage drop at the output pin when drawing 10 mA (according to the ATmega328p datasheet). Is this a valid design decision? The selected Mosfet has Q_G=4.4 nC - thus, I figured that it loads and thus switches in 0.4 µs, correct? Feb 14, 2022 at 0:09
• @maxschlepzig, I've updated my answer as per your question change. For the gate pull-down resistor, it's better to have that on the I/O pin, not the gate, to not create a potential divider (less important here but good practice in most MCU circuits). Look up the right figures but assuming I/O pin leakage of +/-10 uA max. leads to a 33K pull-down producing 0.33 V max on the gate and only 100 uA draw if I/O pin was 3.3 V. Feb 14, 2022 at 14:22
• Ok, I moved the pull-down resistor in the schematic. Jun 19, 2022 at 21:17

Use a FET in stead of the bipolar tranistor (2N2222) to get rid of the current to base causing power loss. Choose a FET with a low threshold voltage, so that it operates as a swich at 3.3 V.

Some LEDs are more efficient than other, you'll find the information on the datasheet. LED "efficiency" can also be effectively improved by shorter pulses or narrowing the beam and thus being able to transmit less power in total to get same power per area. Narrowing could be achieved with external optics or selecting a component that does it for you.

• Ok, I'll get a few LED variants with different 'angle of half intensity' specifications to see what works best in the target area. I'll also check what's the minimum duty cycle standard consumer IR receivers are comfortable with. Feb 12, 2022 at 22:59
• Regarding comparing the efficiency of LEDs - the value to compare is the radiant intensity (mW/sr) at a fixed forward current (when comparing different models with the same angle), correct? Feb 12, 2022 at 23:03

I strongly suggest you use an SOT-23 MOSFET such as AO3400 rather than some TO-220 behemoth that has huge stored charge. And Vgs(th) is not a good indication of Rds(on). It tells you when the MOSFET is barely on (0.25mA or something like that). You want it on thoroughly. Don't let the SMT package stop you, get a little breakout board and solder it down if you have to. They're cheap. You can drive it directly from the MCU. You will find sparse pickings in non-SMT packages for logic-level parts. There is little demand, whereas new and better parts are continually being introduced in SMT packages. You could easily drive 1A and run several LEDs in parallel (with individual series resistors).

Unfortunately, 3.3V is a bit low for this trick but if you had a 5V supply you could connect two LEDs in series and get double the light output with the same current.

• Well, I think nobody stated that Vgs(th) is a good indication of Rds(on). I just wrote that Vgs(th) needs to be lower than the targeted logic level, as a (trivial) necessary condition. Which might help with parametric searches. Those breakout boards for SOT-23 parts seem to be called 'sufboards' sometimes. Yes, this is an option. I hope it isn't to hard to solder on them. (for someone who has zero SMT soldering experience) Yes, the TO-220 parts feel a bit like overkill. Regarding stored charge: The AO3400 sheet specifies Q_g=6nC which is higher than the Q_g of the PSMN022-30PL TO-220 part. Feb 20, 2022 at 19:37
• Ok, re-posted my comment since I copy'n'pasted the wrong TO-220 part. I also updated my answer with a selection of SOT-23 parts. The main advantages in the extra available parts I can identify: 1) even lower total gate charge time 2) builtin ESD protection - however, I don't know if that is - perhaps - nice to have or absolutely superfluous, when switching an IRLED with an MCU ... Feb 20, 2022 at 19:41

First of all, your link to the datasheet is broken.

here is a good link

Second of all, you could probably consider N-channel MOSFET, if possible. It's not hard to find the one which works with 3.3V. "Logic level mosfets". It will make the system significantly more efficient eliminating base current and power losses in BJT. Consider MOSFET's gate threshold voltage and its RdsON resistance, since it will add to your current limiting resistor of LED.

• Ok, I've fixed the link (I copied it from some older notes). I'll try to find a suitable MOSFET then. Feb 12, 2022 at 22:52