Transistor Sizing for Relay Coils: Base Resistor, Saturation, and the Flyback Loop in One Working Sheet
Transistor sizing for relay coils: use official IC, hFE, and saturation limits, calculate the base resistor from those, and close the flyback loop.

A 200 mA relay coil can still overstress a transistor that looks correctly sized on a quick worksheet. On the official Good-Ark MMBT3904 datasheet (Doc. No. 643141), continuous collector current is 200 mA and collector dissipation is 200 mW, both at 25 °C, in a SOT-23 body. The same file does not give a DC current gain or a collector-emitter saturation voltage at 200 mA, and the official 1N4148W datasheet lists only 150 mA of average rectified current. If the coil current, the gain used to size the base resistor, and the flyback diode all came from typical values instead of those official rows, the first failure is often a hot transistor or a missing flyback path, not a mysterious coil.
(Last modified date: November 17, 2026)
Transistor sizing for relay coils is a five-line worksheet: the coil current, including pull-in inrush from the relay datasheet; a saturation check against the official VCE(sat) test current, not a typical hFE; a base resistor calculated from that base current and the official VBE(sat); a flyback path whose official current rating covers the coil; and margin for temperature and tolerance. A purchasing check uses the same official rows. A landing-page “Hfe” figure is not a substitute for the current at which that gain was measured.

How to calculate a base resistor for a relay-coil transistor
Size the base resistor from the official saturation test, then confirm that the transistor’s official current and gain still cover the coil. For an NPN low-side switch, the useful starting point is the datasheet condition that actually guarantees VCE(sat), which is a forced base current, not a typical hFE of 100.
The official BC817-40 file (BC817-16-25-40, Doc. No. 643141) makes that difference visible. Continuous collector current is 500 mA, collector dissipation is 300 mW, VCEO is 45 V, and RθJA is 417 °C/W, all at 25 °C unless noted. VCE(sat) is 0.70 V maximum and VBE(sat) is 1.20 V maximum, both at IC = 500 mA and IB = 50 mA. That saturation row is a forced gain of 10, not the classification range of 250 to 600 listed for BC817-40 (marking 6C). A separate minimum hFE of 40 is given at VCE = 1 V and IC = 500 mA. The gain range tells you the transistor can supply current; the VCE(sat) row tells you how hard to drive the base if you want the specified saturation voltage.
Work a 200 mA steady coil, 5 V logic, with those official BC817-40 rows, and keep the same forced gain of 10 used in the saturation test:
- Write the collector current from the relay datasheet, including pull-in inrush, and compare it with official IC. For BC817-40, 200 mA steady is inside the 500 mA continuous rating. A part whose official continuous IC equals the coil current, with no inrush margin, fails this line before any resistor is calculated.
- Set the base current from the official saturation condition, not from typical hFE. Using the same forced gain of 10: IB = 200 mA / 10 = 20 mA. Check that this is still compatible with the official minimum hFE: at 500 mA the minimum is 40, so a forced gain of 10 is more base current than the minimum-gain figure alone would suggest, which is the point of the saturation row.
- Calculate the base resistor from official VBE(sat). The file specifies 1.20 V maximum only at 500 mA / 50 mA; a 200 mA VBE(sat) is not listed, so the official 1.20 V maximum is the conservative value available from that table. RB = (5 V − 1.20 V) / 20 mA = 190 Ω. A 180 Ω standard value supplies a little more base current. Resistor dissipation is IB2R ≈ 72 mW at 180 Ω, which still has to be checked against the resistor’s rating.
- Repeat the same arithmetic on a 24 V logic rail: RB = (24 V − 1.20 V) / 20 mA = 1.14 kΩ, for example a 1.1 kΩ standard value. The resistor now dissipates about 0.44 W at 20 mA, so the wattage rating is part of the worksheet, not an afterthought. That extra dissipation is often the purchasing signal to look at a logic-level MOSFET instead of a larger base resistor.
- Close the flyback loop across the coil, cathode to the coil’s positive side, and confirm the diode’s official current rating covers the coil current. Placement, orientation, and the release-time trade of a plain diode versus a resistor or Zener arrangement are covered in the relay flyback diode guide. Official 1N4148W average rectified current is 150 mA, with a 300 mA non-repetitive peak and a 2.0 A surge rating only at tp = 1 µs, so that small-signal diode does not cover a 200 mA coil as a continuous flyback path.
The same 200 mA coil does not close on official MMBT3904 rows. Continuous IC is 200 mA, so the coil already uses the entire official current rating. DC current gain is 100 to 300 at VCE = 1 V, IC = 10 mA; the minimum is 60 at 50 mA and 30 at 100 mA; there is no official hFE at 200 mA. VCE(sat) is 0.30 V maximum and VBE(sat) is 0.95 V maximum, both only at IC = 50 mA and IB = 5 mA. A buyer who treats the product-page “Hfe 300” as a design number is reading the upper limit of the 10 mA gain row. Pin identification for an NPN part is covered in the general-purpose NPN transistor guide and in the NPN multimeter checks; polarity for a high-side PNP drive is a different worksheet, described in the general-purpose PNP guide and the NPN versus PNP wiring guide.
| Line | What to write down | Official MMBT3904 at a 200 mA coil | Official BC817-40 at a 200 mA coil |
|---|---|---|---|
| 1. Collector current | Relay steady current plus inrush, versus official IC | Official continuous IC is 200 mA: no official headroom | Official continuous IC is 500 mA: 200 mA steady fits, inrush still needs the relay file |
| 2. Saturation drive | Base current from the official VCE(sat) test, not typical hFE | VCE(sat) is given only at 50 mA / 5 mA; no official 200 mA saturation row | VCE(sat) 0.70 V max at 500 mA / 50 mA (forced gain 10); use IB = 20 mA at 200 mA |
| 3. Gain check | Official minimum hFE at a current that covers the coil | Minimum hFE is 30 at 100 mA; no official value at 200 mA | Minimum hFE is 40 at 500 mA; classification range for BC817-40 is 250 to 600 |
| 4. Base resistor | RB = (Vlogic − VBE(sat)) / IB, then resistor wattage | Official VBE(sat) is 0.95 V max only at 50 mA, so the 200 mA resistor cannot be closed from that file alone | At 5 V, RB ≈ 180 Ω using official 1.20 V VBE(sat) and 20 mA; at 24 V, about 1.1 kΩ and 0.44 W |
| 5. Flyback path | Diode official current versus coil current, tight loop, correct polarity | 1N4148W official IO is 150 mA: below a 200 mA coil | Use a diode whose official IO or IF covers 200 mA; 1N4148W still does not |
SOT-23 is the official outline on both datasheets used above. The BC817-40 product page is BC817-40; the MMBT3904 page is MMBT3904. Family listings start at the transistor catalog.
When a MOSFET replaces the base-resistor wattage
Once the worksheet prices the base-resistor dissipation, the upgrade question is quantitative. On a 24 V rail, the 20 mA base current already dissipates about half a watt in the resistor, and that wattage grows with coil current. A logic-level MOSFET removes that base-wattage line, but only if the official ID and the official RDS(on) at the available gate voltage both cover the coil. The comparison of when a MOSFET or a BJT is the simpler switch is developed in the MOSFET versus BJT switching guide and in the twelve-scenario MOSFET or transistor guide.
The official Good-Ark 2N7002K datasheet (Rev. A) lists “relay driver” among its applications, but the electrical rows are narrow for a 200 mA coil and too narrow for a 500 mA coil. Drain-source voltage is 60 V, continuous drain current is 0.3 A at TC = 25 °C and VGS = 10 V, and maximum RDS(on) is 3.5 Ω at VGS = 5 V, ID = 0.05 A, or 3 Ω at VGS = 10 V, ID = 0.5 A. A 200 mA coil at the 5 V RDS(on) limit would drop 0.7 V and dissipate 0.14 W in the MOSFET, and a 500 mA coil exceeds the official 0.3 A continuous current. Application-line wording does not replace those limits.
A MOSFET that does publish a 4.5 V on-resistance can be checked on a 5 V GPIO. On the official GMN00703LM datasheet (Rev. A), VDS is 30 V, VGS(th) is 1.2 V to 2.5 V, and maximum RDS(on) is 0.96 mΩ at VGS = 4.5 V, ID = 20 A, or 0.68 mΩ at VGS = 10 V, ID = 20 A, in a PDFN5060 outline. The 335 A continuous current listed at TC = 25 °C is a case-temperature rating, not a still-air board current; official RθJA is 43 °C/W on a 1 in2 FR4 board with 2 oz copper. For a 200 mA coil the 4.5 V resistance is more than enough electrically; the part is simply an official example of a gate-voltage row you can actually use. Gate-drive timing and protection are covered in the gate-drive design guide, and 3.3 V or 5 V GPIO constraints are in the logic-level MOSFET guide. Official low- and medium-voltage MOSFET listings start at the LV/MV MOSFET catalog.

