This guide contains all the information you will need to run the OSA Electronics 6 Ch Relay Board for Raspberry Pi.


  1. What we need
  2. Assembly
  3. Test instructions

What we need


Use the nylon screws and standoffs to assembly the Raspberry Pi together with the 6 Ch Relay Board, as shown on the image below:


GPIO use

By default, the board will start with OFF state relays. To change to ON state, you will need to control via I2C the main chip (PCF8574). The board requires 5v and 3.3v to operate.

The following image shows you the pinout of the board:



Test Instructions

First off, make sure the board is fully assembled with your Raspberry Pi, and you have everything needed to continue qith this guide.

You can download Raspberry OS and other distributions from here.

Step 1
Use your desired Linux distribution or install a fresh image of Raspberry OS.

Make sure your distro is up to date, or in any case, run:

sudo apt-get update 
sudo apt-get dist-upgrade

Step 2
If not installed, install SMBus:

sudo apt-get install python-smbus

Step 3
The next step is to create a new Python file:


This file should be blank! Just copy and paste the following text into the file:

# Test program for 6 Ch Relay Board RLB0665N 

# Imports Section 
import smbus 
import time 

# Initial Setup 
RELAY1 = 0xFE 
RELAY2 = 0xFD 
RELAY3 = 0xFB 
RELAY4 = 0xF7 
RELAY5 = 0xEF 
RELAY6 = 0xDF 

bus = smbus.SMBus(1) 

# Set the I2C address 
PCF8574_addr = 0x20 

# Run the program 
    while True: 
        bus.write_byte(PCF8574_addr, 0xFF) # Turn OFF all relays 
        bus.write_byte(PCF8574_addr, RELAY1) # Turn ON Relay 1 
        bus.write_byte(PCF8574_addr, RELAY2) # Turn ON Relay 2 
        bus.write_byte(PCF8574_addr, RELAY3) # Turn ON Relay 3 
        bus.write_byte(PCF8574_addr, RELAY4) # Turn ON Relay 4 
        bus.write_byte(PCF8574_addr, RELAY5) # Turn ON Relay 5 
        bus.write_byte(PCF8574_addr, RELAY6) # Turn ON Relay 6 
        bus.write_byte(PCF8574_addr, 0x00) # Turn ON all relays 
except KeyboardInterrupt: 				# Trap a CTRL+C keyboard interrupt 
    bus.write_byte(PCF8574_addr, 0xFF)  # Turn OFF all relays

Save the file as usual (Ctrl+O) and exit (Ctr+X).

Step 4
Now, run the script typing:

sudo python

Voilà! Your Relay Board should start to work!

To cancel the script at any time, just press Ctrl+C and it will be stopped.

Leave a Reply

Your email address will not be published. Required fields are marked *