Ugenz Academy/IoT Tutorial

Relays

12 min read2,245 words

Reading progress

Keep learning

Relays

1. Introduction to Relays

A relay is an electrically operated switch that uses an electrical signal to open or close contacts in another circuit.

Relays allow a low-power control circuit to switch a separate circuit that may operate at a higher voltage or current, provided the relay is correctly rated for the application.

Relays are commonly used in home automation, industrial control systems, motor control, automotive electronics, and electrical protection systems.

10pcs SRD-05VDC-SL-C 1 Channel Relay Module Board 5V High Level for Arduino | eBay

리드 릴레이에 대해 알아야 할 것은 무엇입니까?

Relé, 5 pines 12V 30A/40A Relé de automóvil Relé de pin Grado profesional | Walmart en línea

5

Example: An ESP32 can control a suitable relay module to switch a lamp on or off. The ESP32 provides the control signal, while the relay contacts switch the lamp's power circuit.

2. Basic Parts of a Relay

An electromagnetic relay contains several important parts.

Budowa przekaźnika - Zrozum jego działanie krok po kroku

elektryk-fhu.pl

A. Coil

The coil is a wire wound around a core. When electric current flows through the coil, it creates a magnetic field.

The coil requires a specified operating voltage, such as 5 V, 12 V, or 24 V DC, depending on the relay.

B. Iron Core

The iron core strengthens the magnetic field produced by the coil. This helps the relay generate enough magnetic force to move its mechanism.

C. Armature

The armature is a movable metal part attracted by the magnetic field when the coil is energized. Its movement changes the positions of the contacts.

D. Contacts

Contacts are conductive parts that connect or disconnect the external circuit.

The three common contact terminals are:

  • COM (Common): The movable contact's common connection.
  • NO (Normally Open): Disconnected from COM when the relay coil is not energized.
  • NC (Normally Closed): Connected to COM when the relay coil is not energized.

E. Spring

The spring returns the armature to its normal position when the coil is de-energized.

3. Working Principle of a Relay

Most conventional relays used in basic electronics are electromagnetic relays. They work using the magnetic effect of electric current.

The operation can be understood in two states.

State 1

Relay OFF — Coil De-energized

PPT - Developing Fundamental PLC Wiring Diagrams and Ladder Logic Programs PowerPoint Presentation - ID:8960319

slideserve.com

When no current flows through the coil, the magnetic field is absent. The spring keeps the armature in its normal position.

  • COM is connected to NC.
  • COM is disconnected from NO.

State 2

Relay ON — Coil Energized

What Is A Relay And How Does It Work? Wiring Diagrams, DPDT Schematic, And How To Test A Relay Explained

fastturnpcbs.com

When the correct voltage is applied to the coil, current flows and creates a magnetic field. The armature moves and changes the contact positions.

  • COM connects to NO.
  • COM disconnects from NC.

When the coil's power is removed, the spring normally returns the contacts to their original positions.

Important: ON and OFF here describe the relay coil, not necessarily the device connected to its contacts. A load connected through NC may operate when the coil is OFF.

4. Types of Relays

A. Electromagnetic Relay

30-JQC-3F/6V – JCM Electronics

jcmelectronics.com

An electromagnetic relay uses a coil, magnetic field, armature, and mechanical contacts.

Applications:

  • Switching lamps and fans
  • Controlling pumps
  • Automotive electrical systems
  • Industrial control panels

It provides electrical separation between the coil circuit and the switched contact circuit, subject to the relay's specified insulation ratings.

B. Solid-State Relay (SSR)

Snapklik.com : SSR-25DA Solid State Relay DC To AC Input 3-32V DC Output 24-380V AC

snapklik.com

A solid-state relay switches a circuit using semiconductor devices instead of moving mechanical contacts.

Advantages:

  • No mechanical contact movement
  • Silent switching
  • Fast operation
  • No mechanical contact wear

Limitations:

  • Can generate heat
  • May have leakage current when OFF
  • Must be selected for the correct AC or DC load type

C. Reed Relay

