The most reliable relay circuit schematic for 5V microcontrollers uses a low-side NPN BJT topology. You need a 5V relay (like the Songle SRD-05VDC-SL-C), a 2N2222 NPN transistor, a 1kΩ base resistor, and a 1N4148 flyback diode. This configuration safely isolates the 70mA coil current from your GPIO pin, which typically maxes out at 20mA. By placing the transistor on the ground side of the coil, you avoid complex level-shifting and ensure the relay fully de-energizes when the GPIO goes low.

The Standard Low-Side Relay Circuit Schematic: Node Topology & Behavior

Before soldering or wiring a PCB, you must understand the exact node relationships in a low-side switch. Unlike high-side switching, where the load sits between the switch and ground, a low-side topology places the load (the relay coil) between the positive supply and the switching element. This is the industry standard for electromechanical relay control because NPN transistors and N-channel MOSFETs are cheaper, faster, and easier to drive from low-voltage logic than their PNP/P-channel counterparts.

Node Topology Map

  • Node A (CTRL): Microcontroller GPIO output (0V or 5V logic).
  • Node B (R1_IN): Junction between GPIO and the 1kΩ base resistor.
  • Node C (BASE): 2N2222 Base pin / R1_OUT.
  • Node D (COLLECTOR): 2N2222 Collector / Relay Coil- / 1N4148 Anode.
  • Node E (EMITTER): 2N2222 Emitter / System GND.
  • Node F (VCC_COIL): 5V Supply / Relay Coil+ / 1N4148 Cathode.
  • Node G (COM): Relay Common contact (switched high-current path).
  • Node H (NO): Relay Normally Open contact.
  • Node I (NC): Relay Normally Closed contact.

State & Failure Behavior Matrix

This table defines exactly what happens at critical nodes under normal operation and single-point failures. Understanding this matrix is how you troubleshoot a dead relay without blindly swapping parts.

Condition / State Node C (Base V) Node D (Collector V) Coil Current COM-NO Path
CTRL = 0V (Logic LOW) 0V ~5.0V (Floating high via coil) 0 mA Open
CTRL = 5V (Logic HIGH) ~0.7V (Vbe drop) ~0.2V (Vce saturation) ~70 mA Closed
Open Base Resistor (R1) 0V (Floating) ~5.0V 0 mA Open
Shorted Flyback Diode ~0.7V (if CTRL=5V) 5.0V (Shorted to VCC) Bypassed (Transistor burns) Open (or welded)
Open Relay Coil ~0.7V (if CTRL=5V) 0.2V (Transistor saturates empty) 0 mA Open

Component Selection & Design Walkthrough

Let's build this out with real, off-the-shelf values. We are targeting a 5V logic system (like an Arduino Uno or ESP32 dev board running through a level shifter) driving a standard 10A mechanical relay.

Designator Component Real-World Value / Part Number Why This Specific Part?
K1 Electromechanical Relay Songle SRD-05VDC-SL-C 70Ω coil (71mA at 5V), 10A/250VAC contacts. Ubiquitous and cheap (~$1.50).
Q1 NPN BJT Transistor 2N2222 (TO-92) Handles up to 800mA continuous. 71mA coil current is well within its safe operating area.
R1 Base Resistor 1kΩ (1/4W, 5%) Limits base current to 4.3mA, providing a forced beta of ~16 to guarantee hard saturation.
D1 Flyback Diode 1N4148 Fast switching speed (4ns) clamps the inductive spike faster than a standard 1N4007 rectifier.

The Base Resistor Math

According to BJT saturation principles, you never design a switch using the transistor's linear hFE (which might be 200). You use a 'forced beta' of 10 to 20 to ensure the transistor acts as a closed switch with minimal voltage drop (Vce_sat).

The relay coil draws Ic = 5V / 70Ω = 71.4mA.
Target base current (Ib) for a forced beta of 15: 71.4mA / 15 = 4.76mA.
The voltage across R1 is the GPIO high (5V) minus the base-emitter drop (Vbe ≈ 0.7V), leaving 4.3V.
Using Ohm's law: R = 4.3V / 4.76mA = 903Ω.
The nearest standard E12 resistor value is 1kΩ, which yields 4.3mA of base current. This is perfectly adequate to saturate the 2N2222 without overloading a microcontroller GPIO pin rated for 20mA.

Bench Tip: If you are driving this from a 3.3V microcontroller (like a raw ESP32 GPIO), the voltage across R1 drops to 2.6V (3.3V - 0.7V). A 1kΩ resistor will only supply 2.6mA, which might leave the 2N2222 in the linear region, causing it to overheat. For 3.3V logic, drop R1 to 470Ω or switch to a logic-level MOSFET like the 2N7000.