PDFN5060 is the official outline on the GMN00703LM product page. Confirm RDS(on) at the gate voltage the microcontroller actually produces, not only at 10 V.
FAQ
Can I size the base resistor from a typical hFE of 100?
No. Typical or landing-page gain is not the official saturation condition. On BC817-40, official VCE(sat) is specified at a forced gain of 10, while the 250 to 600 classification range is a different row. Using IB = IC / 100 under-drives the base relative to that saturation test and can leave the transistor out of the specified VCE(sat).
If the transistor’s official IC equals the coil current, is the part large enough?
Not by itself. Official MMBT3904 continuous IC is 200 mA, which matches a 200 mA coil and leaves no official headroom for pull-in inrush, temperature, or tolerance. The same file also lacks hFE and VCE(sat) at 200 mA, so the saturation line of the worksheet cannot be closed.
Does IB = IC / hFE,min guarantee saturation?
Not necessarily. Minimum hFE tells you the transistor can deliver the collector current in the active region. Official VCE(sat) is guaranteed only at the listed IC / IB test, which for BC817-40 is 500 mA / 50 mA. Use that forced gain for the resistor, then confirm the official minimum hFE still covers the coil current.
Can I omit the flyback diode if the transistor is oversized?
No. The coil stores energy that has to return through a defined path when the transistor turns off. A larger transistor current rating does not create that path. The diode must also be rated for the coil current: official 1N4148W average current is 150 mA, which is below a 200 mA coil.
The 2N7002K datasheet mentions relay drivers. Is it a drop-in upgrade from BC817-40?
Not on the official current and resistance rows. 2N7002K continuous ID is 0.3 A at TC = 25 °C, and maximum RDS(on) is 3.5 Ω at 5 V gate drive. That does not cover a 500 mA coil, and it is a poor fit even for 200 mA if you need a low switch drop. Choose a MOSFET whose official ID and official RDS(on) at the available gate voltage both cover the coil.

