Skip to content

Actuators · Relay

5V Relay Module (1-Channel, SRD-05VDC-SL-C)

Let a 5 V or 3.3 V pin switch a lamp, pump, fan or solenoid on its own supply, with COM, NO and NC screw terminals.

Updated November 25, 2026 2 board guides
5V Relay Module (1-Channel, SRD-05VDC-SL-C)

A relay module is the simplest way to let a microcontroller turn something bigger on and off: a 12 V pump, an LED strip, a solenoid lock, a fan, or (carefully) a mains lamp. The Arduino never touches the load. It only energises a small coil, and the coil pulls a metal contact that closes a completely separate circuit.

The common blue 1-channel module carries a Songle SRD-05VDC-SL-C relay, a transistor to drive its coil, a flyback diode, a status LED and, on most versions, an optocoupler. That extra circuitry is why you can connect it straight to a GPIO pin instead of building the driver yourself. This page explains what each part does, how to wire the load side, why most modules switch ON when the input is LOW, and what changes on a 3.3 V ESP32.

5V Relay Module at a glance

Specifications

Relay
Songle SRD-05VDC-SL-C (or equivalent)
Coil voltage
5 V DC (operates from about 3.75 V)
Coil current
about 70–75 mA while ON (coil ≈ 70 Ω)
Contact rating (relay)
10 A at 250 V AC, 10 A at 30 V DC
Practical module limit
about 5 A continuous; PCB traces and screw terminals are the weak point
Contact form
SPDT: COM switches between NC and NO
Input (IN) current
about 1–5 mA, depending on optocoupler and LED
Trigger
usually active LOW; some boards have an H/L jumper
Switching time
about 10 ms to operate, 5 ms to release
Isolation
optocoupler versions, with the JD-VCC jumper removed

Relay figures from the Songle SRD datasheet. Module limits vary between makers, so treat 10 A as the relay's rating, not the board's.

How a relay module works

The input side and the switched side are two separate circuits. On the left, your microcontroller drives the IN pin. On most modules IN does not drive the coil directly: it lights the LED inside a PC817 optocoupler, the optocoupler turns on an NPN transistor, and the transistor lets about 70 mA flow through the relay coil. A flyback diode across the coil absorbs the voltage spike when the coil switches off, which would otherwise destroy the transistor.

When the coil is energised it pulls the moving contact, COM, away from NC (normally closed) and onto NO (normally open). You hear that as the familiar click.

Inside a 5 V relay module: IN drives an optocoupler, the optocoupler switches a transistor, the transistor powers the coil, and the coil moves COM from NC to NO

Relay module pinout

PinSideWhat it does
VCCControl5 V supply for the coil driver and LED
GNDControlGround, shared with the microcontroller
INControlSignal from a GPIO pin. LOW turns the relay ON on active-LOW boards
COMLoadCommon contact: connect one wire of the load circuit here
NOLoadNormally open: connected to COM only while the relay is ON
NCLoadNormally closed: connected to COM while the relay is OFF
JD-VCCJumperSeparate coil supply on optocoupler boards (jumpered to VCC by default)

NO or NC: which terminal do you use?

Think of the relay as a switch placed in one wire of the load circuit. Break the positive wire of the load, connect the supply side to COM, and connect the load side to NO or NC:

  • NO (normally open) is the usual choice. The load is OFF until your code turns the relay ON, and it switches OFF again if the board resets, loses power or crashes. Use it for pumps, heaters, motors and lights.
  • NC (normally closed) keeps the load ON unless the relay is energised. Use it when "on" must be the safe default, such as a fan that should keep running if the controller fails.

Leave the unused terminal empty. The load's own supply stays separate from the Arduino; only the coil side shares a ground with it.

Switching a 12 V load: +12 V to COM, NO to the load, the load back to the supply. The Arduino only connects to VCC, GND and IN

Active LOW, active HIGH and the start-up click

On most blue modules the optocoupler LED sits between VCC and IN. Pulling IN to ground lets current flow, so LOW = relay ON and HIGH = relay OFF. That surprises almost everyone the first time: the relay turns on as soon as you call pinMode(pin, OUTPUT), because a fresh output pin starts LOW.

The fix is to write HIGH before making the pin an output, so the relay never sees a LOW at start-up:

sketch.ino
const int RELAY_PIN = 7;

void setup() {
  digitalWrite(RELAY_PIN, HIGH);  // OFF on an active-LOW module, set before pinMode
  pinMode(RELAY_PIN, OUTPUT);
}

Some boards have a three-pin H/L jumper that selects the trigger level. With it on H, the logic flips (HIGH = ON). If your relay clicks the opposite way to your code, check the jumper before changing the sketch.

