Relay Driver with Flyback Diode: Circuit, Measurements and Online Simulator

To build this Relay Driver with Flyback Diode circuit you need a bench power supply, a 12 V battery, a toggle switch, a 4.7 kΩ resistor, a 2N2222 NPN transistor, a relay (5 V coil, SPDT), a 1N4148 diode and a 12 V 1 W bulb. A 5 V relay coil, switched by a transistor, turns a 12 V bulb on and off through its contacts — two circuits, electrically isolated. You hear it click. Make the 12 connections in the wiring table, press Run, and and flip the switch: the armature pulls in 5 ms later (you hear it), the NO contact closes and the bulb lights. The diode across the coil protects the transistor from the coil kick when it lets go.

Open this circuit in the free Electronics bench simulator

Parts list

QtyPartWhat it does
1Bench Power SupplySet the voltage and a current limit. It holds the voltage (CV) until the load wants more than the limit, then holds the current (CC). + and − float; GND is earth.
112 V batteryA DC source with a little internal resistance. + is the longer terminal.
1Toggle SwitchAn on/off switch between its two terminals. Flip it while the circuit runs.
14.7 kΩ resistorLimits current. 220 Ω in series with an LED; 10 kΩ as a pull-up or pull-down.
12N2222 NPN transistorA small base current (B→E) lets a current β times larger flow C→E. Use a base resistor (1 kΩ from a pin) to switch loads.
1Relay (5 V Coil, SPDT)A real relay: the 70 Ω coil pulls in above ~50 mA and releases below ~20 mA, 5 ms later each way (you hear the click). COM connects to NC at rest and to NO when energised. Drive the coil through a transistor, with a flyback diode.
11N4148 diodeConducts from A (anode) to K (cathode, the striped end) once about 0.7 V is across it; blocks the other way.
112 V 1 W bulbA filament bulb. Cold, its resistance is a tenth of its hot value, so it draws a surge at switch-on and glows up over a few tens of ms.

Wiring

#FromTo
1Bench Power Supply +Toggle Switch 1
2Toggle Switch 24.7 kΩ resistor leg 1
34.7 kΩ resistor leg 22N2222 NPN transistor B
42N2222 NPN transistor EBench Power Supply -
5Bench Power Supply -Bench Power Supply GND
6Bench Power Supply +Relay (5 V Coil, SPDT) COIL1
7Relay (5 V Coil, SPDT) COIL22N2222 NPN transistor C
81N4148 diode KRelay (5 V Coil, SPDT) COIL1
91N4148 diode ARelay (5 V Coil, SPDT) COIL2
1012 V battery +Relay (5 V Coil, SPDT) COM
11Relay (5 V Coil, SPDT) NO12 V 1 W bulb 1
1212 V 1 W bulb 212 V battery -

Step by step

  1. Open the electronics bench. Open the BitForBytes Embedded Lab in your browser. A circuit with no microcontroller runs on the analog bench: no install or account is needed.
  2. Add the parts. Add a bench power supply, a 12 V battery, a toggle switch, a 4.7 kΩ resistor, a 2N2222 NPN transistor, a relay (5 V coil, SPDT), a 1N4148 diode and a 12 V 1 W bulb from the parts palette (Instruments, Power, Passive and Semiconductors).
  3. Wire 1. Connect Bench Power Supply + to Toggle Switch 1.
  4. Wire 2. Connect Toggle Switch 2 to 4.7 kΩ resistor leg 1.
  5. Wire 3. Connect 4.7 kΩ resistor leg 2 to 2N2222 NPN transistor B.
  6. Wire 4. Connect 2N2222 NPN transistor E to Bench Power Supply -.
  7. Wire 5. Connect Bench Power Supply - to Bench Power Supply GND.
  8. Wire 6. Connect Bench Power Supply + to Relay (5 V Coil, SPDT) COIL1.
  9. Wire 7. Connect Relay (5 V Coil, SPDT) COIL2 to 2N2222 NPN transistor C.
  10. Wire 8. Connect 1N4148 diode K to Relay (5 V Coil, SPDT) COIL1.
  11. Wire 9. Connect 1N4148 diode A to Relay (5 V Coil, SPDT) COIL2.
  12. Wire 10. Connect 12 V battery + to Relay (5 V Coil, SPDT) COM.
  13. Wire 11. Connect Relay (5 V Coil, SPDT) NO to 12 V 1 W bulb 1.
  14. Wire 12. Connect 12 V 1 W bulb 2 to 12 V battery -.
  15. Run and measure. Press Run and flip the switch: the armature pulls in 5 ms later (you hear it), the NO contact closes and the bulb lights. The diode across the coil protects the transistor from the coil kick when it lets go.

Lab sheet

// Electronics bench: relay driver
//
// Control side: 5 V, switch, 4.7 kΩ into the NPN base; the coil from 5 V to the collector,
// a 1N4148 across the coil (cathode to +5 V) as a flyback diode.
// Load side: 12 V to COM, NO to the bulb, the bulb to 0 V. The sides share only a magnetic field.
//
// Coil: 70 Ω draws 71 mA at 5 V, above the 50 mA pickup. It lets go below 20 mA.

What to try

Press Run and flip the switch: the armature pulls in 5 ms later (you hear it), the NO contact closes and the bulb lights. The diode across the coil protects the transistor from the coil kick when it lets go.

Frequently asked questions

How do I wire the Relay Driver with Flyback Diode circuit?

Make 12 connections: Bench Power Supply + to Toggle Switch 1; Toggle Switch 2 to 4.7 kΩ resistor leg 1; 4.7 kΩ resistor leg 2 to 2N2222 NPN transistor B; 2N2222 NPN transistor E to Bench Power Supply -; Bench Power Supply - to Bench Power Supply GND; Bench Power Supply + to Relay (5 V Coil, SPDT) COIL1; Relay (5 V Coil, SPDT) COIL2 to 2N2222 NPN transistor C; 1N4148 diode K to Relay (5 V Coil, SPDT) COIL1; 1N4148 diode A to Relay (5 V Coil, SPDT) COIL2; 12 V battery + to Relay (5 V Coil, SPDT) COM; Relay (5 V Coil, SPDT) NO to 12 V 1 W bulb 1; 12 V 1 W bulb 2 to 12 V battery -.

What parts do I need for the Relay Driver with Flyback Diode?

A bench power supply, a 12 V battery, a toggle switch, a 4.7 kΩ resistor, a 2N2222 NPN transistor, a relay (5 V coil, SPDT), a 1N4148 diode and a 12 V 1 W bulb.

Can I simulate the Relay Driver with Flyback Diode online for free?

Yes. The BitForBytes Embedded Lab solves the circuit in time, the way SPICE does (nodal analysis with real diode, transistor and capacitor models), and gives you a bench power supply, function generator, oscilloscope and multimeter to measure it — free, in the browser.

What does this circuit show?

A 5 V relay coil, switched by a transistor, turns a 12 V bulb on and off through its contacts — two circuits, electrically isolated. You hear it click.

More Electronics bench projects