Decoding the Relay in Circuit Diagram: Topology and Node Labels

When you analyze a standard relay in circuit diagram layouts, you are looking at two galvanically isolated circuits bridged entirely by a magnetic field. The control side (low-voltage DC logic) and the load side (AC mains or high-power DC) share no direct electrical connection. This isolation is what makes relays indispensable for protecting sensitive microcontrollers from high-voltage transients.

Below is the standard low-side NPN SPDT (Single Pole Double Throw) electromagnetic relay topology, broken down by explicit node labels to help you trace the current path during design and troubleshooting:

  • Node 1 (N1): MCU GPIO Output (e.g., ESP32-WROOM-32 Pin 25)
  • Node 2 (N2): Base Resistor ($R_1$) Input
  • Node 3 (N3): NPN Transistor Base (2N2222)
  • Node 4 (N4): NPN Emitter to System GND
  • Node 5 (N5): NPN Collector / Flyback Diode Anode / Relay Coil Pin A
  • Node 6 (N6): Relay Coil Pin B / Flyback Diode Cathode / VCC (5V)
  • Node 7 (N7): Common (COM) - Load Return Path
  • Node 8 (N8): Normally Open (NO) - Load Active Path
  • Node 9 (N9): Normally Closed (NC) - Load Default Path
Bench Safety Note: Never breadboard the load side (COM, NO, NC) with mains AC voltage (120V/240V). Keep load-side testing restricted to low-voltage DC (e.g., a 12V LED strip or a 5V buzzer) until the control logic is verified and the circuit is moved to a soldered perfboard or enclosed terminal block.

Component Selection and Spec Sheet Data

Before calculating resistor values, we must anchor the design to real-world components. The table below outlines a robust, low-cost component selection for a 5V relay driven by a 3.3V microcontroller logic pin.

Component Part Number Critical Parameter Value Est. Cost (2026)
Power Relay Songle SRD-05VDC-SL-C Coil Resistance 70 Ω $1.20
Signal Relay Omron G5V-2-5VDC Contact Rating 2A @ 30VDC $2.50
NPN Transistor 2N2222 (TO-92) Max Collector Current ($I_C$) 800 mA $0.10
Flyback Diode 1N4007 Peak Reverse Voltage 1000 V $0.05
Base Resistor Carbon Film (E12) Base Limit ($R_1$) 330 Ω $0.02

Design Walkthrough: Sizing the Base Resistor

Let's design the control side for an ESP32 driving the Songle SRD-05VDC-SL-C. The relay coil has a nominal resistance of 70 Ω. At a 5V supply, the steady-state coil current is $I = V/R = 5 / 70 = 71.4 \text{ mA}$.

To guarantee the 2N2222 acts as a closed switch (hard saturation), we assume a forced beta ($h_{FE(sat)}$) of 10, rather than the datasheet's linear gain of 100+. Required base current $I_b = 71.4 \text{ mA} / 10 = 7.14 \text{ mA}$.

The ESP32 GPIO outputs 3.3V. Accounting for the base-emitter voltage drop ($V_{be} \approx 0.7\text{V}$), the voltage across the base resistor is $3.3 - 0.7 = 2.6\text{V}$. Using Ohm's Law: $R_1 = 2.6\text{V} / 7.14\text{mA} = 364 \, \Omega$. We select the next standard E12 value down: 330 Ω. This provides ~7.8 mA of base current, safely within the ESP32's 40 mA absolute maximum GPIO limit, while ensuring the transistor saturates fully with a $V_{CE(sat)}$ of roughly 0.2V.

Behavior Matrix: Failure Modes and Extremes

Understanding what breaks at the extremes is what separates a hobbyist from a competent designer. If a single element in this topology fails open or short, the cascading effects can be destructive. The behavior matrix below details these exact failure modes.

