Circuit 3D

How a relay works

A relay is a switch worked by an electromagnet: current through its coil pulls a hinged armature that moves a set of contacts, so a small current switches a separate, often larger, circuit. A 5 V relay with a 70 Ω coil draws 5 ÷ 70 ≈ 71 mA.

I = Vcoil ÷ Rcoil

where Vcoil is its rated coil voltage and Rcoil the coil’s resistance, so a 5 V relay with a 70 Ω coil draws about 71 mA.

Its common contact, COM, rests on the normally closed contact and swings to the normally open one while the coil is on.

What is a relay?

A relay is an electrically operated switch: a small current through its coil opens or closes contacts in a separate circuit, which may run at a higher voltage or current.

It lets a microcontroller, a sensor or a timer switch a lamp, a pump or a heater it could never power itself, and the two circuits stay electrically apart. In Figure 1, switch the coil on and watch the common contact swing from one lamp to the other.

coil, 5 V COM NC NO NC lamp NO lamp

Coil on: 5 V ÷ 70 Ω = 71.4 mA through the coil makes an electromagnet that pulls the armature down, so COM swings to NO: the NO lamp lights and the NC lamp goes out.

Figure 1. A 5 V relay with a 70 Ω coil, drawn open: its armature carries the common contact, COM, between the normally closed contact, NC, and the normally open one, NO, each wired to its own lamp.

How does a relay work?

Current through the coil turns its iron core into an electromagnet, which pulls a hinged iron armature towards it; a spring pulls the armature back when the current stops.

The armature carries the moving contact, so each pull and release flips the contacts, with the familiar click. The coil and contacts share no wire, only a magnetic pull, so the switched circuit is isolated from the one that controls it. The coil is an inductor, which matters when it switches off.

What do COM, NO and NC mean on a relay?

COM is the common, moving contact; NO is normally open, joined to COM only while the coil is on; and NC is normally closed, joined to COM while the coil is off.

Wire a load between COM and NO to switch it on with the coil, or between COM and NC to switch it off. The contacts are rated for a maximum voltage and current, often printed on the case; stay within both, and leave mains wiring to qualified people.

How do you drive a relay from a microcontroller?

To drive a relay from a microcontroller, use a transistor: the pin feeds its base through a resistor, and the transistor switches the coil’s larger current.

A typical 5 V hobby relay draws about 71 mA, far more than a pin should supply, though a small reed relay may draw only 10 mA. Figure 2 compares each coil’s current with an Arduino Uno pin’s ratings, with and without a transistor.

20 mA rated 40 mA maximum 71.4 mA from the pin

A 70 Ω coil, straight from the pin: it would ask for 5 V ÷ 70 Ω = 71.4 mA, past even the 40 mA absolute maximum, damaging the pin; switch it with a transistor.

Figure 2. 5 V relay coils, from a reed relay’s 500 Ω to a hobby relay’s 70 Ω, against an Arduino Uno pin’s ratings.

Why does a relay need a flyback diode?

A relay needs a flyback diode because its coil resists any sudden change in current, so switching it off makes a voltage spike that can destroy the transistor driving it.

A diode across the coil, pointing back towards the supply, gives that current a loop to die away in, holding the spike to a fraction of a volt above the supply. Figure 3 shows the transistor’s side with and without one.

0 V 5 V supply switched off the transistor’s collector over 10 ms

Flyback diode: the coil’s current loops round through the diode instead, so the collector rises only to about 5 V + 0.7 V = 5.7 V, and the relay lets go a moment later.

Figure 3. The voltage on an NPN transistor’s collector as it switches a 5 V relay coil off, with and without a diode across the coil.

What types of relay are there?

Electromechanical relays, with a coil and moving contacts, are the classic kind; reed relays seal small contacts in a glass tube, and solid-state relays switch with semiconductors, such as a triac for AC, and no moving parts.

Solid-state relays are silent and wear-free but drop a little voltage and warm up; latching relays hold their position with no coil current. Relay modules for Arduino add the transistor, the diode and an indicator LED on one board.

How do you work out a relay’s coil current and driver?

To work out a relay’s driver, divide the coil voltage by its resistance for the current, then give the transistor’s base about a tenth of that to switch it fully on.

Example 1: a coil’s current and power

A relay’s coil is rated 5 V, 70 Ω. What current does it draw, and what power does it use?

Given
a 5 V relay with a 70 Ω coil
Find
its coil current and power
Solution
I = V ÷ R = 5 V ÷ 70 Ω = 71.4 mAP = V × I = 5 V × 71.4 mA = 357 mW
Answer
71.4 mA, 357 mW

Example 2: a driver’s base resistor

An NPN transistor switches a 71 mA relay coil from a 5 V microcontroller pin. What base resistor does it need?

Given
a 71 mA relay coil switched by an NPN transistor from a 5 V pin
Find
the base resistor
Solution
Give the base a tenth of the coil current: 71 mA ÷ 10 = 7.1 mAR = (5 V − 0.7 V) ÷ 7.1 mA = 606 ΩThe next standard size down, 560 Ω, gives a little more, so the transistor stays fully on
Answer
560 Ω from the pin to the base

Summary

Key equations

  • I = Vcoil ÷ Rcoil the coil’s current
  • P = Vcoil × I the coil’s power
  • Rb = (Vpin − 0.7 V) ÷ (I ÷ 10) a driver’s base resistor

Key terms

Coil
The electromagnet that works it.
Armature
The hinged plate it pulls.
NO and NC
Normally open and normally closed.
Flyback diode
Catches the coil’s spike.

Practice problems

  1. What makes a relay’s contacts move?

  2. With the coil off, which contact does COM touch?

  3. Why does a relay coil need a diode across it?

  4. A 5 V relay’s coil is 70 Ω. About what current does it draw?

  5. Can an Arduino Uno pin drive that 71 mA coil directly?

FAQ

What is a relay used for?

Letting a small control circuit switch a separate one: lamps, pumps, heaters and motors from a microcontroller, thermostat or timer, and isolating the two.

Can I connect a relay straight to an Arduino?

Not a typical one: its coil draws more than a pin can give. Use a transistor and a flyback diode, or a relay module that has both.

Why does my relay click but the load doesn’t switch?

The load may be on the wrong contact, NC instead of NO, or its circuit isn’t complete through COM. Check each contact with a meter’s continuity test.

What is the difference between a relay and a transistor?

Both let a small signal switch a load. A relay’s contacts are isolated and switch AC or DC, but click and wear; a transistor is silent and fast, but switches DC and shares a connection with its control circuit.

What does SPDT mean on a relay?

Single pole, double throw: one moving contact, COM, that switches between two others, NC and NO. A DPDT relay has two such sets worked together.

What is a solid-state relay?

A relay with no moving parts: an LED inside lights a light-sensitive switch, such as a triac or MOSFET, keeping the two sides isolated.

How do you test a relay?

Measure the coil with a meter: tens to hundreds of ohms is good, OL means a broken coil. Then power the coil and check with the continuity test that COM moves from NC to NO.

What does a relay diagram show?

Its coil, drawn as a box or a loop, beside a switch with COM, NO and NC contacts, often joined by a dashed line to show that the coil moves the switch.