Littelfuse - MDSR-7-10-20 - Reed Switch, MDSR-7 Series, SPST-NO, Glass Body, 350mA, 140V - RS

us.rs-online.com

A reed relay uses small magnetic contacts enclosed in a sealed glass tube. A magnetic field causes the contacts to open or close.

Applications: Signal switching, measurement equipment, and communication circuits.

D. Latching Relay

Venda DR25E01 DC 5V 9V 12V 24V 3-5A Flip-Flop Latch DPDT Relay Module Bistable Self-locking Switch Low Pulse Trigger Board for Motor LED PLC - Banggood Brasil-arrival notice-arrival notice

br.banggood.com

A latching relay retains its last switched state after its operating pulse or coil power is removed. A suitable pulse or reset mechanism changes it to the other state.

Applications: Energy meters, remote switching, and systems where reduced coil power consumption is useful.

E. Time-Delay Relay

A time-delay relay switches its contacts according to a specified timing function.

For example, it can turn on a motor after a delay or keep a fan running for a set period after a machine stops.

F. Automotive Relay

Waterproof Automotive Relay 12V 24V – Reliable Performance and Robust – InterCyprus Trading Ltd

intercyprus.com

Automotive relays are designed for vehicle electrical systems and are commonly used to control headlights, horns, fans, and other electrical loads.

Their contact ratings, coil voltage, pin arrangement, and protection features must match the application.

5. Relay Terminals and Pin Configuration

A common five-terminal electromagnetic relay has two coil terminals and three contact terminals.

TerminalFunction
Coil 1 and Coil 2Supply the relay coil's specified voltage
COMCommon contact terminal
NOConnects to COM when the coil is energized
NCConnects to COM when the coil is de-energized

A typical five-pin relay may have a pinout such as 85 and 86 for the coil, 30 for COM, 87 for NO, and 87a for NC. However, pin assignments vary, so check the relay's diagram or datasheet before wiring it.

Some four-pin relays have only COM, NO, and the two coil terminals, without an NC contact.

6. Difference Between NO and NC Contacts

FeatureNO (Normally Open)NC (Normally Closed)
Coil OFFOpenClosed
Coil ONClosedOpen
Load behaviorCan turn on when the coil energizesCan turn off when the coil energizes
Common useTurn a load on when commandedKeep a load connected in the normal state

Example: If a lamp is connected between COM and NO, the lamp is normally OFF and turns ON when the relay coil is energized.

If the lamp is connected between COM and NC, it is normally ON and turns OFF when the coil is energized, assuming the load has its own power supply.

7. Relay Circuit Using a Transistor

A microcontroller GPIO pin generally should not drive a conventional relay coil directly because the coil may require more current than the pin can safely supply.

A common solution is to use a transistor or MOSFET as a driver.

avr - Transistor to run relay - Electrical Engineering Stack Exchange

electronics.stackexchange.com

A basic DC relay driver circuit contains:

  • A relay with a coil voltage matched to the supply
  • An NPN transistor or suitable MOSFET
  • A base or gate resistor where required
  • A flyback diode across a DC relay coil, when appropriate
  • A power supply capable of supplying the coil current
  • A control signal from the microcontroller

How it works

  1. The microcontroller sends a control signal to the transistor or MOSFET.
  2. The transistor or MOSFET switches the coil current.
  3. The energized coil produces a magnetic field.
  4. The relay contacts change position.
  5. The connected load switches ON or OFF.

When the coil is switched off, its magnetic field collapses and can produce a voltage spike. A flyback diode across a DC coil provides a path for this current and helps protect the driver. The diode must be connected with the correct polarity.

A relay module may already include a driver transistor, diode, and other supporting components. Check its specifications before adding extra components.

8. Relay with ESP32

An ESP32 can control a relay module for automation projects, but the module must be compatible with the ESP32's GPIO voltage and current limits.

A typical connection for a compatible module is:

ESP32Relay module
GPIO pinIN
GNDGND
Suitable supplyVCC, according to the module specifications

The load is connected through the relay's COM and NO or NC contacts.