Warning

Mains voltage can kill. A 230 V or 120 V load needs an enclosure, insulated and strain-relieved cable, a fuse, and no exposed screw terminals. Never touch the board while mains is connected. If you are learning, practise with a 12 V lamp or pump first: the wiring and code are identical.

What can a relay module switch?

  • 12 V LED strip, lamp

    Suitable?
    Yes
    Notes
    Check the strip's current; stay under about 5 A
  • 12 V pump or fan

    Suitable?
    Yes
    Notes
    Motors draw several times their rated current at start-up
  • Solenoid lock or valve

    Suitable?
    Yes
    Notes
    Add a flyback diode across the solenoid itself
  • Mains lamp (under 100 W)

    Suitable?
    With care
    Notes
    Enclosure, fuse and proper cable required
  • Kettle, heater, iron

    Suitable?
    No
    Notes
    8–10 A continuous overheats module traces and terminals
  • Fast PWM dimming

    Suitable?
    No
    Notes
    A relay is on/off only; use a MOSFET for PWM
  • Hundreds of switches per hour

    Suitable?
    No
    Notes
    Contacts wear out; use a MOSFET or solid-state relay

Relay module variants

Which relay board do you have?

  • 1-channel with optocoupler

    How to recognise it
    PC817 chip and a 3-pin JD-VCC / VCC / GND header
    What changes
    Can isolate the coil supply; best choice for ESP32
  • 1-channel without optocoupler

    How to recognise it
    Only a transistor, no PC817, no JD-VCC header
    What changes
    IN drives the transistor directly; often active HIGH
  • 2, 4 or 8-channel boards

    How to recognise it
    One IN pin per relay
    What changes
    Each energised relay adds about 70 mA: power the coils separately
  • H/L trigger boards

    How to recognise it
    Jumper labelled H and L next to each input
    What changes
    Choose active HIGH or active LOW
  • Solid-state relay (SSR)

    How to recognise it
    Black block, no click, often marked 'SSR'
    What changes
    Silent and fast, but AC-only types won't switch DC

Troubleshooting

  • Relay clicks on at power-up

    Likely cause
    Active-LOW module and the pin starts LOW
    Fix
    Write HIGH before pinMode(OUTPUT)
  • LED lights but no click

    Likely cause
    Coil supply too weak
    Fix
    Power VCC (or JD-VCC) from 5 V that can supply 100 mA per relay
  • Board resets when relay switches

    Likely cause
    Coil current or load noise dipping the 5 V rail
    Fix
    Separate coil supply via JD-VCC, short load wires, flyback diode on the load
  • Relay never turns off on ESP32

    Likely cause
    3.3 V HIGH is not enough to switch off a 5 V active-LOW input
    Fix
    Remove the JD-VCC jumper and power VCC from 3.3 V (see the ESP32 guide)
  • Load works backwards

    Likely cause
    Wired to NC instead of NO, or H/L jumper set
    Fix
    Move the load wire to NO, or flip the jumper
  • Contacts welded shut

    Likely cause
    Load current or inrush too high
    Fix
    Replace the relay; use a bigger relay or an SSR for that load

Frequently asked questions

Can a 5 V relay module run from 3.3 V? The control side can, the coil cannot. The coil needs about 5 V to pull in reliably, so keep 5 V on the coil (VCC or JD-VCC) and drive only the input from 3.3 V.

Why does my relay buzz instead of clicking? The coil is getting too little voltage or current, often from a weak USB port or a long thin wire. Measure 5 V at the module while the relay is ON.

Do I need a diode on the module? The module already has one across its own coil. If the load is inductive (a solenoid, motor or another relay), put a diode across the load as well, cathode to positive.

Relay or MOSFET? A MOSFET is better for DC loads you switch often or dim with PWM. A relay is better for AC loads, for loads that need full isolation, and for beginners who want a switch that is clearly on or off.

Tip

Pick your board guide: 5V relay module with Arduino Uno covers wiring, a timed switch and a push-button toggle. 5V relay module with ESP32 covers the JD-VCC wiring that makes a 5 V relay work properly with 3.3 V logic.

Wiring & code

Board integration

Library

None needed by Arduino core

No library required: the sketches use digitalWrite() and digitalRead(), which are built into Arduino.

This guide wires a 1-channel 5 V relay module to an Arduino Uno, switches it on a timer, then adds a push button that toggles the relay on each press. Because the Uno is a 5 V board, the module connects directly: no level shifting, no extra transistor. Read the relay module overview first if NO, NC and active LOW are new to you.

Parts

