4-Channel Relay Board for Raspberry Pi Assembly and Testing Guide


The guide is for the assembly of the 4-Channel Relay Board for the Raspberry Pi. This board is also compatible with the Quick2wire Interface board.

First check all items are correct in the kit.

Kit Contents

  • 3 x 10k resistor
  • 4 x 560R resistor
  • 1 x 100uF capacitor
  • 1 x 47uF capacitor
  • 4 x 3mm LED
  • 1 x MCP23008 IC
  • 1 x ULN2803A IC
  • 4 x Relay
  • 1 x 3 way DIP switch
  • 2 x 6 way IDC boxed header
  • 1 x 25 way IDC boxed header
  • 1 x 6 way IDC cable
  • 6 x 3 way screw terminal
  • 1 x PCB
  • 2 x jumper
  • 1 x 2 way header
  • 1 x 3 way header

Start Soldering

If you are new to soldering then checkout this tutorial from Sparkfun.
Solder the 3 x 10k and 4 x 560R resistor.

Solder the 3way DIL switch and the 2way and 3way header.

Solder the 4 x 3mm LED and the two capacitors. Note the polarity of C2, the – is on the left side. On the LED the cathode is the short pin should be placed on the right side of the two holes.

Solder the 3 IDC connectors. Note the orientation of the boxed header. Solder IC1 and ULN1, note the notch of the IC is facing the top.

Slide two of the 3way screw terminal together.

Solder the 3way screw terminals.

Solder the 4 x Relays.

Insert a jumper on JP8 and 5v side of JP9.
The board assembly is now complete.


Before connecting the board up make sure power is switched off to the Raspberry Pi. You can connector the Relay board to the Quick2Wire Interface board via the supplied 6way ribbon cable.

Or via a 26way ribbon cable (not supplied with the kit) directly to the Raspberry Pi.


Install the I2C driver first. With all the DIP switches (S1) in the off position. Now type in:

sudo i2cdetect -y 1

Makes sure you get a reply like this:

If you are using an old Rev 1 board type this instead:

sudo i2cdetect -y 0

Download the test software by typing:

wget http://www.skpang.co.uk/dl/relay_test.py

Change the file permission to allow execute:

chmod +x relay_test.py

Run the example by:


Check the relays are clicking in turn and the LED are on with the relay.



End of test.

Short URL:

Tags: , , ,

8 Responses to 4-Channel Relay Board for Raspberry Pi Assembly and Testing Guide

  1. Gamma on 16/08/2013 at 15:01

    Would this board be safe to operate with 230VAC voltages on relays? For example controlling a couple of 230VAC halogen light bulbs with RPi.

    • admin on 19/08/2013 at 23:30

      You should only work with mains electricity if you are a qualified person. 240V can kill if not wired up correctly. Having said that this board uses mains rated relay and have proper PCB track clearance. Only connect this board to the mains if you are a qualified and competent person. Ensure the board is in a proper mains rated enclosure.

  2. ids on 25/08/2013 at 07:50

    Hi. Great board, just finished assembling one yesterday.

    Code example working fine, however there is not any documentation what the other ports do (can turn on r1-4) but what can 5-8 be used or and how.

    Plus how can you turn on multiples of relays on at the same time ? Say 1-3


    • Damian on 27/12/2013 at 15:57

      You can switch multiple relays on the same was as single relays – it’s just a different value passed.

      If you think of the relays as 1, 2, 4, 8 then it makes sense. Passing these values directly will turn on the relays singularly, something like
      for relay in [1, 2, 4, 8]:

      will step though all the relays (this is what the test_relays script does).

      If you want to switch multiple relays on, add the numbers together and use that. For example:
      Relay 1+2 – 1+2 = 3
      Relay 2+3 – 2+4 = 6
      Relay 1+2+3 – 1+2+4 = 7
      Relay 1+2+3+4 – 1+2+4+8 = 15
      Relay 1+4 – 1+8 = 9
      Relay 3+4 – 4+8 = 12

      This should give you control of all 16 combinations. For reference 0/16 is all off, 15 is all on (anything higher than 16 will cycle back around).

      Hope this helps!

      • Dave on 05/01/2014 at 14:42

        Hi, I got the test program working fine but I want to be able to turn on any one relay at a time and can’t find any information anywhere on how to do it. How do I modify the program to turn on just one relay and delete the loop? Many thanks.

        • IRO on 13/12/2014 at 20:06

          #! /usr/bin/python

          import smbus
          import sys
          import getopt
          import time

          bus = smbus.SMBus(1) # on a RPi REV2 board

          def main():
          a = 0
          delay = 1

          bus.write_byte_data(0×20,0×09,0×10) #
          bus.write_byte_data(0×20,0×09,0×20) #
          bus.write_byte_data(0×20,0×09,0×40) #
          bus.write_byte_data(0×20,0×09,0×80) #
          bus.write_byte_data(0×20,0×09,0xFF) #
          bus.write_byte_data(0×20,0×09,0×70) #
          bus.write_byte_data(0×20,0×09,0×30) #
          bus.write_byte_data(0×20,0×09,0×10) #
          bus.write_byte_data(0×20,0×09,0×00) #

  3. Dick Haight on 12/10/2013 at 23:15

    Any reason you didn’t choose an opt-isolated board?

  4. Stephen kingham on 01/02/2015 at 05:54

    I am interested in several (as many as 4) 4-Ch Relay Board Kit for Raspberry boards but have some questions.
    Can I drive 2 boards from one Pi? I presume to do that I need to be able to change the i2c address and I will need to know what leads are needed between the Pi and the board as I have several other boards using the GPIO interfaces. Also I would like to supply the board from a separate power supply rather than the Pi.