Aziz Bench

2N2222A as a switch with Arduino and ESP32

A general-purpose NPN for loads up to a few hundred milliamps: relays, small motors, groups of LEDs. Saturation is guaranteed with a base current of one tenth of the load, so 300 mA needs 30 mA of base current, more than a microcontroller pin should give.

Transistor
2N2222A
NPN · TO-92 · onsemi (P2N2222A)
Max voltage
40 V
Max current
600 mA
VCE(sat)
0.3 V at 150 mA
TO-92 pinout
1C2B3E

From a 3.3 V or 5 V pin

PinVerdictWhyIn free air
ESP32 · 3.3 VWorks150 Ω on the base: up to 140 mA of load at a gain of 10140 mA (pin current)
Arduino Uno · 5 VWorks220 Ω on the base: up to 171 mA of load at a gain of 10171 mA (pin current)

In free air at 25 °C, with the junction 25 °C below its 150 °C maximum and θJA 200 °C/W, from a 20 mA pin at the datasheet’s forced gain, and no further than the highest current with a guaranteed saturation voltage.

Specifications

TypeNPN
PackageTO-92
Maximum voltage40 V
Maximum current600 mA
Minimum gain hFE100 at 150 mA · 40 at 500 mA
VCE(sat), maximum0.3 V at 150 mA (IC = 10 × IB) · 1 V at 500 mA (IC = 10 × IB)
VBE(sat), maximum1.2 V at 150 mA (IC = 10 × IB) · 2 V at 500 mA (IC = 10 × IB)
Thermal resistanceθJA 200 °C/W
Maximum junction temperature150 °C
Datasheet usedonsemi (P2N2222A)

Pinout

PinFunction
1Collector
2Base
3Emitter

Flat face toward you, leads down: pin 1 is on the left. This is the onsemi P2N2222A. Other 2N2222A and PN2222A in TO-92, and the metal-can 2N2222A, may use a different order: check the datasheet of the part you have.

Similar parts

PartPackageVCE(sat), guaranteedMax voltageMax current
2N2222ATO-921 V at 500 mA (IC = 10 × IB)40 V600 mA
2N3904TO-920.3 V at 50 mA (IC = 10 × IB)40 V200 mA
BC547TO-920.6 V at 100 mA (IC = 20 × IB)45 V100 mA
S8050SOT-230.6 V at 500 mA (IC = 10 × IB)25 V500 mA
TIP120TO-2204 V at 5 A (IC = 250 × IB)60 V5 A

Tips

The base resistor is sized for IC = 10 × IB, the condition of the datasheet’s saturation voltage. A higher gain from the hFE column would leave the transistor half on and hot.

Every coil needs a flyback diode across it, cathode to the positive supply. Without it the voltage spike at turn-off can destroy the transistor at the first switching.

Open the calculator →Check the 2N2222A with your own load, supply, PWM frequency and temperature.

Other transistors

Frequently asked questions

Does the 2N2222A work with a 3.3 V ESP32?

Yes, with a base resistor: at the gain of 10 the datasheet uses for saturation, a 20 mA pin drives the 2N2222A up to 140 mA of load. For more current use a logic-level MOSFET.

How much current can the 2N2222A switch without a heatsink?

About 171 mA from a 5 V Arduino pin, in free air at 25 °C, keeping the junction 25 °C below its 150 °C maximum (limit: pin current).

What is the 2N2222A pinout?

TO-92: 1 collector, 2 base, 3 emitter. Flat face toward you, leads down: pin 1 is on the left. This is the onsemi P2N2222A. Other 2N2222A and PN2222A in TO-92, and the metal-can 2N2222A, may use a different order: check the datasheet of the part you have.

Source of the figures: onsemi (P2N2222A) datasheet (PDF)