Relay board, two channels
Two relays with optocouplers, active low: LOW on IN is on.
- 10 pins
- 4 settings
- In 8 projects
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) orhigh.- coil
- 5V (or 12V, 24V)
5V(the default),12Vor24V, the SRD relay the board carries.pull_msand- pull_ms
- 10
- release_ms
- 5
- 10 and 5 ms, the SRD-05VDC's times.
10 pins
Named as the editor names them, so a wire lands where you expect it.
coil says 12 or 24 V.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.
On an ESP32 the inputs can come straight from 3.3 volt pins, but VCC still needs 5 volts, or no coil pulls in.
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() {}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.
See the Relay board, two channels in a project
8 built-in projects use it. Each opens in the editor, already wired.
The boards it is shown on
Each of these 2 boards has a built-in project with the Relay board, two channels in it.
The rest of the bench
Every one of these is drawn and simulated the same way.
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.