Parts

Relay boards: two, four and eight channels

The green boards with a row of blue relays, one screw terminal per relay and a control header at the end. Aliases: 8 channel relay module, 12 V relay module.

Each channel is the single relay module, and the boards add one thing everybody trips over: they are active low.

Pins

Pin What it does
GND Ground.
IN1 to IN8 One input per channel. LOW switches the channel on.
VCC The coils' supply, 5 V unless coil says 12 or 24 V.
NO1, COM1, NC1 and so on Each channel's changeover contact.

Properties

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

12 V and 24 V boards

The same boards are sold with SRD-12VDC and SRD-24VDC relays, and then VCC must be that supply: an SRD coil pulls in at 75 percent of its rating, so a 12 V board needs 9 V and a 24 V board 18 V, and on 5 V nothing clicks. The inputs are still read against half of VCC, so a 5 V pin's HIGH is under the 6 V a 12 V board wants: an active-low 12 V board stays on. Drive each input through an NPN transistor that pulls it to ground and otherwise leaves it open.

Active low, and the click at power-up

Each input goes to an optocoupler's LED, whose other end is on VCC. Pulling IN low lights it, which switches the relay's transistor, which pulls the coil in. So digitalWrite(pin, LOW) switches a channel on and HIGH switches it off, and an unwired input is off.

A sketch that calls pinMode(pin, OUTPUT) before writing the pin HIGH leaves it low for that instant, and every channel clicks on at power-up. Write the pin HIGH first, then make it an output.

What the model gets right

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.

What it does not model

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.

See it in action

Relay board runs a chase round four lamps on a four-channel board, and Relays reverse a motor uses a two-channel board as an H bridge. Open them at /templates.

Arduino relay module: active LOW and startup clicks walks through why LOW turns a channel on, the click at power-up and a module that will not switch, on the Relay board circuit.

Two projects switch 12 V lamps on a four-channel board: the IR remote control relay module from the keys of a handset, and Bluetooth home automation from an HC-05.