Difference between revisions of "RPi Relay Board"

From Waveshare Wiki
Jump to: navigation, search
Line 18: Line 18:
 
= Resources =
 
= Resources =
 
* [[:File:RPi-Relay-Board-Schematic.pdf|Schematic]]
 
* [[:File:RPi-Relay-Board-Schematic.pdf|Schematic]]
* [https://www.waveshare.com/w/upload/0/0c/RPi_Relay_Board.zip Demo Code]]
+
* [https://www.waveshare.com/w/upload/0/0c/RPi_Relay_Board.zip Demo Code]
 
* [[Libraries Installation for RPi]]
 
* [[Libraries Installation for RPi]]
 
==3D Drawing==
 
==3D Drawing==
 
*[https://www.waveshare.com/w/upload/0/0b/RPi_Relay_Board_3D_Drawing.7z RPi_Relay_Board_3D_Drawing]
 
*[https://www.waveshare.com/w/upload/0/0b/RPi_Relay_Board_3D_Drawing.7z RPi_Relay_Board_3D_Drawing]
 +
 
=FAQ=
 
=FAQ=
 
{{FAQ|Can multiple RPi Relay Boards be stacked to use together? |
 
{{FAQ|Can multiple RPi Relay Boards be stacked to use together? |

Revision as of 08:17, 4 August 2022

RPi Relay Board
Rpi-relay-board-1.jpg

Raspberry Pi Expansion Board, Power Relay
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Introduction

Raspberry Pi Expansion Board, Power Relay.

More

Interface description

  • Correspondence between relay channel and RPi Pin
Channel No. RPi Pin No. wiringPi BCM Descriptions
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.
If you use cable to wire the board instead of directly attaching the pin heard, you need to connect the 5V, 3.3V and GND for normally powering.

  • Relay_JMP (6P jumper) usage:

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

  • Relay screw terminal description:

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 a Low Level from its IO, the LED related to the corresponding channel lights up. At the same time, the relay NO (normally open contacts) closes, and the NC (normally closed contacts) opens, so as to change the ON/OFF status of the external circuit.

(PS: Remember to connect the jumper Relay_JMP!)

Before the relay action:

Rpi-relay-board-manual-1.jpg

After the relay action:

Rpi-relay-board-manual-2.jpg

Working with Raspberry Pi

Install related function library

PS: If you are using the system of the Bullseye branch, you need to change "apt-get" to "apt", the system of the Bullseye branch only supports Python3.

BCM2835

#Open the Raspberry Pi terminal and run the following command
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz
tar zxvf bcm2835-1.71.tar.gz 
cd bcm2835-1.71/
sudo . /configure && sudo make && sudo make check && sudo make install
# For more information, please refer to the official website: http://www.airspayce.com/mikem/bcm2835/

wiringPi

#Open the Raspberry Pi terminal and run the following command
cd
sudo apt-get install wiringpi
#For Raspberry Pi systems after May 2019 (earlier than that can be executed without), an upgrade may be required:
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
gpio -v
# Run gpio -v and version 2.52 will appear, if it doesn't it means there was an installation error

# Bullseye branch system using the following command:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
. /build
gpio -v
# Run gpio -v and version 2.70 will appear, if it doesn't it means there was an installation error
  • Install the Python function library.
sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install python-dev
sudo pip install RPi.GPIO

Test demo

Execute the following commands in the terminal, download the demo and extract it to the specified directory.

wget https://files.waveshare.com/upload/0/0c/RPi_Relay_Board.zip
unzip -o RPi_Relay_Board.zip -d ./RPi_Relay_Board
sudo chmod 777 -R RPi_Relay_Board
cd RPi_Relay_Board

Shell demo

Enter the Linux terminal and execute the following commands in the terminal:

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

Expected Result: The LED for relay channel 1 is lighted up and the relay is audible. The last two parameters in the command can be changed. For example, run the above commands to turn on relay 2 and turn off relay 3.

Bcm2835 Demo

Enter the Linux terminal and execute the following commands in the terminal:

cd bcm2835
make
sudo ./Relay_Module

Expected result: You can see the 3 LEDs light up in sequence and the relay switches back and forth between NC and NO contacts in sequence. At the same time, the terminal will display which contact the relay is currently in.

wiringPi Demo

Enter the Linux terminal and execute the following commands in the terminal:

cd wiringPi
make
sudo ./Relay_Module

Expected result: You can see the 3 LEDs light up in sequence and the relay switches back and forth between NC and NO contacts in sequence. At the same time, the terminal will display which contact the relay is currently in.

Python Demo

Enter the Linux terminal and execute the following commands in the terminal:

cd python
sudo python Relay_Module.py

Expected result: You can see the 3 LEDs light up in sequence and the relay switches back and forth between NC and NO contacts in sequence. At the same time, the terminal will display which contact the relay is currently in.

Web Control

The web page control of this demo is based on the python web framework to control the relay.
Enter the Linux terminal and execute the following commands in the terminal:

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

Enter the Raspberry Pi IP address in the address bar of Google Chrome (other browsers may be not compatible), port number 8080.
RPi-Realy Board python-bottle.png

Resources

3D Drawing

FAQ

 Answer:
Since the relay is too tall to be stacked together, multiple relay modules can be connected via Dupont cables.


 Answer:
Because the relay is triggered by a low level, the relay pulls in when the output is low.



Support

If you require technical support, please go to the Support page and open a ticket.