18 Transistor Selection
18.1 Start Simple
Switch One Real Load and Measure the Heat
A microcontroller means the small computer that runs the device program and connects to pins, sensors, and outputs.
Imagine a microcontroller pin trying to switch a motor, valve, or relay that needs far more current than the pin can supply. The transistor is the controlled switch between a small logic signal and a larger load path. Start with the load current, supply voltage, heat, switching speed, and the protection needed when the load turns off.
Test the chosen transistor with minimum drive, maximum load, rapid switching, a blocked load, and power removal. Keep board identity, microcontroller pin voltage, load current, transistor voltage, temperature, switching time, protection state, and failure result.
This bench test covers one part and load range, not every production condition. The deeper sections compare transistor families, ratings, drive, heat, protection, and release margin.
18.2 Learning Objectives
- Apply a systematic decision framework to choose between BJT and MOSFET transistors for a given IoT application
- Evaluate transistor specifications including voltage rating, current rating, power dissipation, and switching speed against project requirements
- Distinguish between logic-level and standard MOSFETs and explain why logic-level devices are required for 3.3V/5V microcontroller circuits
- Design a complete transistor switching circuit for a real-world IoT load, including flyback diode protection and proper gate drive
A transistor is like an electronic switch that lets a tiny signal from your microcontroller control a much bigger load, like a motor or a bright LED strip. There are two main types: BJTs (controlled by current, simpler for beginners) and MOSFETs (controlled by voltage, more efficient for most IoT projects). This guide helps you pick the right one for your project without getting lost in the thousands of options available.
18.3 Why This Chapter Matters
Follow these connections in order: This is one of the most practical chapters in the whole book because it answers a frequent real-world question: how do I let a small microcontroller pin control something bigger safely. Most beginner hardware damage happens when loads such as relays, motors, solenoids, and LED strips are connected as if GPIO pins were power supplies. After this chapter, a student should be able to choose a reasonable transistor strategy instead of copying circuits without knowing why they work.
18.4 How To Use This Chapter
- If you are a beginner, do not try to compare every transistor family at once. Start with the rule of thumb: logic-level N-channel MOSFETs solve most microcontroller load-switching problems.
- Use the decision table first, then the application recommendations, and only then the detailed criteria.
- Whenever a part number appears, connect it to a real task: relay driver, LED strip dimmer, motor switch, battery disconnect, or level shifter.
This chapter is a selection workflow, not a part-number catalog:
- First you choose the transistor family from the load and power budget.
- Then you check the common switching circuits and package trade-offs.
- Next you verify voltage, current, heat, speed, and logic-level gate drive.
- Finally you apply the rules to a garden valve, quizzes, and a bench design challenge.
Checkpoints recap the decision rules as you go, and anything titled “Deep dive” is optional on a first read.
18.5 Systematic Selection Process
18.5.1 Decision Framework: BJT vs MOSFET
Start with the family choice. The rest of the chapter only makes sense once you know whether you are paying for continuous base current or charging a MOSFET gate.
Start here to narrow down your choice between the two main transistor families:
| Question | Choose BJT | Choose MOSFET |
|---|---|---|
| What’s your power budget? | Mains powered, continuous operation OK | Battery powered, need ultra-low power |
| What current are you switching? | < 500mA (BJT adequate) | > 500mA or need low losses |
| What’s your control signal? | Have current available (>1mA) | Limited current (<100µA GPIO) |
| How often does it switch? | Infrequent (<1 kHz) | High frequency (>10 kHz) |
| What’s your experience level? | Beginner (BJT simpler biasing) | Intermediate (MOSFET gate drive trickier) |
Rule of Thumb: For modern IoT projects, MOSFET is usually the better choice due to voltage control (no base current drain), lower power losses (lower Rds(on)), and faster switching.
Consider switching a 2A DC motor with both BJT and MOSFET options. A power NPN BJT (TIP31C, rated for 3A) has , giving power dissipation . The BJT also requires base current: at , the TIP31C has (minimum guaranteed at high current), so . This exceeds most GPIO limits, requiring a driver stage. For simplicity, assume a base driver provides adequate current. From a 5V driver: .
A logic-level N-channel MOSFET (IRLZ44N) has (max) at . Power dissipation: . Gate current is essentially zero (<1µA). Total MOSFET losses: 0.112W vs. BJT losses: 1.344W (1W conduction + 344mW base drive) — the MOSFET is 12x more efficient. For battery-powered IoT nodes operating 24/7, this translates to months of extended battery life.
Checkpoint: Family Choice
You now know:
- Battery-powered IoT designs usually favor MOSFETs because the gate draws essentially zero steady current.
- A 2A load can push a TIP31C BJT into an 80mA base-current problem, while the IRLZ44N example dissipates 0.112W.
- The decision table is a filter: power budget, current, control signal, switching rate, and experience level all matter.
18.5.2 Transistor Switching Circuits for IoT
Once the transistor family is narrowed, choose where the switch sits in the load path. Low-side, high-side, H-bridge, and flyback protection solve different wiring problems.
The most common transistor configurations you’ll encounter in IoT hardware design:
Bring the visual evidence in Figure 18.1 into transistor switching circuits for iot. Its purpose is to reveal MOSFET Switching Circuits: Low-Side, High-Side, and H-Bridge Configurations before a design claim is accepted.
In Figure 18.1, MOSFET Switching Circuits for IoT establishes the first electrical role, while N-Channel MOSFET (80% of use cases) marks the contrasting role and Load supplies the operating detail. Those labels show MOSFET Switching Circuits: Low-Side, High-Side, and H-Bridge Configurations. This connects the visual to transistor switching circuits for iot by making the relevant component behaviour part of the design check.
Key Insights:
| Circuit Type | When to Use | Advantages | Critical Design Note |
|---|---|---|---|
| Low-Side N-MOSFET | Motors, relays, LEDs, most loads | Simplest, cheapest, direct GPIO control | Load not at ground potential (affects sensors) |
| High-Side P-MOSFET | Battery disconnect, sensor power, reverse polarity protection | Load at ground, true power-off | Inverted logic (LOW=ON), higher Rds(on) |
| H-Bridge | DC motors needing reversing, bidirectional control | Forward/reverse/brake/coast modes | Must implement dead-time (1-5µs), risk of shoot-through |
| Flyback Diode | ALL inductive loads (relays, solenoids, motors) | Protects transistor from voltage spikes (>300V) | Cathode to VCC, anode to GND side of load |
Inspect Figure 18.2 with Diode and Load Out in mind. Look at how it presents nPN BJT as a switch: Complete relay driver circuit with flyback diode protection and input/output timing diagrams before applying transistor switching circuits for iot.
Read Figure 18.2 as a protected switching path. NPN BJT Switch Circuit names the low-side device, Load Out shows the controlled relay node, and Diode spans the inductive load to carry current when the transistor turns off. The timing traces then connect the input command to the delayed load response. This is why transistor selection includes base drive, collector current, and flyback energy rather than only the load’s steady-state current.
Why examine Figure 18.3 here? It exposes n-channel FET as a switch: Lamp driver circuit with gate resistors and input/output timing diagrams, the visual distinction needed for transistor switching circuits for iot.
At the left of Figure 18.3, FET as a Switch Circuit establishes the low-side topology; the Lamp is the load whose current bypasses the logic input. The Flywheel path matters for an inductive load even though the pictured lamp itself is resistive. Relating those labels to the input and output traces shows why the MOSFET gate network, load supply, and transient protection must be specified as one switching circuit.
18.5.3 IoT Transistor Recommendations
Based on real-world IoT projects, here are proven transistor choices for common scenarios:
| Application | Recommended Transistor | Specs | Why This One? | Alternative |
|---|---|---|---|---|
| LED indicator (20mA) | 2N2222 (NPN BJT) | 40V, 600mA, β=100-300 | Cheap ($0.05), easy to bias, overkill specs | BC547 (smaller package) |
| Relay control (50mA coil) | 2N3904 (NPN BJT) or 2N7000 (N-MOSFET) | BJT: 40V, 200mA MOSFET: 60V, 200mA | Both work well, MOSFET uses less power | BC337 for higher current |
| High-power LED (350mA) | IRLZ44N (N-MOSFET) | 55V, 47A, Rds(on)=28mΩ max @ Vgs=5V | Logic-level (works with 3.3V/5V GPIO), low losses | FQP30N06L (cheaper) |
| Motor control (1-3A) | IRLZ44N (logic-level) or IRF540N (N-MOSFET) | IRLZ44N: 55V, 47A, Rds(on)=28mΩ @ 5V IRF540N: 100V, 33A, Rds(on)=44mΩ @ 10V | IRLZ44N for 3.3V/5V GPIO; IRF540N needs 10V gate driver | IRL540N (logic-level, 100V) |
| Solenoid valve (500mA) | TIP120 (Darlington NPN) or FQP30N06L (N-MOSFET) | Darlington: 60V, 5A, β=1000 MOSFET: 60V, 32A | Darlington simplest, MOSFET more efficient | TIP122 (100V higher voltage) |
| High-side switching (12V+) | IRF9540 (P-channel MOSFET) | -100V, -23A, Rds(on)=117mΩ @ Vgs=-10V | Standard gate: needs Vgs=-10V, use with gate driver or >10V supply | FQP27P06 (lower Rds(on)) |
| Load switching (ultra-low power) | AO3401 (P-channel SOT-23) | 30V, 4A, Rds(on)=35mΩ, leak<1µA | SMD compact, near-zero leakage for battery | Si2333DS (even lower leak) |
| H-bridge motor driver | 4x IRLZ44N with gate drivers (or 2x P-channel high + 2x N-channel low) | 55V, 47A, Rds(on)=28mΩ max @ 5V | Logic-level, handles high current, low losses; N-channel high-side requires bootstrap driver | L298N module (integrated, no external gate drivers needed) |
| 5V→3.3V level shifter | BSS138 (N-channel SOT-23) | 50V, 200mA, Rds(on)=3.5Ω | Standard for bidirectional I2C/SPI shifting | 2N7000 (through-hole version) |
| Signal amplifier (audio) | 2N3904 (NPN) + 2N3906 (PNP) | Complementary pair for push-pull | Low noise, good for small-signal amplification | BC547/BC557 pair |
SMD vs Through-Hole Trade-Offs:
- Through-hole (TO-92, TO-220): Easier for beginners, hand-solderable, good heat dissipation (TO-220 with heatsink)
- SMD (SOT-23, SOT-223, DPAK): Compact for production, cheaper in volume, harder to solder by hand
A reliable iot transistor recommendations starts by viewing Figure 18.4; it identifies a small-signal transistor in the through-hole TO-92 package — the same footprint as the 2N2222, 2N3904, and BC547 parts in the recommendation table above. The three leads (here, base, collector, emitter) hand-solder easily, but the plastic body caps power dissipation around 0.4-0.5W, which is exactly the thermal limit worked through in the checkpoint below. Photo: Mister rf, CC BY-SA 4.0 for the calculation or selection that follows.
At A small-signal transistor in the through-hole TO-92 package — the same footprint, Figure 18.4 states one side of the design; 2N3904 introduces the next state or component, and base names the consequence. The visual shows a small-signal transistor in the through-hole TO-92 package — the same footprint as the 2N2222, 2N3904, and BC547 parts in the recommendation table above. The three leads (here, base, collector, emitter) hand-solder easily, but the plastic body caps power dissipation around 0.4-0.5W, which is exactly the thermal limit worked through in the checkpoint below. Photo: Mister rf, CC BY-SA 4.0. The running iot transistor recommendations narrative uses that consequence to decide what is safe and measurable.
18.5.4 Detailed Selection Criteria
The recommendation table gives a starting part. The detailed criteria below are the safety checks that decide whether that part survives in the actual product.
When the simple recommendation table doesn’t fit your needs, use these detailed criteria:
What to check: Maximum voltage between collector-emitter (BJT) or drain-source (MOSFET)
Selection rule: Choose transistor with voltage rating ≥ 2× your supply voltage for safety margin
Examples:
- 5V circuit → ≥10V transistor (2N2222: 40V, OK)
- 12V motor → ≥24V transistor (IRF540N: 100V, OK)
- 24V industrial → ≥50V transistor (TIP120: 60V, OK)
Common mistake: Using 2N7000 (60V) for 48V system → fails (need 100V+ transistor)
What to check: Maximum continuous collector (BJT) or drain current (MOSFET)
Selection rule: Choose transistor with current rating ≥ 2-3× your load current for thermal safety
Examples:
- 100mA LED → ≥200mA transistor (2N3904: 200mA, OK)
- 1A motor → ≥2A transistor (IRF540N: 33A, huge safety margin)
- 10A heater → ≥20A transistor (IRFB3207: 180A, OK)
Thermal derating: At 25°C use full rating, at 85°C derate to 50-70% of rating
Common mistake: “2A motor needs 2A transistor” → overheats (motor stall current may be 5A!)
What to check: Maximum power transistor can dissipate as heat
Calculation:
- BJT: P = V_CE(sat) × I_C (saturation) or P = V_CE × I_C (active mode)
- MOSFET: P = I_D² × Rds(on) (when ON) or P = V_DS × I_D (switching losses)
Selection rule: Ensure P_dissipation < P_D rating (with heatsink if needed)
Examples:
| Switch Type | Key Calculation | Package Limit | Decision |
|---|---|---|---|
| MOSFET switching 2A at 12V | Rds(on) = 100mΩ, so P = (2A)² × 0.1Ω = 0.4W | TO-220: about 1W without heatsink | OK without heatsink |
| BJT switching 2A at 12V | V_CE(sat) = 0.5V, so P = 0.5V × 2A = 1W | TO-92: about 0.5W max | Needs heatsink or larger package |
Why MOSFETs win: Lower on-resistance → less heat → longer life, smaller package
18.5.5 MOSFET vs BJT Power Calculator
Adjust the sliders to compare power losses for your specific load current and transistor parameters.
What to check: How fast can the transistor switch on/off?
Selection rule: For PWM/switching applications, choose transistor with f_T ≥ 10× your PWM frequency
Examples:
- 1 kHz PWM (motor speed control) → f_T ≥ 10 kHz (most transistors OK)
- 20 kHz PWM (LED dimming, avoid audible whine) → f_T ≥ 200 kHz (2N2222: 300 MHz, OK)
- 100 kHz switching (buck converter) → f_T ≥ 1 MHz (specialized switching FETs)
Switching losses: At high frequencies, switching losses dominate. Use MOSFETs with low gate charge (Q_g) for efficiency.
Common mistake: Using slow Darlington (TIP120) for 20 kHz PWM → overheating, poor efficiency
Critical MOSFET selection criterion often overlooked by beginners!
Standard MOSFETs:
- Need V_GS = 10-12V to achieve the specified low Rds(on)
- IRF540N datasheet: Rds(on) = 44mΩ @ V_GS = 10V
- With 5V gate drive: Rds(on) = ~200mΩ (4.5× higher → 4.5× more heat!)
Logic-Level MOSFETs:
- Specified for low Rds(on) at V_GS = 4.5-5V; for 3.3V GPIO, prefer parts with Rds(on) specified at 2.5-3.3V
- IRLZ44N datasheet: Rds(on) = 28mΩ max @ V_GS = 5V (OK for 5V gate drive; check curves before relying on 3.3V)
- Note the “L” in IRLZ44N → Logic-level
Selection rule:
- 3.3V/5V microcontroller: MUST use a logic-level MOSFET, and must verify Rds(on) at the gate voltage you can actually provide; V_GS(th) alone is not enough
- 12V+ gate driver: Can use standard MOSFET (often cheaper, lower Rds(on))
Common beginner mistake: “My IRF540N gets really hot even though it’s rated for 33A and I’m only switching 2A” → Using standard MOSFET with 5V gate drive! Solution: Replace with IRLZ44N (logic-level version)
Checkpoint: Ratings and Gate Drive
You now know:
- Voltage rating should be at least 2x the supply, and current rating should be about 2-3x the load current.
- Power loss has to fit the package: a TO-92 example can fail near 0.15W at 60 deg-C, while MOSFET loss uses I^2 x Rds(on).
- For 3.3V or 5V GPIO, “logic-level” means checking Rds(on) at the gate voltage you can actually provide.
18.5.6 Garden Irrigation Transistor
Now apply the checklist to a real actuator. The valve example ties together load current, flyback protection, GPIO limits, outdoor temperature, and battery life.
Requirements:
- Control 12V solenoid valve (opening/closing water flow)
- Solenoid coil: 12V, 50mA nominal, 200mA inrush current
- Controlled by ESP32 GPIO (3.3V, 12mA max)
- Battery powered (need low quiescent current)
- Outdoor deployment (temperature: -10°C to +60°C)
Decision Process:
Step 1: BJT or MOSFET?
- Battery powered → prefer MOSFET (zero gate current)
- Load: 200mA → either works, but MOSFET more efficient
- Choice: MOSFET
Step 2: Voltage rating?
- Solenoid: 12V → need ≥24V rating for safety (2x rule)
- With flyback diode, inductive spikes are clamped to ~12.7V
- Requirement: V_DS ≥ 24V (flyback diode limits spike voltage)
Step 3: Current rating?
- Load: 200mA inrush → need ≥400mA continuous rating
- Requirement: I_D ≥ 400mA (most MOSFETs exceed this)
Step 4: Logic-level or standard?
- ESP32 GPIO: 3.3V → MUST be logic-level
- Need logic-level behavior and low Rds(on) at the available gate drive; for ESP32, prefer datasheet data at 2.5-3.3V or a dedicated gate driver
- Requirement: Logic-level MOSFET verified at the actual GPIO voltage
Step 5: Package and thermal?
- P_dissipation = I² × Rds(on) = (0.2)² × 0.03Ω = 1.2mW
- Negligible heat → no heatsink needed
- Requirement: Any package (TO-92, SOT-23)
Final Selection: 2N7002 (N-channel MOSFET, SOT-23) or IRLML2502 for more margin
- V_DS: 60V (OK: safe for 12V + inductive spikes)
- I_D: 115mA continuous (2N7002, SOT-23 package limited; OK for 50mA nominal because the 200mA inrush is brief)
- V_GS(th): 1.0-2.5V typical (OK: reliably on at 3.3V)
- Package: SOT-23 (OK: compact, easy to solder)
- Cost: $0.05 (OK: very cheap)
- Rds(on): 2.0Ω @ V_GS=2.5V → P = (0.05A)^2 x 2.0 = 5mW nominal (OK: negligible losses)
Note: The popular 2N7000 (TO-92, 200mA) is also viable here since nominal current is only 50mA, but the 2N7002 offers better margin and a smaller footprint.
Additional Protection: Add 1N4007 flyback diode across solenoid coil (cathode to +12V, anode to drain) to protect MOSFET from inductive kickback when solenoid turns OFF.
Wiring map:
| Connection | Where It Goes | Why |
|---|---|---|
| ESP32 GPIO | 1kΩ series resistor, then MOSFET gate | Limits the brief gate-charging current |
| MOSFET source | GND | Completes the low-side switch path |
| MOSFET drain | Solenoid negative side | Lets the MOSFET pull the solenoid to ground when ON |
| Solenoid positive side | +12V supply | Provides load power |
| Flyback diode cathode | +12V side of solenoid | Blocks current during normal operation |
| Flyback diode anode | MOSFET drain side of solenoid | Safely recirculates coil current when the MOSFET turns OFF |
Why NOT alternatives:
- BJT (2N3904): Needs base current (~2mA), wastes battery power during sleep cycles
- IRF540N: Standard gate (not logic-level), won’t fully turn on with 3.3V
- Relay: 50mA coil current wasteful for battery, mechanical wear, slower
Scenario: You’re designing a remote irrigation valve controller powered by LoRaWAN. The 12V solenoid valve coil draws 300mA nominal, with 800mA inrush current when first energized. The system runs on 4× AA batteries (6V total) with a boost converter to 12V. The LoRa module (RFM95) GPIO output is 3.3V at 12mA max. Battery life target is 2 years with 10 valve actuations per day, each lasting 30 seconds.
Step-by-Step Selection Process:
1. BJT vs MOSFET Decision:
- Battery powered → prefer MOSFET (zero gate current)
- Switching load (not amplification) → MOSFET
- Choice: N-channel MOSFET
2. Voltage Rating Calculation:
- Supply voltage: 12V
- With flyback diode, voltage spikes are clamped to ~V_supply + V_diode_forward (~12.7V)
- Safety margin: 2× minimum for transient protection
- Requirement: V_DS ≥ 12V × 2 = 24V (with flyback diode protection)
- Selected rating: 55V (IRLZ44N, provides ample margin with flyback diode)
3. Current Rating Calculation:
- Peak inrush: 800mA
- Safety factor: 3× for inrush currents
- Requirement: I_D ≥ 800mA × 3 = 2.4A
- Selected rating: 3A continuous (standard rating above 2.4A)
4. Logic-Level Requirement:
- GPIO voltage: 3.3V
- Must be logic-level MOSFET with V_GS(th) < 2V
- Fully enhanced at V_GS = 3.3V
- Requirement: MUST specify logic-level in datasheet
5. Power Dissipation Check:
- Steady-state current: 300mA
- Worst-case Rds(on) at V_GS=3.3V: Need from datasheet
- Example candidate: IRLZ44N has Rds(on) = 28mΩ @ V_GS=4.5V, approximately 35mΩ @ 3.3V
- Power dissipation: P = I² × R = (0.3A)² × 0.035Ω = 3.15mW
- TO-220 package without heatsink: 1W max
- Verdict: No heatsink needed (3.15mW << 1W)
6. Battery Life Impact:
- Active time per day: 10 actuations x 30 sec = 300 seconds = 0.0833 hours
- MOSFET power loss per day: 3.15mW x 0.0833h = 0.263 mWh/day
- Over 2 years (730 days): 0.263 x 730 = 192 mWh = 0.192 Wh
- At 6V: 0.192 Wh / 6V = 32 mAh consumed by MOSFET losses over 2 years
- AA batteries in series: 2,500 mAh capacity (series does not multiply mAh)
- MOSFET represents: 32 / 2,500 = 1.28% of total battery capacity
- Verdict: Negligible impact on battery life
Final Component Selection:
- Transistor: IRLZ44N (N-channel logic-level MOSFET)
- Specs: 55V V_DS (ample margin with flyback diode clamping spikes to ~12.7V), 47A I_D, 28mΩ Rds(on) max @ 5V, TO-220 package
- Cost: ~$0.80 in single quantities, $0.35 in 100+ quantities
- Flyback diode: 1N4007 (1000V, 1A) across valve coil — essential for clamping inductive voltage spikes
- Gate resistor: 10kΩ pull-down from gate to ground (keeps MOSFET OFF when RFM95 is sleeping)
- Gate series resistor: 100Ω between GPIO and gate (limits current spikes)
Wiring map:
| Connection | Where It Goes | Why |
|---|---|---|
| RFM95 GPIO (3.3V) | 100Ω series resistor, then IRLZ44N gate | Controls the valve while limiting gate current spikes |
| Gate pull-down | 10kΩ from gate to GND | Keeps the valve OFF while the radio module boots or sleeps |
| IRLZ44N source | GND | Low-side switching reference |
| IRLZ44N drain | Solenoid valve negative side | MOSFET switches the valve current |
| Solenoid valve positive side | +12V supply | Provides valve power |
| 1N4007 flyback diode | Cathode to +12V, anode to MOSFET drain | Protects the MOSFET from inductive kickback |
Key Lessons:
- Inductive loads always need flyback diodes - without it, inductive kickback can generate 300V+ spikes destroying the MOSFET
- Logic-level is non-negotiable for 3.3V systems - standard MOSFETs won’t fully turn on, causing excessive heat
- Check Rds(on) at YOUR gate voltage - datasheets often spec at 10V, but you’re using 3.3V
- Pull-down resistors prevent float-induced turn-on - critical for systems with sleep modes
- Power dissipation is usually negligible - the 3.15mW loss is only 0.088% of the 3.6W valve power (12V x 300mA)
Real-World Validation: After deployment, measure the MOSFET temperature rise. With 3mW dissipation, temperature rise will be approximately:
- Thermal resistance junction-to-ambient (TO-220, no heatsink): ~62°C/W
- Temperature rise: 3mW × 62°C/W = 0.19°C
- Essentially unmeasurable - confirms calculations were correct
Checkpoint: Applied Valve Design
You now know:
- A 12V solenoid needs flyback protection, and the 2x voltage-rating rule turns that into at least a 24V transistor check.
- The valve example separates 200mA inrush from 50mA nominal current, then verifies logic-level drive from a 3.3V ESP32 GPIO.
- In the LoRaWAN valve case, MOSFET loss is small: 3.15mW, about 31.94mAh over 730 days, or 1.28% of the AA string capacity.
18.7 Chapter Summary
The worked examples have done the arithmetic; the summary turns those checks into a reusable field procedure.
Transistor selection for IoT follows a systematic process: start with the BJT vs MOSFET decision (MOSFETs win for most battery-powered applications due to zero gate current and lower conduction losses), then verify four critical specifications against your requirements.
The four key selection criteria are: (1) voltage rating at least 2x your supply voltage to handle transients, (2) current rating at least 2-3x your load current for thermal margin, (3) power dissipation within the package limits (P = I^2 x Rds(on) for MOSFETs, P = Vce(sat) x Ic for BJTs), and (4) logic-level gate compatibility if driven directly from a 3.3V or 5V microcontroller GPIO.
Logic-level MOSFETs are essential for microcontroller-driven circuits. Standard MOSFETs require Vgs = 10V to achieve their rated Rds(on), leading to excessive heating when driven from 3.3V/5V GPIOs. Always check Rds(on) at your actual gate voltage in the datasheet, not the headline specification.
Protection circuits are non-negotiable for inductive loads: flyback diodes across relay coils, solenoids, and motors prevent destructive voltage spikes when the transistor switches off. Gate pull-down resistors keep MOSFETs off during microcontroller reset or sleep states.
The Sensor Squad goes shopping for the perfect transistor!
the microcontroller had a mission: he needed to control a small water valve for a smart garden. “But I can only push with 3.3 volts and 12 milliamps,” Max said. “The valve needs 12 volts and 100 milliamps! I need a transistor helper.”
The Sensor Squad went to the Electronics Store, where they found LOTS of transistors. “There are two main types,” explained Temperature Terry. “BJTs and MOSFETs.”
“A BJT is like a faucet,” said the LED. “You have to keep pushing the handle (sending current to the base) to keep it open. If you let go, it closes.” “A MOSFET is like a light switch,” added the battery. “You just flip it (send voltage to the gate) and it stays on without you pushing. Much better for saving my energy!”
Max picked up a MOSFET called the 2N7000. “Let’s check if this one works for us. Voltage rating: 60V — our valve is 12V, so we have plenty of safety margin. Current rating: 200mA — that’s double what our valve needs, giving us a safety margin. And it’s logic-level, which means my 3.3 volt signal can turn it on. Perfect!”
“Don’t forget the flyback diode!” warned Sammy. “The valve has a coil inside that stores energy in a magnetic field. When Max turns it off, that energy has to go somewhere, and it creates a huge voltage spike that could destroy the transistor!” They added a 1N4007 diode across the valve to protect everything.
“So choosing a transistor is like choosing the right tool for the job,” concluded Max. “Check the voltage, check the current, make sure it works with your signal level, and always add protection for valves and motors!”
18.7.1 Key Words for Kids
| Word | What It Means |
|---|---|
| MOSFET | A type of transistor that works like a light switch (voltage controlled) |
| BJT | A type of transistor that works like a faucet (current controlled) |
| Logic-Level | A MOSFET that can be turned on by a microcontroller’s small voltage |
| Flyback Diode | A protector that absorbs voltage spikes from motors and pumps |
| Voltage Rating | The maximum voltage a transistor can handle safely |
| Current Rating | The maximum current a transistor can carry safely |
18.8 MOSFET Gate Drive Basics
The earlier sections treat gate drive as a selection rule. This optional section explains the device behavior behind that rule.
The big picture: A MOSFET acts as a voltage-controlled switch where applying voltage to the gate terminal creates a conductive channel between drain and source, allowing current to flow with very low resistance (typically 0.01-0.1Ω for power MOSFETs).
Step-by-step breakdown:
-
OFF State (Vgs = 0V): No gate voltage applied, P-type body region blocks current flow between N-type drain and source with >1MΩ resistance, leakage current <1µA - Real example: IRLZ44N with 12V across drain-source passes only 0.25µA when gate is grounded
-
Threshold (Vgs = 2V): Gate voltage reaches threshold, creating thin conductive channel of electrons at oxide interface, resistance drops to ~10Ω, enabling milliamp-level currents - Real example: At Vgs = 2V, IRLZ44N conducts 100mA with 1V drop across channel
-
Fully Enhanced (Vgs = 5V): Strong gate electric field inverts surface from P-type to N-type, forming wide low-resistance channel (~50nm deep), Rds(on) = 0.028 ohm max enabling 47A rating - Real example: At Vgs = 5V, IRLZ44N passes 10A with only 0.28V drop, dissipating 2.8W heat
Why this matters: Gate threshold voltage (Vgs(th)) determines microcontroller compatibility. Standard MOSFETs need 10V, logic-level MOSFETs work with 3.3-5V GPIO. Using wrong type causes partial turn-on, high resistance, and excessive heating.
18.9 Concept Check: MOSFET Selection
Test your transistor selection skills:
18.10 Concept Relationships
Transistor selection connects throughout IoT hardware design:
| Related Concept | Chapter Link | Relationship |
|---|---|---|
| Component Basics | Conductors and Insulators | Transistors are active components controlling current |
| Semiconductor Physics | Doping and Diodes | MOSFETs built from PN junction layers |
| Motor Control | DC Motor Drivers | H-bridge uses 4 MOSFETs for bidirectional control |
| Power Efficiency | Energy Optimization | Low Rds(on) MOSFETs reduce switching losses |
18.11 Try It Yourself
After the quizzes, turn the rules back into a circuit. This relay exercise checks whether you can choose the part, size the resistor, and place the diode without copying blindly.
Challenge: Design a Load Switching Circuit
Objective: Select proper transistor, calculate component values, and draw complete circuit for microcontroller-controlled relay.
Specification:
- Relay coil: 5V, 70mA, 100Ω coil resistance
- Microcontroller: Arduino Uno (5V GPIO, 40mA max)
- Requirement: Simple, low-cost circuit
Steps:
- Choose transistor type: BJT vs MOSFET? (70mA suggests BJT acceptable)
- Calculate current: 70mA coil needs what transistor rating? (2× safety = 140mA minimum)
- Calculate base resistor for BJT OR gate resistor for MOSFET
- Add flyback diode protection (inductive load!)
- Draw complete circuit with all component values
Solution:
| Item | Selection | Reason |
|---|---|---|
| Transistor | 2N2222 NPN BJT | 40V, 600mA rating gives comfortable margin for a 70mA relay coil |
| Base resistor | 4.7kΩ from Arduino Pin 9 to base | Gives about 0.91mA base current, enough overdrive for reliable saturation |
| Flyback diode | 1N4007 across relay coil | Cathode/stripe to +5V, anode to transistor collector |
Wiring map:
| Arduino / Component Node | Connects To |
|---|---|
| Arduino Pin 9 | 4.7kΩ resistor, then 2N2222 base |
| 2N2222 collector | Relay coil negative side |
| Relay coil positive side | +5V supply |
| 2N2222 emitter | GND |
| 1N4007 diode | Across the relay coil, stripe/cathode to +5V |
Expected Observation: Relay clicks ON when GPIO HIGH, OFF when LOW. MOSFET alternative (2N7000) would use 10k-ohm pull-down + 100-ohm gate resistor instead, drawing <1uA vs BJT’s 0.9mA base current.
18.11.1 BJT Base Resistor Calculator
Use this calculator to find the base resistor value for any BJT switching circuit.
18.12 See Also
Transistor Applications:
Follow these connections in order: Motor Control Circuits - H-bridge design with MOSFETs; LED Drivers - Constant current and PWM dimming; Relay Interface - Isolating high-voltage loads.
Advanced Topics:
Follow these connections in order: Gate Drive Circuits - Bootstrap and isolated drivers; Thermal Management - Heatsink sizing calculations; PCB Layout - Minimize switching losses; GPIO Output Stage Contracts - Deep dive into push-pull versus open-drain outputs, shared bus lines, and contention risks.
18.13 Continue: GPIO Output Stage Contracts
The main chapter above stays focused on selecting BJTs, MOSFETs, ratings, gate drive, heat, and protection for IoT loads. For the deeper design contract behind push-pull versus open-drain outputs, pull-up-defined HIGH levels, shared I2C-style lines, and bus-contention failure modes, continue to GPIO Output Stage Contracts.
18.14 What’s Next?
| Next Chapter | Description |
|---|---|
| Electronics Summary and Resources | Consolidates key concepts, common pitfalls checklist, and visual reference galleries for the entire Electronics module |
Recommended reading sequence:
| Topic | Chapter |
|---|---|
| Component fundamentals | Conductors and Insulators |
| Semiconductor physics | Doping and Diodes |
| Transistor selection (this chapter) | Transistor Selection Guide |
| Module wrap-up | Electronics Summary and Resources |
18.15 Key Takeaway
Choose the transistor from the load backward. Current, voltage, switching speed, high-side or low-side placement, GPIO drive level, heat, and protection needs determine whether a BJT, logic-level MOSFET, or driver IC is appropriate.
