4DVolt

5 V relay module: pinout and wiring

A relay module lets an Arduino or ESP32 switch larger loads such as lamps, pumps and fans. See the pinout, when it activates on a low or high level, how to wire the load and try it in the simulator.

1-channel relay module with COM, NO and NC terminals
5 V relay module

Specifications

Coil supply
5 V (3.3 V, 12 V and 24 V modules also exist)
Coil current
≈ 70 mA when on
Control signal
3.3 V or 5 V on the IN pin
Contacts
SPDT: COM, NO (normally open) and NC (normally closed)
Max load
10 A at 250 V AC or 10 A at 30 V DC (typical)
Isolation
Optocoupler on many modules
Activation
Low level (most common) or high
Indicator
LED lit when the coil is energized

Pinout

The module has two groups: three control pins on one side (VCC, GND, IN) and three screw terminals for the load on the other (NO, COM, NC).

Control (3 pins)

1 VCC Coil supply, 5 V
2 GND Ground, shared with the Arduino
3 IN Control signal from a digital pin

Load (3 terminals)

1 NO Normally open: closes with COM when the relay turns on
2 COM Common: load input
3 NC Normally closed: connected to COM while the relay is off

Relay module simulator

Choose the level that activates the module and the level on the IN pin to see whether the coil turns on and which contact closes.

Module activates on
Level on the IN pin
Coil
Module LED
Closed contact
Lamp on NO

With the coil energized, COM switches from NC to NO. The example lamp is wired between COM and NO, so it only lights when the relay turns on.

How to wire it

Connect VCC to 5 V, GND to ground and IN to a digital pin, for example D7 on the Arduino Uno. The module LED lights when the coil is energized.

For the load, run the live wire (or the positive, in DC) through COM. Take the wire to the lamp from NO if it should light when the relay turns on, or from NC if it should stay lit while the relay is off. The other lamp wire goes straight to the mains or the supply.

Most blue modules are active low: the relay turns on with IN at LOW and off with IN at HIGH. Some modules are active high, and many have a jumper to choose. Test with the coil and no load before connecting the lamp.

Be careful when wiring a 120 V or 240 V load: the terminal is exposed. Unplug before touching the wiring and use an insulated enclosure.

To switch an inductive DC load such as a motor or solenoid, add a flyback diode across the load to absorb the voltage spike on turn-off.

Example code (Arduino)

Sketch that turns the relay on and off every 2 seconds, for an active-low module.

#define RELAY_PIN 7

void setup() {
  digitalWrite(RELAY_PIN, HIGH);  // off (active-low module)
  pinMode(RELAY_PIN, OUTPUT);
}

void loop() {
  digitalWrite(RELAY_PIN, LOW);   // relay on
  delay(2000);
  digitalWrite(RELAY_PIN, HIGH);  // relay off
  delay(2000);
}

Common mistakes

  • Setting the pin as output before setting its level: on active-low modules the relay clicks when the Arduino powers up. Set HIGH first and call pinMode afterwards.
  • Powering the module from the Arduino 5 V pin with several relays on: the coil current can brown out the board. Use a separate supply and join the grounds.
  • Swapping NO and NC and thinking the relay is inverted: check which terminal the load is on.
  • Forgetting the flyback diode when driving DC motors and solenoids.
  • Wiring a mains load without insulating the terminals or unplugging first.

Always check the manufacturer's datasheet for your exact model: pin order can vary between modules.

Frequently asked questions

How do I connect a relay module to Arduino?

Connect VCC to 5 V, GND to ground and IN to a digital pin. For the load use COM and NO (on when the relay is on) or COM and NC (off when the relay is on).

What are NO, NC and COM?

COM is the common contact. NO (normally open) closes with COM when the relay turns on. NC (normally closed) stays connected to COM while the relay is off and opens when it turns on.

Why does the relay turn on with LOW?

Many modules use a transistor and an optocoupler that conduct when IN is pulled to zero, so the relay is active low. Check the marking on your module.

Can I use the relay with an ESP32?

Yes, as long as the module accepts a 3.3 V signal on IN. Power the coil from 5 V and join the grounds. If the relay does not switch, use a module with an optocoupler and a separate VCC.

Other components