Component guide · Beginner · 4 min read
Relay Modules

How to Switch Lights and Appliances Safely
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
A relay module is an electrically controlled switch that lets a microcontroller turn a separate circuit on or off, such as a 12 V pump or a mains lamp. A small current energises a coil that moves the contacts: COM connects to NO (normally open) when the relay is on, and to NC (normally closed) when off. Most modules switch on when their input is pulled low.
Key specs at a glance
- Coil voltage
- 5 V or 12 V module versions (3.3 V versions exist)
- Coil current
- About 70 to 90 mA per 5 V relay
- Contact rating (relay body)
- Commonly 10 A at 250 V AC / 30 V DC (SRD-05VDC type)
- Terminals
- COM, NO, NC
- Input logic
- Usually active-low (IN pulled to GND = on); some have an H/L jumper
- Isolation
- Optocoupler modules with JD-VCC jumper separate coil and logic power
This part is often wired to 230 V mains. Do all wiring with the plug pulled out, keep mains wires inside a closed box with strain relief, add a fuse, and never touch the board while it is plugged in. If you are new to mains wiring, have an electrician check it before you switch on.
How a relay module works
A relay is a coil and a spring-loaded switch. Current through the coil creates a magnetic field that pulls the switch across with an audible click. The module adds a transistor so a microcontroller pin can drive the 70 to 90 mA coil, a flyback diode to absorb the coil's voltage spike, an LED, and screw terminals.
Because the switched circuit only touches the contacts, the relay isolates your 5 V electronics from the load, as long as the module is built and wired properly.
COM, NO and NC: which terminal to use
| Terminal | Meaning | Use it when |
|---|---|---|
| COM | Common, the moving contact | Always used: one side of the load circuit |
| NO | Normally open: connected to COM only when the relay is on | The load should be off by default (lights, pumps) |
| NC | Normally closed: connected to COM when the relay is off | The load should stay on if the controller fails (fail-safe fans, alarms) |
- COM
- Meaning:
- Common, the moving contact
- Use it when:
- Always used: one side of the load circuit
- NO
- Meaning:
- Normally open: connected to COM only when the relay is on
- Use it when:
- The load should be off by default (lights, pumps)
- NC
- Meaning:
- Normally closed: connected to COM when the relay is off
- Use it when:
- The load should stay on if the controller fails (fail-safe fans, alarms)
Wiring a relay module to Arduino or ESP32
- VCC to 5 V, GND to ground, IN to a digital pin.
- Many modules are active-low:
digitalWrite(pin, LOW)turns the relay on. Set the pin HIGH in setup() before making it an OUTPUT to avoid a click at boot. - ESP32 and Pico: many 5 V modules do not switch reliably from a 3.3 V pin, and some idle their input at 5 V. Use a module rated for 3.3 V logic, or an optocoupler module with JD-VCC (see below).
JD-VCC isolation: on optocoupler modules, remove the JD-VCC jumper, feed 5 V to JD-VCC for the coils from a separate supply, and feed the module's VCC from your board's 3.3 V or 5 V. The input side then never shares current with the coils.
const int RELAY = 7;
void setup() {
digitalWrite(RELAY, HIGH); // off before enabling the output
pinMode(RELAY, OUTPUT);
}
void loop() {
digitalWrite(RELAY, LOW); // relay ON
delay(2000);
digitalWrite(RELAY, HIGH); // relay OFF
delay(2000);
}How much can a relay module really switch?
The "10A 250VAC" printed on the blue relay is the rating of the contacts, not the whole module. PCB traces, terminals and wire size often limit cheap modules to a few amps. Motors, compressors and LED drivers draw inrush currents many times their running current.
As a rule, run module relays at no more than half their printed rating, and use a contactor or a properly rated SSR for heaters, pumps and motors above about 5 A.
Mechanical relay vs solid-state relay (SSR)
| Mechanical relay | Solid-state relay | |
|---|---|---|
| Switching | Moving contacts, clicks | Semiconductor, silent |
| Speed and life | Slow, contacts wear (about 100,000 operations) | Fast, no wear |
| Loads | AC or DC | AC SSRs switch AC only; DC SSRs for DC |
| Off state | Fully open | Small leakage current |
| Heat | Low | Needs a heatsink above a few amps |
- Switching
- Mechanical relay:
- Moving contacts, clicks
- Solid-state relay:
- Semiconductor, silent
- Speed and life
- Mechanical relay:
- Slow, contacts wear (about 100,000 operations)
- Solid-state relay:
- Fast, no wear
- Loads
- Mechanical relay:
- AC or DC
- Solid-state relay:
- AC SSRs switch AC only; DC SSRs for DC
- Off state
- Mechanical relay:
- Fully open
- Solid-state relay:
- Small leakage current
- Heat
- Mechanical relay:
- Low
- Solid-state relay:
- Needs a heatsink above a few amps
Mains safety
Indian mains is 230 V AC at 50 Hz and can kill. If you are not trained to wire mains, use low-voltage loads (5 to 24 V DC) or ready-made certified smart plugs. If you do switch mains: put the relay in a closed, insulated enclosure, switch the live (phase) wire, fuse the circuit, keep low-voltage and mains wiring physically apart, and never work on it while plugged in.
Try it: RL time constant calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Driving a relay coil straight from a microcontroller pin without a transistor (modules include one; bare relays do not).
- Forgetting that the module is active-low and getting the opposite behaviour.
- Trusting the 10 A printed on the relay for the whole module.
- Using a 5 V relay module with a 3.3 V board without checking that it switches reliably.
- Switching inductive DC loads (motors, solenoids) without a flyback diode across the load.
Frequently asked questions
What is the difference between NO and NC on a relay?
NO (normally open) connects to COM only when the relay is energised. NC (normally closed) connects to COM when the relay is off. Use NO for loads that should be off by default.
Can I use a 5 V relay module with an ESP32?
Sometimes. Power the module from 5 V, but check that a 3.3 V input switches it reliably. Optocoupler modules with a JD-VCC jumper, or modules labelled 3.3 V compatible, are the safe choice.
Why does my relay module turn on when the pin is LOW?
Most modules are active-low: the input pulls current through an LED or optocoupler to ground. Write LOW for on and HIGH for off, or move the H/L jumper if your module has one.
Can a relay module switch a 230 V appliance?
The relay contacts are usually rated for 250 V AC, but a cheap module's tracks and terminals limit current, and safe enclosure and wiring are essential. For anything above a light bulb, use a properly rated relay or contactor.
Should I choose an SSR or a mechanical relay?
Choose an SSR for frequent, silent switching of AC loads such as heaters. Choose a mechanical relay for DC loads, rare switching or when you need a fully open contact.
Parts for this guide
Terms in this guide
Projects that use it
Put this into practice: 161 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- SRD series relay datasheet (Songle)
- PC817 optocoupler datasheet (Sharp)
- IS 732 wiring practice guidance (Bureau of Indian Standards) for mains installations
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.



