2-CH Relay HAT Optocoupler Isolation Relay Expansion Board

2-CH Relay HAT

Overview

This product is a 2-channel relay expansion board, suitable for Raspberry Pi Zero/Zero W/Zero WH/2B/3B/3B+/4B, STM32, and Arduino. It comes with two relays on board, and can control shutdown independently.

Parameters

  • Supply voltage:5V
  • Relay allows access to the load:250V/5A
  • With relay working indicator, it is convenient to check the working status of the relay
  • Optocoupler isolation circuit, strong anti-interference ability, stable work
  • Open source demo codes available for Raspberry Pi
  • Size: 56mm(Length) x 34mm(width)
  • Weight: 25g

Usage

Hardware interface configuration description

The sample program in the Raspberry Pi motherboard uses the wiringPi pin definitions. The definition of the connection with the Raspberry Pi motherboard is shown in the following table:

2-CH Relay HATPin functionBCMwiringPi
5V5V5V5V
GNDGNDGNDGND
CH1Channel 126P25
CH2Channel 219P24

The Resource Profile is shown in the figure below:

2-CH Relay HAT

① Relay output Relay control signal level and amplitude sliding switch, available 3.3V or 5V.

② Relay working indicator: when the light is on, it means that the normally open end of the relay is closed, the normally closed end is disconnected, and when the light is off, it means that the normally open end of the relay is disconnected and the normally closed end is closed.

③ Relay

④ Relay output

⑤ Power indicator

⑥ PH2.0 4PIN Module wire

⑦ 2.54mm 4PIN connector

Relay wiring diagram is as follows:

Relay wiring instruction

Demo Codes Usage

Wiringpi library installation:

First, use the "gpio -v" command on the terminal to check whether the wiringpi library has been installed. If the information of 2.52 appears, it means that the installation has been successful. You can skip this part of the content, otherwise you need to install it as follows:

sudo apt-get install wiringpi

#For Raspberry Pi systems after May 2019 (earlier ones do not need to be executed), an upgrade may be required:

wget https://project-downloads.drogon.net/wiringpi-latest.deb

#Version 4B upgrade of Raspberry Pi,If your download fails or the #speed is very slow, you can download it at the following linkand then #and copy it to the Raspberry Pi mainboard:

#https://github.com/seengreat/wiringpi-library

sudo dpkg -i wiringpi-latest.deb
gpio -v

If version 2.52 appears, the installation is successful

#For the Bullseye branch system, use the following command:

git clone https://github.com/WiringPi/WiringPi
cd WiringPi
. /build
gpio-v

#Running gpio - v will result in version 2.70. If it does not appear, it indicates an installation error.

If the error prompt "ImportError: No module named 'wiringpi' " appears when running the python version of the sample program, run the following command.

#For Python 2. x version

pip install wiringpi

#For Python 3. x version

pip3 install wiringpi

Note: If the installation fails, you can try the following compilation and installation:

git clone --recursive https://github.com/WiringPi/WiringPi-Python.git

Note: The -- recursive option can automatically pull the submodule, otherwise you need to download it manually.

Enter the WiringPi Python folder you just downloaded, enter the following command, compile and install:

#For Python 2. x version

sudo python setup.py install

#For Python version 3. X

sudo python3 setup.py install

If the following error occurs:

2-CH Relay HAT

At this time, enter the command sudo apt install swig to install swig. After that, compile and install sudo python3 setup.py install. If a message similar to the following appears, the installation is successful.

2-CH Relay HAT

Execute the sample program

Python:

Go to the Python directory:

cd /home/pi/4-ch_relay/python

performance:

sudo python3 4-ch-relay.py

C:

Go to the C directory:

cd /home/pi/4-ch_relay/c

Resources

Schematic

Demo Codes

Product

Data Sheet

HF3FF005-1ZS

LTV-357T-B-IN

Technical Support

Technical Support and Product Notes