Element Failure State Circuit Behavior Physical Consequence
Base Resistor ($R_1$) Open No base current reaches N3. Transistor remains in cutoff. Relay stays in default state (COM to NC). MCU is perfectly safe.
Flyback Diode (D1) Open / Missing Inductive kickback ($V = -L \frac{di}{dt}$) has no recirculation path when N1 goes LOW. Voltage at N5 spikes to >50V. Exceeds 2N2222 $V_{CEO}$ (40V max), destroying the transistor and potentially back-feeding the ESP32 GPIO.
Relay Coil Short Coil resistance drops to near 0 Ω. 5V rail sags heavily. Transistor attempts to pass >500mA. 2N2222 exceeds its 625mW power dissipation limit, resulting in thermal runaway and magic smoke.
Contacts (COM-NO) Welded (Short) Mechanical armature fuses to the NO contact due to high-current DC arcing. Load remains permanently energized even when N1 goes LOW. Critical safety hazard in mains-voltage applications; requires physical replacement.
Transistor (C-E) Short Collector and Emitter act as a dead short to GND. Relay coil is permanently energized. If the coil is left on indefinitely, it may overheat and melt the plastic bobbin housing.

Low-Side NPN vs. High-Side PNP: Why This Topology Wins

A common question when drafting a relay in circuit diagram software is whether to switch the ground path (low-side NPN) or the positive voltage path (high-side PNP). The low-side NPN topology is the undisputed standard for microcontroller-driven relays, and the reason comes down to logic-level voltage matching.

If we used a PNP transistor (like a 2N3906) on the high side, the emitter would connect to the 5V VCC rail. To turn the PNP ON, the base must be pulled to GND. To turn it OFF, the base must be pulled up to 5V. Here is the fatal flaw: A 3.3V MCU GPIO cannot output 5V. If you connect a 3.3V GPIO directly to the PNP base via a resistor, the GPIO will only pull the base up to 3.3V. This leaves a 1.7V differential across the base-emitter junction, causing the PNP to remain partially ON, or worse, forcing current backward through the MCU's internal ESD protection diodes, eventually bricking the ESP32.

To make a high-side PNP work with a 3.3V MCU, you must add a second NPN transistor just to level-shift the 3.3V logic up to 5V. The low-side NPN topology avoids this entirely by referencing the switch to GND, requiring only a single base resistor and keeping the parts count minimal.

Step-by-Step Breadboard Testing Procedure

Before connecting any high-power loads, you must verify the control logic and the flyback diode's presence. Follow this exact sequence to validate your build on the bench.

  1. Wire the Control Side Only: Connect the ESP32 GPIO to the 330 Ω resistor, the resistor to the 2N2222 base, the emitter to GND, and the collector to the relay coil. Wire the 1N4007 diode in reverse bias across the coil (stripe facing the 5V VCC rail).
  2. Verify Diode Polarity: Use your multimeter's diode mode. Place the red probe on the diode's anode (N5) and black on the cathode (N6). You should read a ~0.6V forward voltage drop. If you read "OL" in this direction, your diode is backward and will short the 5V rail when the relay turns off.
  3. Test Default Continuity: Set the multimeter to continuity mode. Probe the COM and NO terminals on the load side. The meter should read "OL" (open loop). Probe COM and NC; it should beep (< 1 Ω).
  4. Apply Logic HIGH: Power the 5V rail and the ESP32. Trigger the GPIO pin HIGH. You should hear the distinct 2-5ms acoustic "click" of the armature pulling in. If you hear a faint buzzing instead of a solid click, your coil is under-volted or the transistor is not fully saturating.
  5. Verify Contact Closure: While the GPIO is HIGH, probe COM and NO again. The meter should now beep, indicating < 1 Ω of resistance across the contacts.
  6. Measure $V_{CE(sat)}$: For a final sanity check, measure the DC voltage between the transistor's Collector and Emitter while the relay is ON. It should read between 0.1V and 0.3V. If it reads >1V, the transistor is in the linear region and will overheat; reduce your base resistor value.

For deeper reading on inductive kickback and relay mechanics, refer to SparkFun's Relay Tutorial and the classic All About Circuits chapter on Electromechanical Relays. When driving multiple inductive loads directly from logic ICs, the Texas Instruments ULN2003A datasheet provides excellent reference schematics for integrated flyback diodes and Darlington pairs, saving you from wiring discrete components for every single channel.