A relay works in a circuit by using a low-power electromagnet (the coil) to mechanically pull a metallic armature, closing or opening high-power contacts. This provides galvanic isolation between a sensitive control signal (like a 5V microcontroller GPIO) and a heavy load (like a 120V AC motor or 12V DC solenoid). The control side dictates when the switch throws; the load side handles the actual current. Below, we break down the exact node topology, calculate real drive component values for an Omron G5LE, and map out what physically breaks when components fail.
The Core Topology: Nodes, Pins, and Current Paths
To understand how a relay works in a circuit, we must separate the schematic into two galvanically isolated halves: the control topology and the load topology. We will use standard node labels to trace the current paths.
Control Side (Low Voltage DC)
- Node A (Logic Input): The microcontroller GPIO pin (e.g., 5V from an Arduino Uno).
- Node B (Base Drive): The junction between the current-limiting base resistor and the NPN transistor base.
- Node C (Collector / Coil Ground): The NPN transistor collector, tied to one side of the relay coil.
- Node D (Emitter / System Ground): The NPN emitter, tied to the shared control circuit GND.
- Node E (Coil VCC): The positive supply for the relay coil (e.g., 12V DC), tied to the other side of the coil and the cathode of the flyback diode.
Load Side (Switched Power)
- Node F (COM - Common): The moving armature contact. Usually tied to the load's power source (Line or V+).
- Node G (NO - Normally Open): The contact that closes when the coil is energized. Tied to the load.
- Node H (NC - Normally Closed): The contact that is closed when the coil is de-energized. Used for fail-safe or interlock circuits.
Relay Behavior and Failure Mode Matrix
When designing or troubleshooting, you need to know exactly what happens when a specific element changes state or fails. The table below maps normal operation against extreme open/short failures in the control topology.
| Component / State Change | Circuit Behavior | Physical Result / Hazard |
|---|---|---|
| GPIO High (Normal) | Current flows A → B → Base → D. Transistor saturates, pulling Node C to GND. Coil energizes. | Armature pulls in. COM connects to NO. Load powers on. |
| GPIO Low (Normal) | Base current stops. Transistor cuts off. Coil field collapses, diode clamps the spike. | Armature springs back. COM connects to NC. Load powers off. |
| Flyback Diode SHORTED | Node E (12V) is directly shorted to Node C (Collector). When transistor turns on, VCC shorts to GND. | Massive current spike. Transistor explodes or PCB traces vaporize. Coil never energizes. |
| Flyback Diode OPEN / Missing | When transistor turns off, inductive spike ($V = L \frac{di}{dt}$) hits Node C. Voltage exceeds $V_{CEO}$ (usually 40V). | Transistor undergoes avalanche breakdown, fails short-circuit. Relay may stick 'on' permanently. |
| Base Resistor SHORTED | GPIO (Node A) connects directly to Base (Node B). Base-emitter junction acts as a raw diode. | GPIO sources excessive current (>40mA). Microcontroller pin burns out or silicon melts. |
| Base Resistor OPEN | No base current can flow regardless of GPIO state. Transistor remains in cutoff. | Relay stays completely de-energized. Load remains on NC contact (or off, if using NO). |
Design Walkthrough: Sizing the Drive Circuit for a 12V Relay
Let's build a real drive circuit. We are switching a 12V DC solenoid using a 5V Arduino Uno GPIO. We will use the Omron G5LE-14-DC12, a standard 12V SPDT PCB relay.
1. Calculate Coil Current
According to the Omron G5LE datasheet, the DC12 coil has a resistance of 360 Ω at 25°C.
Calculation: $I_{coil} = \frac{V}{R} = \frac{12V}{360\Omega} = 33.3mA$
The transistor must safely sink at least 33.3mA continuously.
2. Select the Switching Transistor
A standard PN2222A NPN BJT is rated for 600mA continuous collector current ($I_C$), which is massive overkill for 33mA, ensuring it runs cool. We will use it in a low-side switching topology.
If you use a PNP transistor on the high side (between 12V and the coil), a 5V or 3.3V microcontroller GPIO cannot reliably turn it off. When the GPIO outputs 5V 'HIGH', the base-emitter junction of the PNP still sees 7V ($12V - 5V$), keeping the transistor partially or fully turned on. Low-side NPN avoids this level-shifting headache because the emitter is tied to the shared 0V ground, making a 5V logic HIGH more than enough to saturate the base.
3. Size the Base Resistor ($R_B$)
To guarantee the PN2222A acts as a closed switch (saturation), we force a beta ($h_{FE}$) of roughly 20, even though the datasheet lists a typical $h_{FE}$ of 100+ at this current. This ensures the transistor doesn't overheat from a high $V_{CE}$ voltage drop.
- Required Base Current ($I_B$): $\frac{I_{coil}}{Forced \ Beta} = \frac{33.3mA}{20} = 1.66mA$
- GPIO Voltage ($V_{OH}$): 5.0V
- Base-Emitter Drop ($V_{BE}$): ~0.7V
- Resistor Math: $R_B = \frac{5.0V - 0.7V}{1.66mA} = 2590\Omega$
Component Choice: Select the next standard E12 value down to ensure hard saturation: 2.2 kΩ. This yields a base current of ~1.95mA, safely within the Arduino's 20mA per-pin limit.
4. The Flyback Diode Selection
When the transistor turns off, the coil's magnetic field collapses, generating a reverse voltage spike. A flyback diode placed in reverse-bias across the coil (Cathode to Node E, Anode to Node C) provides a recirculation path for this current.
While the ubiquitous 1N4007 works, its slow reverse recovery time ($t_{rr} \approx 30\mu s$) means the coil voltage decays slowly, which can cause the relay armature to release sluggishly. For faster relay drop-out times, use a small-signal switching diode like the 1N4148 ($t_{rr} \approx 4ns$) or a Schottky diode like the 1N5819. The 1N4148 is rated for 300mA continuous, easily handling the 33mA coil decay.
Step-by-Step Breadboard Verification
Before connecting your load, verify the control topology on a breadboard. This sequence prevents accidental MCU destruction.
- Place the Relay: Straddle the Omron G5LE across the breadboard's center trench. The coil pins are typically pins 2 and 5 (check the specific datasheet footprint, as pinouts vary by manufacturer).
- Install the Flyback Diode: Insert the 1N4148. The cathode (marked with a black band) must connect to the coil's 12V side (Node E). The anode connects to the transistor side (Node C). Getting this backwards will short your 12V supply to ground the moment the transistor turns on.
- Wire the Transistor: Place the PN2222A. With the flat face toward you, the pins are Emitter (left), Base (middle), Collector (right). Tie Emitter to the ground rail.
- Insert the Base Resistor: Connect the 2.2 kΩ resistor between the Arduino GPIO (Node A) and the transistor Base (Node B).
- Power the Rails: Connect your external 12V supply positive to the relay coil (Node E) and the external supply ground to the breadboard ground rail. Crucial: The Arduino GND and the 12V supply GND must be tied together on this same rail to complete the control circuit.
- The 'Click' Test: Upload a simple blink sketch (1 second HIGH, 1 second LOW) to the Arduino. You should hear a distinct mechanical click from the relay every second.
- Verify with a Multimeter: Set your meter to DC Volts. Measure between Node C (Collector) and Ground. When the GPIO is HIGH, this should read near 0.2V (transistor saturation voltage, $V_{CE(sat)}$). If it reads 12V, your transistor is not turning on (check base wiring). If it reads ~6V, the transistor is in the linear region and will overheat (lower your base resistor value).
For a deeper dive into the physics of inductive kickback and relay contact bounce, refer to the comprehensive guides at SparkFun's Relay Tutorial and All About Circuits. Understanding these node-level behaviors ensures your circuit survives the first power-on and operates reliably for years.