For example, an ESP32-based room automation system can switch a lamp through a properly rated relay module. The ESP32 sends only the control signal; the relay contacts handle the load circuit.

Important: Relay modules differ. Some use active-LOW inputs, some use active-HIGH inputs, and their coil supplies and input circuits vary. Do not assume that every module can be powered directly from an ESP32's 3.3 V pin.

9. Relay Ratings and Specifications

Before selecting a relay, understand its main specifications.

SpecificationMeaning
Coil voltageVoltage required to operate the coil
Coil currentCurrent consumed by the coil
Contact voltage ratingMaximum specified switching voltage for a particular type of load
Contact current ratingPermitted contact current under specified conditions
Contact arrangementWhether the relay has NO, NC, or changeover contacts
Switching timeTime required for contacts to change state
Electrical lifeExpected number of switching operations under specified conditions
Insulation ratingElectrical separation capability between relevant parts of the relay

Example

A relay may have a 5 V DC coil and contacts rated for a specified AC or DC load. The 5 V rating describes the coil, not the voltage that the relay contacts must switch.

The actual load must remain within the relay's ratings. Motors, pumps, and other inductive loads can have high starting currents, so their switching requirements may differ significantly from those of a resistive load.

10. Advantages of Relays

  1. Electrical isolation: The coil and contacts can provide isolation between the control and load circuits.
  2. High-load switching: Properly rated relays can switch loads that a microcontroller cannot drive directly.
  3. Simple operation: Electromagnetic relays have a straightforward operating principle.
  4. Multiple contacts: Some relays can switch more than one circuit at a time.
  5. Flexible applications: Relays are available for many coil voltages, contact arrangements, and switching requirements.

11. Disadvantages of Relays

  1. Mechanical wear: Mechanical contacts and moving parts wear out over time.
  2. Switching noise: Electromagnetic relays often produce a clicking sound.
  3. Slower switching: Mechanical relays are generally slower than semiconductor switches.
  4. Coil power consumption: The coil consumes power while energized, except for certain latching designs.
  5. Contact arcing: Switching certain loads can create arcs that damage contacts.
  6. Size: Some relays occupy more space than equivalent semiconductor switching devices.

12. Relay vs. Transistor vs. MOSFET

FeatureRelayTransistorMOSFET
Operating methodMechanical contacts or solid-state switching, depending on typeSemiconductorSemiconductor
Moving partsIn mechanical relaysNoNo
Switching speedUsually slowerUsually fastUsually fast
Electrical isolationAvailable between coil and contacts in suitably rated relaysNot inherently providedNot inherently provided
AC load switchingPossible with a suitably rated relayDepends on circuit designDepends on device and circuit design
Typical applicationSwitching separate load circuitsSignal amplification and switchingEfficient electronic switching and power control

A mechanical relay is useful when its contact arrangement and isolation characteristics are needed. A transistor or MOSFET is often preferable for fast, frequent, or efficient electronic switching.

13. Applications of Relays

Relays are widely used in:

  • Home automation systems
  • Room lighting control
  • Water pumps and motor control
  • Automotive headlights and horns
  • Industrial machines
  • HVAC equipment
  • Alarm and control systems
  • Electrical switching and protection circuits
  • Microcontroller-based automation projects

14. Safety Precautions

  • Always select a relay with appropriate voltage and current ratings for the load.
  • Never assume that a relay's low-voltage coil makes its contact circuit safe to touch.
  • Mains AC wiring can cause fatal electric shock. Use suitable enclosures, insulation, fusing, grounding, and correctly rated components.
  • Keep low-voltage control wiring appropriately separated from hazardous-voltage circuits.
  • Use a flyback diode or other suitable suppression method for DC coils where required.
  • Do not connect an inductive load such as a motor without considering its starting current and switching characteristics.

In summary: A relay is an electrically controlled switch. An electromagnetic relay uses a coil and magnetic force to change contact positions, allowing a control circuit to switch another electrical circuit. Relays are important components in automation, motor control, and many other electronic systems.

Keep learning. Keep building. Keep growing.

© 2026 Ugenz Academy