A relay is an electrically operated switch that uses a low-power control signal to isolate and switch a separate, higher-power circuit. In a real installation, it changes the architecture by providing galvanic isolation—meaning your fragile 3.3V microcontroller shares absolutely no electrical path with the 120V AC load it commands. Beginners commonly confuse relays with contactors (which are simply heavy-duty relays designed for >20A or 3-phase industrial loads) and transistors (which can switch DC loads rapidly but lack a physical air-gap for safety isolation).
The Core Mechanism: Coil, Armature, and Contacts
At its physical core, an electromechanical relay (EMR) consists of three main components: an electromagnetic coil, a movable armature, and a set of metallic contacts. When you apply voltage to the coil, it generates a magnetic field that pulls the armature. This physical movement either closes or opens the contact circuit.
The beauty of this design is the complete physical separation between the control side and the load side. For example, a standard Songle SRD-05VDC-SL-C (the ubiquitous blue cube relay found on maker modules) features a 5VDC coil that draws roughly 70mA, while its contacts can independently switch up to 10A at 250VAC. The only link between the two sides is magnetic flux.
Worked Numeric Example: Sizing a Relay for an ESP32 Project
Let’s look at a common bench scenario: You want to use an ESP32 GPIO pin to switch a 12V DC water pump that draws 8A under normal load using a standard 5V relay module.
1. Calculating the Coil Drive Requirements
The relay coil has a resistance of roughly 70Ω. Using Ohm’s Law ($I = V / R$):
- Coil Current: 5V / 70Ω = 71.4mA
An ESP32 GPIO pin has an absolute maximum current limit of 40mA, and a recommended safe operating limit of 20mA. If you wire the relay coil directly to the ESP32, you will brownout the microcontroller or permanently damage the GPIO driver.
2. The Fix: Adding a Logic-Level MOSFET
To bridge this gap, you must use a logic-level N-channel MOSFET (like the IRLB8721 or 2N7000) as a current amplifier. The ESP32 drives the MOSFET gate (drawing microamps), and the MOSFET switches the 71.4mA coil current from the 5V rail to ground.
3. The DC Motor Edge Case (Contact Welding)
Here is where theory meets harsh reality. While the relay contacts are rated for 10A, that rating assumes a resistive AC load. A 12V DC water pump has a stall current (inrush when the rotor is stuck or starting) that can easily spike to 25A. Furthermore, DC arcs do not have a zero-crossing point to naturally extinguish like AC does. According to SparkFun's relay guidelines and manufacturer derating curves, switching 12V DC inductive loads often requires derating the contact capacity by 50% or more. If you use a standard 10A blue cube for an 8A DC motor, the inrush arc will eventually weld the contacts shut, leaving the pump running permanently. For DC motors, always use an automotive-rated 30A Bosch-style relay or a properly rated Solid State Relay (SSR).
Where You Meet Relays in Practice
You will encounter relays across almost every electrical discipline, though their form factors change drastically based on the environment:
- HVAC Control Boards: Furnace control boards use 24VAC coil relays to switch the blower motor and gas valve. The low-voltage thermostat signal triggers a transistor, which energizes the 24VAC coil.
- Automotive Electrical: Your car’s headlights, fuel pump, and starter solenoid are all driven by heavy-duty 12VDC relays. This allows thin 18 AWG wires to run from the dashboard switch to the relay in the engine bay, while thick 10 AWG wires carry the heavy load from the battery to the load.
- Smart Home Automation: Devices like the Shelly 1 PM sit inside your wall junction boxes. They use Wi-Fi to trigger an internal 10A relay, allowing you to smart-control existing dumb light switches without rewiring your home.
- Industrial PLC Panels: Programmable Logic Controllers (PLCs) use banks of DIN-rail mounted interface relays to protect their expensive output cards from field-side voltage spikes and short circuits.
Electromechanical (EMR) vs. Solid-State Relays (SSR)
When designing a circuit, you must choose between a traditional moving-part EMR and a semiconductor-based SSR. Here is how they compare on the bench:
| Criteria | Electromechanical Relay (EMR) | Solid-State Relay (SSR) |
|---|---|---|
| Switching Speed | Slow (5ms - 20ms) | Extremely Fast (< 1ms, zero-cross capable) |
| Contact Wear | Mechanical lifespan limits (100k - 500k cycles) | No moving parts (millions of cycles) |
| On-Resistance | Near zero (milliohms); runs cool | Higher (ohms); requires heat sinking at high amps |
| Isolation Method | Physical air gap (failsafe open) | Optocoupler (can fail short-circuit) |
| Audible Noise | Audible "click" | Silent operation |
Choose EMR when: You need a true physical air-gap for safety, you are switching mixed AC/DC signals, or you want minimal heat generation at high currents without needing a heatsink.
Choose SSR when: You are switching high-frequency PWM loads, require silent operation, or need to avoid the electromagnetic interference (EMI) caused by a physical contact bounce.
Frequently Asked Questions
What is the difference between a relay and a contactor?
Functionally, they are identical—both use a low-power coil to switch a high-power load. The distinction is based on scale and application. According to industry standards outlined by All About Circuits, a device is generally classified as a contactor when it is designed to handle currents above 15A-20A, switch 3-phase power, or includes built-in arc chutes to safely extinguish the massive electrical arcs generated by heavy industrial motors. Relays are typically used for control circuits, single-phase loads, and lower current branch switching.
Why do I need a flyback diode across a relay coil?
A relay coil is an inductor. When you remove power from an inductor, the collapsing magnetic field induces a massive reverse voltage spike (often exceeding 100V) in a desperate attempt to keep current flowing. If you are driving the coil with a sensitive microcontroller or a MOSFET, this inductive kickback will instantly punch through the semiconductor junction and destroy your component. Placing a standard rectifier diode (like a 1N4007) in reverse-bias across the coil gives this spike a safe path to dissipate back into the coil, protecting your driving circuit.
Can I use a 5V DC relay to switch 120V AC mains?
Yes, absolutely, provided you respect the two separate ratings printed on the datasheet. The coil voltage (5VDC) dictates what you must feed the control side to activate the magnet. The contact rating (e.g., 10A 250VAC) dictates what the physical switch can handle on the load side. As long as the contact rating exceeds your 120V AC load, the relay will switch it safely. The critical mistake beginners make is assuming a "5V relay" can only switch 5V loads, or conversely, wiring 120V AC directly into the 5V DC coil terminals, which will result in an immediate and dangerous short circuit.
What does SPDT mean on a relay pinout?
SPDT stands for Single Pole, Double Throw. It means the relay has one common input terminal (the Pole) that physically flips between two separate output terminals (the Throws). In a standard 5-pin relay, you have the Coil+, Coil-, Common (COM), Normally Open (NO), and Normally Closed (NC). When unpowered, COM is connected to NC. When energized, the armature pulls COM away from NC and connects it to NO. This allows you to wire two completely different loads to a single relay, where one turns on while the other turns off.






