• sales

    +86-0755-88291180

Raspberry Pi Relay Board (B) User Guide

Introduction

We provide Raspberry Pi and Jetson Nano demo for this module

Interface introduce

The correspondence between relay channels and Pi pins:

Channel numberRPi pin numberwiringPiBCMDescription
Channel label29P215Channel 1
Channel label31P226Channel 2
Channel label33P2313Channel 3
Channel label36P2716Channel 4
Channel label35P2419Channel 5
Channel label38P2820Channel 6
Channel label40P2921Channel 7
Channel label37P2526Channel 8

【Note】The silk screen marking on the PCB corresponds to the BCM code.

The use of yellow jumpers

Relay_JMP is the relay control pin selection jumpers. When the jumpers are connected, the Raspberry Pi can be used to control the relays.

Using with Raspberry Pi

Install 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 commands
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz
tar zxvf bcm2835-1.68.tar.gz
cd bcm2835-1.68/
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 commands
sudo apt-get install wiringpi
#For Raspberry Pi systems after May 2019 (If your system is earlier than this before, you may not need to execute), you may need to upgrade:
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 does not appear, the installation is wrong

# Bullseye branch system use the following command:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build
gpio -v
# Run gpio -v and version 2.60 will appear. If it does not appear, it means that there is an installation error

Python

# python2
sudo apt-get update
sudo apt-get install python-pip
sudo pip install RPi.GPIO
# python3
sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install RPi.GPIO

Test demo

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

wget https://www.waveshare.com/w/upload/b/b4/RPi_Relay_Board_B.zip
unzip -o RPi_Relay_Board_B.zip -d ./RPi_Relay_Board_B
sudo chmod 777 -R RPi_Relay_Board_B
cd RPi_Relay_Board_B/RaspberryPi/

BCM2835 demo

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

cd bcm2835
make
sudo ./Relay_demo

Expected result: The relays on the module are closed in turn, and then disconnected in turn. Each relay has a corresponding indicator light, which can be known by observing the status of the indicator light. When the user wants to stop running the program, press Ctrl+C to stop the running of the program

WiringPi demo

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

cd wiringPi
make
sudo ./Relay_demo

Expected result: The relays on the module are closed in turn, and then disconnected in turn. Each relay has a corresponding indicator light, which can be known by observing the status of the indicator light. When the user wants to stop running the program, press Ctrl+C to stop the running of the program

Python demo

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

cd python
sudo python Relay_demo.py

Expected result: The relays on the module are closed in turn, and then disconnected in turn. Each relay has a corresponding indicator light, which can be known by observing the status of the indicator light. When the user wants to stop running the program, press Ctrl+C to stop the running of the program

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 command in the terminal:

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

Enter the IP address of the Raspberry Pi in the address bar of Google Chrome (other browsers may not be compatible), port number 8080

Using with Jetson nano

Install library

sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install Jetson.GPIO
sudo groupadd -f -r gpio
sudo usermod -a -G gpio your_user_name
sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger

Test demo

Download the program and enter the specified directory

sudo apt-get install p7zip
wget https://www.waveshare.com/w/upload/c/c2/RPi_Relay_Board_B.7z
7zr x RPi_Relay_Board_B.7z -r -o./RPi_Relay_Board_B
sudo chmod 777 -R RPi_Relay_Board_B
cd RPi_Relay_Board_B/JetsonNano/

C demo

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

cd C
make
sudo ./main

Expected result: The relays on the module are closed in turn, and then disconnected in turn. Each relay has a corresponding indicator light, which can be known by observing the status of the indicator light. When the user wants to stop running the program, press Ctrl+C to stop the running of the program

Python demo

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

cd python
sudo python relay_demo.py

Expected result: The relays on the module are closed in turn, and then disconnected in turn. Each relay has a corresponding indicator light, which can be known by observing the status of the indicator light. When the user wants to stop running the program, press Ctrl+C to stop the running of the program

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 command in the terminal:

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

Enter the IP address of the Raspberry Pi in the address bar of Google Chrome (other browsers may not be compatible), port number 8080

TAG: Raspberry Pi Pico 2 RP2350 industrial 6-ch Relay RS485 isolation protection Raspberry Pi Industrial Isolated RS485 TO ETH (C) RJ45 Converter Wall/Rail-Mount For Modbus Raspberry Pi 5 inch (B) DSI MIPI LCD TouchScreen Display 5inch 720x1280 For Luckfox Lyra RK3506/ESP32-P4/Luckfox Omni3576 10-Axis DOF ROS IMU (A) Sensor UART ARM 32 DSP Processor BLE 5.3 Bluetooth / Accelerometer / Gyroscope / Magnetometer / Temperature & Pressure Rasberry Pi 5 PCIe TO MiniPCIe 4G Gigabit Ethernet RJ45 USB HUB HAT+ SIM7600G-H/EG25-G Serial UART Bus Servo ST3215 30KG.CM/19.5KG.CM Magnetic Encoder 360° High Precision And Large Torque JETSON NANO Attitude Sensor RS232 to RJ45 Raspberry Pi Camera 8MP IMX415 also For Luckfox-Omni3576 RK3576 RM520N GL 5G/4G/3G M.2 Moudle IoT EMBB For LTE-A/NSA/SA And GNSS For DFOTA /VoLTE For Quectel Raspberry Pi Pico Jetson Nano 1.54inch OLED Industrial UART USB TO 8CH RS485 Isolated Converter For 35mm standard rail and stacked installation IO BASE MINI Board UNO Minima RA4M1 ZERO Tiny SuperMini R7FA4M1 Board Compatible With R4 For Arduino Raspberry Pi 5 Case ESP32-S3 LCD 2.13Inch E-Paper