Why Low-Side NPN Switching Beats the Alternatives

When sketching a relay circuit schematic, beginners often ask why we don't just connect the relay directly to the MCU pin, or put the transistor on the 5V side. Here is the engineering reality of those alternatives.

Topology Pros Cons & Failure Risks Verdict
Direct MCU Pin Drive Zero extra components. MCU pin maxes at 20-40mA. The 71mA coil will fry the silicon instantly. Never do this.
High-Side PNP BJT Load is grounded when off (safer for some automotive loads). Requires base to be pulled to VCC to turn off. If MCU is 3.3V and VCC is 5V, you need a second NPN transistor just to level-shift the base drive. Too complex for standard 5V logic.
High-Side P-Channel MOSFET No base current draw, fast switching. Vgs threshold issues. If VCC is 12V and MCU is 5V, turning the MCU 'off' (5V) still leaves Vgs at -7V, keeping the relay stuck ON. Requires extra gate driver circuitry.
Low-Side NPN BJT (Our Pick) Simple, cheap, 0V logic turns it completely off regardless of VCC voltage. Load is 'hot' (connected to VCC) even when the relay is off. A short to ground in the load wiring will blow the fuse. Best for 95% of hobbyist and PCB applications.

Failure Mode Analysis: What Breaks at the Extremes?

A robust schematic anticipates how it will fail. Here is what happens when individual elements in this topology break down on the bench.

1. The Flyback Diode is Installed Backwards

If you flip the 1N4148 (cathode to Node D, anode to Node F), it acts as a forward-biased short circuit the moment the transistor turns on. The 5V rail dumps directly through the diode and the saturated transistor to ground. The 2N2222 will exceed its 800mA limit and pop in milliseconds, potentially sending a voltage spike back through the base resistor into your microcontroller.

2. The Relay Coil Opens (Internal Wire Break)

If the fine copper wire inside the relay coil snaps, the circuit becomes an open loop. When the MCU drives the GPIO high, the transistor base receives current and saturates, pulling Node D to 0.2V. However, because there is no coil, no current flows. The relay simply stays in the Normally Closed (NC) state. The transistor remains perfectly safe; it just switches 'air'.

3. GPIO Pin Stuck High (MCU Brownout/Crash)

If your microcontroller crashes during a firmware update and leaves the GPIO pin floating or stuck high, the relay remains energized. In a low-side topology, the coil is continuously powered. This is why safety-critical circuits (like garage door openers or heating elements) should use the Normally Open (NO) contacts (Node H). If the control circuit fails or loses power, the relay drops out and the high-power load safely turns off.

Step-by-Step Breadboard Verification Protocol

Do not connect your high-voltage load (mains AC or a 12V motor) until you have proven the low-voltage switching logic on a breadboard. Follow this exact sequence to avoid bricking your dev board.

  1. Build the Control Side First: Insert the 2N2222, 1kΩ resistor, and 1N4148 diode. Leave the relay out for now. Connect Node E to the breadboard ground rail.
  2. Verify the Base Drive: Power the breadboard with 5V. Use your multimeter to probe Node C (Base) while toggling the GPIO. You should read ~0.7V when HIGH, and 0V when LOW. If you read 5V at the base, your resistor is open or missing.
  3. Test the Open-Collector Pull-Up: With the relay still removed, probe Node D (Collector). When the GPIO is LOW, Node D should float up to 5V (if your meter has a high-impedance input). When GPIO is HIGH, Node D must drop to < 0.3V. This proves the transistor is saturating correctly.
  4. Insert the Relay: Power down the breadboard. Plug in the Songle relay. Ensure the diode is physically parallel to the coil pins (Cathode stripe pointing to the 5V rail).
  5. The 'Click' Test: Power up and toggle the GPIO. You must hear a sharp mechanical click. If the relay chatters or buzzes, your 5V rail is sagging under the 70mA inrush. Add a 100µF electrolytic capacitor across the 5V and GND rails near the relay to stabilize the local voltage.
  6. Measure the Flyback Clamp: If you have an oscilloscope, probe Node D. Trigger on the falling edge of the GPIO signal. When the transistor turns off, you should see a brief spike clamped to roughly 5.7V (5V rail + 0.7V diode forward drop). If you see a spike exceeding 15V, your diode is too slow or installed backwards.
  7. Wire the High-Voltage Load: Only after steps 1-6 pass do you connect Nodes G, H, and I to your actual load. Warning: Ensure all mains AC wiring is de-energized, locked out, and verified dead with a CAT III meter before terminating wires into the relay screw terminals or breadboard.

By treating the relay circuit schematic not just as a drawing, but as a system of defined nodes and predictable failure states, you move from guessing to engineering. Stick to the low-side NPN topology, respect the base current math, and never skip the flyback diode.