Part

Relay board, two channels

Two relays with optocouplers, active low: LOW on IN is on.

See every part
  • 10 pins
  • 4 settings
  • In 8 projects
Drawn live by the editor's own code, at the size you see it.
At a glance

The Relay board, two channels in brief

What it is, and every setting the properties panel gives it.

The two-channel relay board carries two SRD-05VDC relays, each behind an optocoupler, with a GND, IN1, IN2 and VCC header and a three-screw terminal per channel for NO, COM and NC. Besides switching two loads, it is the cheap way to reverse a DC motor: wire the two changeover contacts as an H-bridge and the polarity flips with which relay is pulled in. The input side is what confuses people. Each IN pin sinks the opto’s LED to ground, so the board is active low by default: digitalWrite(pin, LOW) turns a channel on, while HIGH or an unwired pin turns it off. A sketch that sets pinMode to OUTPUT before writing HIGH clicks both relays on, so write HIGH first. Mokxi gives each channel the SRD coil’s 10 millisecond pull-in and 5 millisecond release, a red LED while energized, and a trigger property for the rarer active-high boards. Power VCC from 5 volts, since under 4 volts no coil pulls in, and the coil property covers 12 and 24 volt versions. The JD-VCC jumper, coil current and contact bounce are not modeled.

Family
Outputs
Pins
10
trigger
low (or high)
low (the default, as on nearly every board sold) or high.
coil
5V (or 12V, 24V)
5V (the default), 12V or 24V, the SRD relay the board carries. pull_ms and
pull_ms
10
release_ms
5
10 and 5 ms, the SRD-05VDC's times.
Pins

10 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
Role
What it does
GND
Input or output
Ground.
IN1
Input
IN2
Input
VCC
Input or output
The coils' supply, 5 V unless coil says 12 or 24 V.
NO1
Input or output
Each channel's changeover contact.
COM1
Input or output
Each channel's changeover contact.
NC1
Input or output
NO2
Input or output
COM2
Input or output
NC2
Input or output
How to use it

How to use a 2 channel relay module with an Arduino

In the relays reverse a motor example, IN1 and IN2 go to pins 6 and 7, VCC to 5 volts and GND to ground. Each NO contact is on 5 volts, each NC on ground, and the motor sits between COM1 and COM2. With neither channel on, both motor leads are grounded and it brakes; pull one channel in and that lead goes to 5 volts.

The board is active low, so the sketch hides it behind a relayOn() helper and writes each pin HIGH before pinMode(pin, OUTPUT). To reverse, release one channel before pulling in the other, as the sketch does with a 600 millisecond pause; both in at once just puts 5 volts on both leads, which is a brake again rather than a short.

Part pin
Board pin
IN1
Pin 6
IN2
Pin 7
VCC
5 V
GND
GND
COM1, COM2
The motor’s two leads
NO1, NO2
5 V
NC1, NC2
GND

On an ESP32 the inputs can come straight from 3.3 volt pins, but VCC still needs 5 volts, or no coil pulls in.

Arduino Uno: relays reverse a motorlive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Active low, without the click at power-up
void relayOn(int pin, bool on) {
  digitalWrite(pin, on ? LOW : HIGH);
}
void setup() {
  for (int pin = 6; pin <= 7; pin++) {
    digitalWrite(pin, HIGH);   // off, before it is an output
    pinMode(pin, OUTPUT);
  }
}
void loop() {}
How it is modeled

What is true about the Relay board, two channels, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

Everything the single module gets right, per channel: the 10 ms pull-in and 5 ms release, the arm touching neither contact while it travels, and no coil pulling in under 4 V of VCC on a 5 V board. Each channel's red LED lights while its coil is energized.

Not modeled

The optocoupler as a circuit: the input is a logic level against half of VCC, where a real one is an LED that a 3.3 V high on a 5 V board may still half light. The JD-VCC jumper that lets the coils run from their own supply is not brought out: VCC powers everything. Coil current (about 70 mA a channel, 280 mA for four and 560 mA for eight, more than a USB-powered board likes), contact bounce, and the 10 A contact rating.

From Relay boards: two, four and eight channels, in full.

Projects

See the Relay board, two channels in a project

8 built-in projects use it. Each opens in the editor, already wired.

Boards

The boards it is shown on

Each of these 2 boards has a built-in project with the Relay board, two channels in it.

Wire up the Relay board, two channels

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.