NPN transistor 2N2222
an electronic switch for bigger currents
A small electronic switch: a small current into the base switches on a much larger current through collector–emitter. That is how the ESP32 drives motors, relays and LED strips.
Open the course →How it works
When the GPIO gives 3.3 V, about 2.6 mA flows through the resistor (1 kΩ) into the base. The transistor amplifies ~100×, so up to ~260 mA and more may flow through the collector (when it is "saturated", i.e. fully on). With no base current, the collector–emitter path is open. The load (motor) goes between +5 V and the collector, the emitter to GND: this is a low-side switch.
Pins and wiring
| Pin | What it is | Where it connects / why |
|---|---|---|
| E (emitter) | Left leg (flat side facing you) | → GND. |
| B (base) | Middle leg | → GPIO through a 1 kΩ resistor. Without a resistor you destroy the pin! |
| C (collector) | Right leg | → to the load (motor −). |
Specifications
TypeNPN, TO-92
Max collector current600 mA (800 mA for 2N2222A)
Max C–E voltage40 V
Gain (hFE)~100
Drop when on~0.3 V
Tips and typical mistakes
- Different manufacturers use different leg orders (E-B-C or C-B-E). Check the datasheet!
- For currents above 500 mA use a MOSFET (e.g. IRLZ44N) — it runs cooler.