PartQtyNotes
Arduino Uno (or Nano)1Any 5 V Arduino works the same way
5 V 1-channel relay module1SRD-05VDC-SL-C type
Push button1For the toggle example
Jumper wires5Female-to-male for the module header
Test load1A 12 V lamp or LED strip with its own supply

Step 1. Wire the control side

Unplug the USB cable while wiring. The relay module needs three wires from the Uno:

Wiring: relay module to Arduino Uno

Module pinUno pinNote
VCC5VPowers the coil driver: about 75 mA when ON
GNDGNDCommon ground
IND7Any digital pin works; D7 is clear of serial and SPI
  1. 1Red wire: Uno 5V to module VCC.
  2. 2Black wire: Uno GND to module GND.
  3. 3Signal wire: Uno D7 to module IN.
  4. 4Leave the screw terminals empty for now. Test the click first, then add a load.

Tip

One Uno can power one or two relays from USB. Each energised relay draws about 75 mA. For four or more, power the module from a separate 5 V supply and join its ground to the Uno's GND.

Step 2. Click the relay on a timer

Upload this sketch. The relay should click on for two seconds, off for two seconds, and the module's red LED should follow it. The Serial Monitor at 9600 baud prints the state.

sketch.ino
// 5V relay module on Arduino Uno: timed on/off
// Most modules are active LOW: LOW = relay ON, HIGH = relay OFF.
const int RELAY_PIN = 7;
const bool ACTIVE_LOW = true;   // set to false for active-HIGH boards

void relayOn()  { digitalWrite(RELAY_PIN, ACTIVE_LOW ? LOW : HIGH); }
void relayOff() { digitalWrite(RELAY_PIN, ACTIVE_LOW ? HIGH : LOW); }

void setup() {
  relayOff();                 // set the OFF level first...
  pinMode(RELAY_PIN, OUTPUT); // ...so the relay doesn't click at start-up
  Serial.begin(9600);
}

void loop() {
  relayOn();
  Serial.println("Relay ON");
  delay(2000);

  relayOff();
  Serial.println("Relay OFF");
  delay(2000);
}

If the relay is ON when the sketch says OFF, your board is active HIGH. Change ACTIVE_LOW to false; nothing else in the sketch changes.

Step 3. Toggle it with a push button

Wire a push button between D2 and GND. The sketch uses the Uno's internal pull-up, so no resistor is needed: the pin reads HIGH normally and LOW while the button is pressed. Each press flips the relay.

Extra wiring for the button

Button legUno pinNote
Leg 1D2INPUT_PULLUP, reads LOW when pressed
Leg 2GNDUse legs on opposite sides of the button
sketch.ino
// Push button toggles a 5V relay module (active LOW)
const int RELAY_PIN  = 7;
const int BUTTON_PIN = 2;

bool relayIsOn = false;
bool lastReading = HIGH;
unsigned long lastChange = 0;

void applyRelay() {
  digitalWrite(RELAY_PIN, relayIsOn ? LOW : HIGH);
}

void setup() {
  digitalWrite(RELAY_PIN, HIGH);   // start OFF
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  bool reading = digitalRead(BUTTON_PIN);

  // react to a new press, ignoring contact bounce for 50 ms
  if (reading == LOW && lastReading == HIGH && millis() - lastChange > 50) {
    relayIsOn = !relayIsOn;
    applyRelay();
    Serial.println(relayIsOn ? "Relay ON" : "Relay OFF");
    lastChange = millis();
  }
  lastReading = reading;
}

Step 4. Add the load

With the Uno unplugged, put the relay in the positive wire of your 12 V load: supply positive to COM, NO to the load's positive, and the load's negative straight back to the supply's negative. The relay now switches the lamp exactly as the LED on the module shows. For a load that must stay on if the Uno fails, use NC instead of NO.

Warning

Keep mains for later. The sketch and wiring are the same for a 230 V lamp, but mains needs an enclosure, a fuse and insulated terminals. Learn with a 12 V load first.

Troubleshooting

  • Relay clicks once at reset

    Likely cause
    Pin LOW before setup() runs
    Fix
    Expected during upload; the HIGH-before-pinMode line stops it after start-up
  • LED on, no click

    Likely cause
    Weak 5 V supply
    Fix
    Use a powered USB port or a separate 5 V supply for the module
  • Uno resets when the load switches

    Likely cause
    Load noise on the shared supply
    Fix
    Separate load supply, short wires, diode across inductive loads
  • Button toggles twice

    Likely cause
    Contact bounce
    Fix
    Increase the 50 ms debounce to 80 ms
  • Works backwards

    Likely cause
    Active-HIGH module or load on NC
    Fix
    Set ACTIVE_LOW = false, or move the load to NO

Where to go next

Step-by-step

Board guides