4-way relay

If you have bought one of these 4-way relay boards and are having trouble connecting it up, this page explains what's going on and how to connect it without damaging your Raspberry Pi. There are also 2-way and 8-way versions. The first thing to understand is that the relay coils each take about 70mA at 5V, so be careful that your total current consumption does not exceed the safe maximum for your Raspberry Pi taking into account other circuits and the rating of the power supply.

The relays are driven through opto-isolators so that the actual current required to trigger each relay is <2mA, which is safe to connect to any GPIO pins. Each relay has an associated LED indicator to show its state:

The board has connections as shown in the table below. There is a ground pin (GND), four pins to control the relays and a Vcc pin. There is also a jumper labelled Vcc/JD-Vcc that connects the Vcc pin on the 6-pin header to the JD-Vcc pin when fitted. However, for the Raspberry Pi, which has output pins running at +3V3, the jumper must be removed and then separate +3V3 and +5V supplies connected to the opto-isolators: 3V3 to Vcc on main header and 5V to JD-Vcc for the relays. It is not possible to drive the relays coils reliably using +3V3.

Connection NameConnect ToWhat It Does
GND on main headerRaspberry Pi 0V or GNDProvides a ground connection
IN1 on main headerA suitable Raspberry Pi digital output pinSwitches relay 1 when connected to GND/0V
IN2 on main headerSwitches relay 2 when connected to GND/0V
IN3 on main headerSwitches relay 3 when connected to GND/0V
IN4 on main headerSwitches relay 4 when connected to GND/0V
Vcc on main header+3V3 on Raspberry PiProvides +3V3 for the opto-isolators
Vcc on jumperLeave disconnected
JD-Vcc on jumperRaspberry Pi +5VProvides a supply to drive the relays

Relay coils are energised by setting the INx pins to 0V - use LOW in your Raspberry Pi program. Your program should look similar to this if you're using the WiringPi library:

pinMode(7, OUTPUT);     // Set pin 7 to be output
digitalWrite(7,LOW); 	// Set pin 7 LOW = relay energised
digitalWrite(7,HIGH); 	// Set pin 7 HIGH = relay unenergised

Do this with an Arduino.