# 2N7000 N-Channel FET switch - resistor calculation for LEDs (design revision 2)

Follow up from a previous post about how to control a 5V supply to LEDs from a 3.3V logic GPIO on a Raspberry Pi Zero W.

Most responses recommended that I use a MOSFET / FET instead of a PN2222 transistor. I've done some research and this does indeed seem to be the better approach.

In reference to the data sheet for 2N7000 N-Channel Field Effect Transistor, there are a couple things I would like to clarify before wiring this up, to ensure I'm not going to cause smoke from over powering the FET:

1. Is this FET appropriate for the application? Fig 13 seems like I will be on the cusp of the safe operating area. The red line in the diagram is my understanding.

2. How do I calculate the resistor between the 3.3 V GPIO and the Gate? Or do I even need one?

3. Will the gate resistor impact the resistors on the LED strings?

I will also mention that I chose 2n7000 because it is available with pins. A surface mount won't work for my project.

Any other comments on my design are appreciated.

• You've drawn your circuit with a JFET, which 1) the 2N7000 is not and 2) won't work in this circuit anyway. Not that the 2N7000 will work either; 3.3 volts isn't enough to turn one of those on. Commented Oct 31, 2021 at 22:38
• @GTElectronics It's above the nominal threshold voltage, sure, but the threshold voltage is where the transistor only just barely begins to turn on. if you want any significant amount of current, you have to drive it a few volts above the threshold voltage; 5 V should be adequate, but 3.3 V is too low for it to be a circuit I'd sign off on. Commented Nov 1, 2021 at 3:54
• @Hearth. Right, I'll make the correction. Commented Nov 1, 2021 at 4:00
• FET needs turn on voltage Vgs_thn of usefully less than 3V3. Say 2V or less.. Commented Nov 1, 2021 at 7:52

You don't need any resistor at all at Rg. You can drive the gate directly from the processor. Provided the FET turns on well it won't affect the current through the LEDs or the LED resistor calculation significantly.

However, the 2N7000 is not the ideal device to drive from 3.3v. 3.3v may not be enough to drive it enough into conduction for your needs.

The gate threshold voltage worst case is 3V, but that is not the voltage for full conduction, that is only to pass 1mA. It really needs 5V to turn on well as can be seen from this datasheet graph:

You are misinterpreting the SOA plot. The voltage across the device should only be a few hundred millivolts while conducting and 80mA is no problem.

Actually, for this application, I would use a bipolar transistor (such as a PN2222). I would use a drive it with 5-10mA of bias current with (that would be good for a collector current of 80mA), for example, a 470-ohm resistor. The GPIO can easily drive that.

Why are you using so many LEDs?

If it is for pulse duty such as remote control the duty cycle is low and they can be driven at a higher current.

For continuous duty it looks like 20mA is the maximum.

Also in your calculation for the LED series resistor you have not taken into account the voltage drop of the 2N7000 (or PN2222). That will reduce the resistor value. Actually because of device variations, I would not recommend using more than 2 LEDs in series from a 5V supply. That will allow a higher value resistor with less variation due to the LED.

Datahseet

• Really? Won't a PN2222 pull more current from the GPIO pin? The reason for so many LEDs - these are IR LEDS that I'm using as a light source in a baby-monitor for my kids room. I want it far enough away from the cot they can't reach it. By my understanding, this is the maximum number of IR LEDs that I could safely drive from the 5V supply. I'm not sure I should go higher Voltage as the datasheet says 1.2 V. Commented Nov 1, 2021 at 8:02
• @ZachWork - With the resistor, I suggested it would require the GPIO to supply about 6mA. Commented Nov 1, 2021 at 14:29
1. When you turn the FET on, the Vds won't be 5V so fig. 13 does not apply. However, the FET can be considered not appropriate, as it barely turns on when driven with 3.3V gate voltage. Almost all diagrams indicate it needs more gate voltage.

2. Usually you don't need one for simple on/off control.

3. No, the gate resistor has nothing to do with LED resistors.

• This FET or any FET would not be appropriate? (I'm quite novice at this circuit design). On my previous post where I used an NPN Transistor, the responses suggested I use FET. Would this MOSFET be more appropriate? cdn-shop.adafruit.com/datasheets/irlb8721pbf.pdf Commented Nov 1, 2021 at 7:43
• @ZachWork This FET. And the new one, well look at the ratings what that FET can do with 3.3V at the gate. It might be better, and it might be barely adequate, however, that FET is also mostly rated at 4.5V at gate, which means it might not be any better than a BJT when 3.3V at gate. A proper FET is better than any BJT, but also a BJT could be good enough. Commented Nov 1, 2021 at 8:22

You have 4 strings in parallel so a total of 20mA * 4 = 80mA which isn't much at all so a PN2222 would handle that just fine, it can hold up to 600mA (given the temperature requirements are met).

It would need a base resistor however, this can be calculated (3.3v - 0.7v)/0.02 = 130 ohm. 150 ohm is a more common value.

You got the LED resistor calculations correct.

• You're using 20 mA of base current to drive an 80 mA load with a '2222; that's driving the transistor very far into saturation, further than necessary. I'd aim for more like 10 mA base current at the most. Commented Nov 1, 2021 at 3:34
• I'm more concerned about the maximum current capability of the GPIO pin. Benefits having less Vce and fairly below the maximum base current of the transistor. Would a more preservative base current benefit something in particular? Commented Nov 1, 2021 at 3:49
• It's always good to have less base current when you can, because the base current represents wasted energy; once the transistor is saturated, you get the same output regardless of base current. And even if a microcontroller can output 20 mA on a GPIO pin, that may pull the output voltage down significantly, and will contribute to package-wide limitations as well (the MCU may be able to drive 20 mA per pin, but no more than 100 mA total across all pins, for instance). Commented Nov 1, 2021 at 3:57
• @Hearth In a scenario where I use a PN2222 and reduce the base current to 10 mA as you said --- would the correct base resistor be calculated as (3.3 V - 0.7V) / 0.01mA = 260 ohm? I am also aware that the rule of thumb for base current calculator on a bjt used as a switch - base current = 10% of collector current. The latter would mean (3.3 V - 0.7V) / 0.008mA = 325 ohm Commented Nov 1, 2021 at 9:28
• @ZachWork Yes. You can even use an even lower current if you want, but 10% is a good rule of thumb; that'll definitely be saturated. Commented Nov 1, 2021 at 15:41