Skip to main content

Transistors

Using NPN transistors and Darlington pairs as GPIO-driven switches for higher-power loads in cockpit builds.

Why Transistors in a Cockpit Build?

An ESP32 GPIO pin can safely source or sink around 12 mA (absolute maximum 40 mA). That is enough for a single indicator LED with a series resistor, but not for:

LED strips or multi-LED annunciator banks (combined current easily exceeds 100 mA)
Buzzers or piezo alarms (50–200 mA)
Relay coils (50–150 mA)
Small motors or solenoid valves

An NPN transistor acts as an electrically controlled switch: a tiny base current from the GPIO (limited by a resistor) allows a much larger collector-to-emitter current to flow. The load runs from a separate power rail — the GPIO only provides the control signal.

NPN Low-Side Switch — Wiring

The transistor sits on the low side of the load (between load and GND). The load connects from the positive supply rail to the collector; the emitter goes to GND. When the GPIO is HIGH the base current turns the transistor on and current flows through the load.

+5 V / +12 V LOAD C GND B 1 kΩ GPIO E 1N4007 (inductive loads)

Base Resistor Calculation

The base resistor limits the current into the base so the GPIO is not overloaded:

RB = (VGPIO − VBE) ÷ IB   where   IB = IC ÷ hFE

ParameterTypical valueNotes
VGPIO3.3 VESP32 logic high
VBE0.6–0.7 VBase-emitter drop, silicon NPN
hFE100–300Current gain; see datasheet
ICyour load currentE.g. 200 mA for relay coil

Practical shortcut: a 1 kΩ base resistor works for almost every small NPN transistor (2N2222, BC547, BC337) driven from 3.3 V GPIO. It gives ~2.6 mA base current, which saturates transistors with hFE ≥ 100 for collector currents up to ~260 mA. Use a 10 kΩ resistor if the load is light (< 50 mA) to save power.

Transistors for Cockpit Builds
PartIC maxhFEPackageBest used for
2N2222 / PN2222600 mA100–300TO-92Single LEDs, small buzzers, signal switching
BC547100 mA110–800TO-92Annunciator LEDs, low-current relay drives
BC337800 mA100–630TO-92LED banks, relay coils, small buzzers
TIP120 (Darlington)5 A1 000+TO-220Large LED arrays, motor control, solenoids
IRLZ44N (N-MOSFET)47 A— (FET)TO-220High-power LED strips, motors — gate driven directly from 3.3 V
Darlington Pairs — Extra Gain for Heavy Loads

A Darlington pair cascades two NPN transistors so the emitter of Q1 drives the base of Q2. The combined current gain is the product of both transistors — allowing a tiny base current to switch several amperes. The TIP120 integrates this pair in a single TO-220 package.

GPIO → 1 kΩ → B1 → [NPN Q1] → C2 → [NPN Q2] → LOAD → +V E1 → B2 (direct) E2 → GND Result: combined h_FE = h_FE1 × h_FE2 (e.g. 100×100 = 10 000) TIP120 integrates this pair — rated to 5 A, driven by a single 1 kΩ base resistor
LoadTypical currentRecommended transistor
Single annunciator LED5–20 mABC547 or 2N2222 (or just a resistor, no transistor needed)
4–8 LED annunciator bank40–160 mABC337 or 2N2222
5 V relay coil50–100 mABC337 + 1N4007 flyback diode
12 V relay coil50–150 mABC337 or TIP120 + 1N4007
LED strip (30 LEDs)500 mA – 1 ATIP120 or IRLZ44N
Small DC motor / solenoid1–3 ATIP120 or IRLZ44N + flyback diode
Cockpit Wiring Examples

Overhead Panel Annunciator Bank

An overhead panel typically has dozens of amber/red annunciator lights grouped by system. Rather than running a GPIO wire to each LED, group them by system and switch the whole group with one BC337 per group. Wire each LED in the group in series with its own 68–100 Ω resistor so a single failed LED does not short the others.

Relay-Driven External Power

When a cockpit subsystem (instrument lighting dimmer, panel fan) needs to be toggled from the simulator, a 5 V relay driven by a BC337 is the safest approach. The relay isolates the ESP32 GPIO from the mains-side or high-voltage circuit entirely. Always add a 1N4007 across the relay coil with the cathode towards the positive rail.

LED Backlighting Strip

Panel backlighting (white or amber LED strips behind MDF panels) typically draws 500 mA or more. Use an IRLZ44N MOSFET: gate through a 100 Ω resistor to the ESP32 GPIO, drain to the LED strip negative terminal, source to GND. Add a 10 kΩ pull-down between gate and source so the strip stays off at power-on before the firmware runs.

Pin Identification

TO-92 transistors (2N2222, BC547, BC337) have three legs. With the flat face towards you and legs pointing down, the pin order differs by manufacturer — always check the datasheet or package markings. The most common orderings for NPN are:

TransistorLeftCentreRight (flat face towards you)
2N2222 (Fairchild/ON)EmitterBaseCollector
BC547 / BC337CollectorBaseEmitter