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 Arduino. 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 Arduino 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 the relay is <2mA, which is safe for any digital output 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 so that the same supply drives both opto-isolators and relays. For the Arduino, which has output pins running at +5V, the jumper can be fitted and the same supply can be used, subject to the current limits mentioned previously.

Connection NameConnect ToWhat It Does
GND on main headerArduino 0V or GNDProvides a ground connection
IN1 on main headerA suitable Arduino 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+5V on ArduinoProvides +5V for the opto-isolators and if the jumper is in place, the relays
VCC and JD-VCC jumperPut the jumper on if you want to drive the relay coils. Leave it off if you just want to test a program without actually switching anything. With the jumper off, the indicator LEDs will still light but the relays will not switch.

Relay coils are energised by setting the INx pins to 0V - use LOW in your Arduino sketch. Your sketch should look similar to this

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 a Raspberry Pi.