Zum Inhalt springen

WSAL20524 – RPi Zero Relay/en

Aus JW Tech Wiki

Documentation notice: This technical documentation was independently rewritten from an archived supplier source. Check technical details and commands against the product version and manufacturer documentation before use.

Summary

The 6-channel relay module for the Raspberry Pi Zero provides CAN and RS485 interfaces, isolated protection features, and a 7–36 V DC power supply. It is aimed at developers who want to control relays via GPIO and use field buses.

Related products at JW Tech

Technical overview

  • Supply voltage: 7–36 V DC via screw terminals or round jack
  • CAN controller: MCP2515 over SPI; transceiver: SN65HVD230
  • RS485 transceiver: SP3485EN, half-duplex over UART
  • Six relay channels are driven via GPIO 5, 6, 13, 16, 19 and 20
  • Contact rating per channel: up to 10 A at 250 V AC or 30 V DC
  • Optocoupler isolation separates the relay’s external high-voltage side from the control chip
  • TVS diode protects against surge voltages and transient spikes
  • Switches for 120 Ω terminators on the CAN and RS485 buses
  • Dimensions: 123 mm × 87.92 mm; mounting hole diameter 3.5 mm
  • 40-pin GPIO header fits Raspberry Pi Zero boards with pre-soldered pinheaders

Commands and examples – verify before use: 

git clone https://github.com/WiringPi/WiringPi && cd WiringPi && ./build && gpio -v
sudo apt-get install python3-serial python3-can python3-gpiozero
python3 -m venv myenv && source myenv/bin/activate && pip3 install pyserial python-can gpiozero
wget https://www.waveshare.net/w/upload/2/2f/RPi_Zero_Relay_Code.7z && 7z x RPi_Zero_Relay_Code.7z -r -o./RPi_Zero_Relay_Code && sudo chmod 777 -R RPi_Zero_Relay_Code/
cd RPi_Zero_Relay_Code/Relay/wiringPi/ && make clean && make && sudo ./relay
cd RPi_Zero_Relay_Code/Relay/python/ && python3 relay.py
sudo nano /boot/config.txt # add: dtparam=spi=on ; dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25,spimaxfrequency=3000000
sudo reboot
dmesg | grep -i '\(can\|spi\)'
cd RPi_Zero_Relay_Code/CAN/wiringPi/receive/ && make clean && make && sudo ./can_receive
cd RPi_Zero_Relay_Code/CAN/wiringPi/send/ && make clean && make && sudo ./can_send
cd RPi_Zero_Relay_Code/CAN/python/ && sudo python can_reveive.py && sudo python can_send.py
sudo raspi-config # Interfacing Options -> Serial: disable shell, enable hardware serial port
echo "enable_uart=1" >> /boot/config.txt && sudo reboot
cd RPi_Zero_Relay_Code/485/WiringPi/receive && make clean && make && sudo ./485_receive
cd RPi_Zero_Relay_Code/485/WiringPi/send && make clean && make && sudo ./485_send
cd RPi_Zero_Relay_Code/485/python/ && sudo python receive.py && sudo python send.py

Notes and version constraints

  • The CAN demo assumes two RPi-Zero-Relay modules; other CAN devices require H-H/L-L wiring and matching baud rates (demo default: 100 kbit/s).
  • If frame loss occurs during sustained data transmission, reducing the baud rate may help.
  • On newer systems, a Python virtual environment is recommended; missing libraries may produce warnings that do not block execution.
  • Exact demo file names and paths must match the downloaded archive; mismatches can cause runtime errors.
  • The guide references external datasheets and demo files whose contents were not verified here.

Source and revision record

  • RPi Zero Relay - Waveshare Wiki
  • Source revision: 94074
  • Captured: 2026-09-02T03:57:38+00:00
  • SHA-256: e8e08a6cfa8ab1978ad4cd5a78844dbbdf92445087b58dc5ecf0651a6b1e1304