Relays
A relay is an electrically operated switch. A small control current energizes an electromagnet, which physically moves a set of contacts to switch a separate, often much higher-power, circuit. Relays are the bridge between low-power control electronics and high-power loads — and they are essential components in cars, appliances, home automation and industrial control.
How Relays Work
Inside a mechanical relay, a coil of wire is wound around an iron core. When current flows through the coil, the core becomes an electromagnet that attracts a spring-loaded metal arm called the armature. The armature moves and pushes a set of electrical contacts from one position to another. When the coil current stops, the spring pulls the armature back to its resting position.
The coil circuit and the contact circuit are completely isolated from each other electrically. The only connection between them is magnetic force. This isolation allows a 5 V logic signal to switch a 240 V electrical circuit, or a microcontroller output to control a 30 A motor or heater — with no direct electrical connection between the two.
A relay driven through a transistor switch. The flyback diode across the coil protects the transistor from the inductive voltage spike when the relay de-energizes.
View LargerContact Types: NO, NC, and Common
A relay's switching contacts have specific names based on their state when the relay coil is not energized (the relay is at rest).
- Common (COM): The contact that moves. It connects to either NO or NC depending on whether the relay is energized.
- Normally Open (NO): The contact that is open (disconnected) when the relay is at rest. When the relay energizes, the armature closes the circuit between COM and NO.
- Normally Closed (NC): The contact that is closed (connected to COM) when the relay is at rest. When the relay energizes, the armature breaks this connection.
Relay Configurations
Relays are described by the number of poles (separate contact sets) and the number of throws (positions each pole can connect to).
| Designation | Meaning | Contacts | Typical Use |
|---|---|---|---|
| SPST | Single Pole Single Throw | COM + NO (or NC) | Simple on/off switching |
| SPDT | Single Pole Double Throw | COM + NO + NC | Changeover switching (T/R relay) |
| DPDT | Double Pole Double Throw | 2 × (COM + NO + NC) | Switching two circuits simultaneously |
| 4PDT | Four Pole Double Throw | 4 × (COM + NO + NC) | Industrial control panels, switching several circuits at once |
The Flyback Diode
A relay coil is an inductor. When current through an inductor is suddenly interrupted — as happens when the relay is switched off — the magnetic field collapses and the inductor attempts to maintain current flow by generating a large voltage spike in the opposite polarity. This spike can easily exceed 100 V even from a 12 V relay, destroying the transistor or IC that was driving the coil.
The solution is a flyback diode (also called a freewheeling diode or suppression diode) connected in reverse across the coil: anode to the negative rail, cathode to the positive rail. Under normal operation the diode is reverse-biased and does nothing. When the relay switches off and the spike appears, the diode is suddenly forward-biased and clamps the spike to about 0.7 V, safely dissipating the stored energy as a brief diode current.
Types of Relays
Electromechanical Relay (EMR)
The standard relay with a physical coil, armature, and contacts. Completely isolated, handles high voltages and currents, but has a limited number of mechanical switching cycles (typically 1–10 million operations) and switching speed measured in milliseconds.
Reed Relay
A reed relay uses a coil surrounding a glass capsule containing two ferromagnetic contact blades (reeds) in an inert gas atmosphere. The magnetic field closes the reeds. Reed relays switch faster than standard EMRs, generate less contact bounce, and last longer (up to 1 billion operations), but handle lower currents. They appear in test equipment, alarm sensors (operated by a magnet instead of a coil) and signal switching where low contact resistance and fast switching are important.
Solid-State Relay (SSR)
An SSR uses a phototriac, TRIAC, or MOSFET instead of mechanical contacts, controlled via an optocoupler. SSRs have no moving parts, switch silently, and last indefinitely — but they have a small on-state voltage drop, generate heat at high currents, and do not provide the galvanic isolation of a mechanical relay. SSRs are common in heater and oven controllers, 3D printers and power switching applications where relay noise or wear is a problem.
Practical Applications
Switching Mains Loads from a Microcontroller
A relay module lets an Arduino or ESP32 output switch a lamp, heater, pump or fan running from mains voltage. The 5 V coil is driven through a transistor, and the contacts — rated for 230 V AC at 10 A, for example — carry the load current with complete isolation from the low-voltage side. The mains wiring must still be enclosed and fused, and the contact rating respected.
Automotive Relays
Cars use relays everywhere: the headlights, horn, fuel pump and starter motor all draw far more current than a dashboard switch can carry. A small switch energizes the relay coil, and the relay contacts handle 30 A or more through short, heavy wiring. Adding driving lights or a winch to a vehicle follows the same pattern.
Backup Power Changeover
A relay can switch a load from the mains supply to a backup battery when the mains fails. The coil is powered from the mains adapter: while it is energized, the load runs from the adapter through the NO contact; when the adapter dies, the relay drops out and the NC contact connects the battery.
Power Sequencing and Protection
Control systems use relays to switch power to equipment in a defined sequence — for example, delaying a power amplifier's speaker connection until its supply has settled, which prevents the loud thump at switch-on.
Hands-On: Drive a Relay with a Transistor
Build a simple transistor-driven relay circuit and observe the protection provided by the flyback diode.
- 5 V or 12 V SPDT relay (coil voltage must match your supply)
- NPN transistor (2N2222 or BC547)
- 1 kΩ resistor (base current limiter)
- 1N4001 or 1N4148 diode
- LED and 470 Ω resistor (load indicator)
- Breadboard, power supply, jumper wires
- Connect the relay coil between the collector of the NPN transistor and the positive supply rail. Connect the transistor emitter to ground.
- Connect the 1 kΩ resistor between a control input and the transistor base. Apply a logic high to the control input to switch the transistor on.
- Connect the LED and 470 Ω resistor between the relay NO contact and the positive supply, with the relay COM to ground. When the relay energizes, the LED lights.
- Install the 1N4001 across the coil (cathode to positive rail, anode to collector). Toggle the relay on and off and observe that the LED responds cleanly.
- Listen for the relay click each time it energizes and de-energizes — this confirms the mechanical action.
Frequently Asked Questions
What is the difference between NO and NC contacts?
Normally Open (NO) contacts are open (disconnected) when the relay coil is not energized. Normally Closed (NC) contacts are closed (connected to COM) when the coil is not energized. Energizing the coil reverses both states: NO closes and NC opens.
Why does a relay need a flyback diode?
The relay coil is an inductor. When switched off, its collapsing magnetic field generates a large reverse-polarity voltage spike that can damage or destroy the transistor or IC driving the coil. A diode placed in reverse across the coil clamps this spike, allowing it to dissipate safely as a brief circulating current through the diode.
Can I switch mains voltage with a relay module?
Yes, provided the contacts are rated for the voltage and current and the installation is safe. Check the contact rating printed on the relay (for example 10 A 250 V AC), put the mains wiring in an enclosed box with strain relief, fuse the circuit, and keep the low-voltage wiring well apart from the mains wiring. Cheap relay modules sometimes have poor spacing between the mains tracks and the low-voltage side, so inspect the board before trusting it with mains.
Why do relay contacts wear out, and how can I make them last longer?
Each time the contacts open under load, a small arc forms and erodes the contact surfaces. Inductive loads such as motors and solenoids make the arc much worse. Keep the load within the contact rating, add a snubber (a resistor and capacitor in series) or a varistor across inductive loads, and consider a solid-state relay for loads that switch very frequently.
What relay coil voltage should I use in my project?
Match the relay coil voltage to the available control voltage in your circuit. Common choices are 5 V for microcontroller-driven relays, 12 V for automotive and 12 V systems, and 24 V for industrial applications. Using a relay coil voltage below specification means the relay may not pull in reliably; above specification causes excess heat and shortens coil life.
Test Your Knowledge
Answer the questions below to check your understanding. Every answer can be found in the lesson above.