RPi Relay Board

From ingcool
Jump to: navigation, search

Introduction

The RPi Relay Board is a Relay module which is designed for Raspberry Pi, it supports 3 channels controlling.

RPi Relay Board 1.jpg

Features

  • Standard Raspberry Pi 40PIN GPIO extension header, supports Raspberry Pi series boards
  • High-quality relays, loads up to 5A 250V AC or 5A 30V DC
  • Photo coupling isolation, prevent interference from high voltage circuit
  • Onboard LEDs for indicating relays status
  • Relay control jumper allows controlling the relays by custom pins other than the default pins

User guides

Interfaces

Correspondence between relay channel and RPi Pin

Channel No. RPiPin No. wiringPi BCM Description
CH1 37 P25 26 Channel 1
CH2 38 P28 20 Channel 2
CH3 40 P29 21 Channel 3

Notices: The labels on the PCB are corresponding to the wiringPi code.

Relay_JMP (6P jumpeer)

Relay_JMP is the relay control pin selecting jumper. When this jumper is connected, the relay can be controlled by the Raspberry Pi.

Relay DIP Connector

This board integrates three screw terminals, and each has three pins for connecting external circuits.
All the terminals are low active. When the Raspberry Pi outputs Low Level from its IO, the LED related to the corresponding channel lights up. At the same time, the relay NO (normally open contacts) close and the NC (normally close contacts) open, so as to change the ON/OFF status of the external circuit.

Install libraries

  • Install BCM2835
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz
tar zxvf bcm2835-1.60.tar.gz 
cd bcm2835-1.60/
sudo ./configure
sudo make
sudo make check
sudo make install
  • Install wirignPi
sudo apt-get install wiringpi
#If you use Pi4, you need to update it:
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
  • Install Python libraries
sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install python-dev
sudo pip install RPi.GPIO

Examples

Open a terminal and download the demo codes by following commands.

sudo apt-get install p7zip
wget http://www.ingcool.com/w/images/f/fc/RPi_Relay_Board.7z
7zr x RPi_Relay_Board.7z -r -o./RPi_Relay_Board
sudo chmod 777 -R RPi_Relay_Board
cd RPi_Relay_Board
Shell example

Open a terminal and run the following commands::

cd shell
sudo ./Relay.sh CH1 ON
sudo ./Relay.sh CH2 ON
sudo ./Relay.sh CH3 OFF

Expected result: The LED of relay channel 1 is ON, and you can hear the relay closes. The two parameters at the end of this line are configurable. For example, when you change these parameters to CH2 ON, the relay 2 will connect; and then to CH3 OFF, the relay 3 will disconnect.

BCM2835 example

Open a terminal and run the following command

cd bcm2835
make
sudo ./Relay_Module

Expected result: Three LEDs light up by turns and the relays switch back and forth between the NC node and NO node. In the meantime, the terminal will show the node that the current relay stays at.

wiringPi example

Open a terminal and run the following command

cd wiringPi
make
sudo ./Relay_Module

Expected result: Three LEDs light up by turns and the relays switch back and forth between the NC node and NO node. In the meantime, the terminal will show the node that the current relay stays at.

python example

Open a terminal and run the following command

cd python
sudo python Relay_Module.py

Expected result: Three LEDs light up by turns and the relays switch back and forth between the NC node and NO node. In the meantime, the terminal will show the node that the current relay stays at.

Webpage controlling

This example is based on the python bottle framerate.
Open a terminal and run the following command:

sudo apt-get install python-bottle
cd python-bottle
sudo python main.py

Open a Chrome browser, and go to the IP address of the Raspberry Pi. The port is 8080, for example, 192.168.6.144:8080
RPi-Realy Board python-bottle.png

Resources

Document

Demo codes

FAQ

1、Can I use multiple RPi Relay Board by sticking them?
  • You cannot stack it because of the board is too high, you can think about connecting them by wires.
2、Why the signal is inverted and the board doesn't work if I set it to High?
  • The really board is toggle by Low level, you need to set it to Low for working.
3、The relays are open or close by default when it is controlled by webpage?
  • It is the default open