Skip to content

Smart Relays

Vlad Vladutu edited this page Jul 2, 2025 · 14 revisions

🚀 For a quick setup: Plug your Smart Relays card on top of your Raspberry Pi and jump straight to Software Setup →

General Description

image

The Smart Relays HAT is a stackable expansion card for Raspberry Pi. It is compatible with all Raspberry Pi versions from Zero to 5. Stackable to 8 layers, the card can add up to 32 power relays and 32 universal inputs in an extremely compact, industrial‑grade form‑factor.

Pluggable connectors make the card easy to use when multiple cards are stacked up. Loads of up to 10A and 240V can be switched by all relays. Status LEDs show when relays are on or off, when the inputs are activated and are also programmable.

The card has also an RS485 driver which can communicate with other industrial equipment using the MODBUS protocol.

Mechanically, the Smart Relays card adheres to the Sequent Microsystems Modular Industrial format. It can be installed in the free 3D printable stackable enclosure. All the cards in this format have the same mechanical specifications.

Features

  • Four relays with integrated HALL effect sensors on loads
  • Four Analog inputs reading temperature from 10K thermistors, or
  • Four Digital inputs reading dry contact or 24V opto-isolated signals
  • Eight layer stackable to 32 relays and 32 inputs
  • Pluggable connectors (26-16AWG wires) on all inputs and relay contacts
  • Normal-Open and Normal-Close contacts on all relays
  • Hardware watchdog power cycles the Pi on software lockup
  • Command Line, Python Drivers, Node-Red Nodes, OpenPLC module, Arduino Library, HomeAssistant Integration

Up to eight cards can be stacked on top of one Raspberry Pi. The Smart Relays cards share a serial I2C bus using only two of the Raspberry Pi’s GPIO pins to manage all eight cards. This feature leaves the remaining 24 GPIOs available for the user.

What Is In Your Kit

  1. Smart Relays card for Raspberry Pi

image

  1. Mounting hardware
    • Four M2.5x18mm male-female brass standoffs
    • Four M2.5x5mm brass screws
    • Four M2.5 brass nuts

image

  1. Four Jumpers

image

The jumpers are used to select the input modes. See Input Operating Modes section for more info

  1. All the required female mating connectors.

image

Board Layout

image

The Smart Relays card comes with appropriate mounting hardware. Up to eight cards can be stacked on top of one Raspberry Pi.

A power LED indicates when the board is active. The LED flashes at 0.5s interval, indicating also that the local processor is up and running.

Four LEDs indicate the status of their respective relay. A LED is lit when the corresponding relay is energized. Other four LEDs indicate the status of the inputs. LEDs are lit when inputs are high. The General Purpose Pushbutton is read by the local processor, which can be programmed to signal the Raspberry Pi by setting low pin 37 of the Raspberry Pi GPIO connector (GPIO26). You can also read the status of the pushbutton from the I2C interface.

The three left-most positions of the SW1 switch are used for selecting the stack level (explained in the next section). The three right-most switches are used to control the RS485 communication.

Configuration DIP Switch

The 6 position DIP Switch selects the stack level and routes the RS485 to the Raspberry Pi serial port 1 (GPIO pins 14 and 15). The three leftmost positions are used for the stack level, as shown in the following section. Positions 4 and 5, when set to ON, disconnect the RS485 port from the local processor and connect it to Raspberry Pi. Position 6 is for the RS485 terminator. Set this switch on if your card is the last one on the RS485 chain.

Stack Level

The 3 left positions of the switch are used to select the stack level of the card:

stack_level0 stack_level1 stack_level2 stack_level3 stack_level4 stack_level5 stack_level6 stack_level7
Stack Level 0 1 2 3 4 5 6 7
I2C Address 0x0e 0x0f 0x10 0x11 0x12 0x13 0x14 0x15

RS-485 Communication

The Smart Relays contains a standard RS485 transceiver which can be accessed both by the local processor and by Raspberry Pi. The desired configuration is set using the switches.

If switches are ON, Raspberry Pi can communicate with any device with an RS485 interface. In this configuration the card is a passive bridge which implements only the hardware levels required by the RS485 protocol. To use this configuration, you need to tell the local processor to release control of the RS485 bus:

4rel4in 0 rs485wr 0 0 0 0 0

Input Operating Modes

Each input channel can work in one of two hardware modes, selected with jumpers on 2 of the three pins next to the terminal block:

image

Jumper position Hardware mode Typical use
Pins 1-2 Opto-coupled Pulse counting, quadrature encoders, PWM capture
Pins 2-3 10k thermistor / dry-contact Temperature probes, dry contact closure

(If the jumper is removed the channel is inactive.)

  • Opto-coupled mode (jumper on 1-2)

All inputs can be used to count transitions up to 4 kHz. For slow signals you can read the cumulative transition counts. For fast transitions you can read the PPS (pulse per second).

Inputs can be paired (1 with 2 and 3 with 4) to read quadrature encoder devices with up to 4000 PPS.

Inputs can also be used to read PWM signals, reading both the fill factor and the frequency. PWM signals up to 100Hz can be processed with a resolution better than 1%. Faster signals up to 500Hz can also be processed with 5% precision.

  • 10k thermistor (jumper on 2-3 + 10k NTC between the terminals highlighted on the PCB)

  • Dry contact (jumper on 2-3 + clean switch between the terminals highlighted on the PCB)

Power Requirements

The Smart Relays card requires +5V power, supplied either from the Raspberry Pi expansion bus, or from its own pluggable connector. The on-board relays are powered by the +5V (See Schematic).

Raspberry Pi current consumption:

  • 250 mA @ +5V (could be as high as 2A)

Smart Relays Card current consumption:

  • <50 mA @ +5V (all relays OFF)
  • 400 mA @ +5V (all relays ON)

The connector, which powers the card, can supply up to 8A and is protected by a 3A resettable fuse. We recommend using a 5V regulated power supply rated at 3A or higher. The Smart Relays card can be stacked up to eight levels. A multi-stack configuration can be powered from any of the cards.

Mechanical Specifications

image

The card is compatible with any card manufactured by Sequent Microsystems and can be mounted in any order. You may also inter-mix cards from other vendors, assuming they do not use the same I2C address. It can be installed in the 3D-printable modular enclosure available for download from our website.

Software Setup

  1. Have your Raspberry Pi ready with the latest OS.

  2. Enable I2C communication:

sudo raspi-config

image

image

image

  1. Install the 4rel4in software from github.com:
cd
git clone https://github.com/SequentMicrosystems/4rel4in-rpi.git
cd 4rel4in-rpi
sudo make install
  1. Run the software:
4rel4in

The program will respond with a list of available commands.

  • Run 4rel4in -h for online help.

  • After installing the software, you can update it to the latest version with the commands:

cd ~/4rel4in-rpi
git pull
sudo make install

Examples

General syntax: 4rel4in <stack-level> <command> [other-arguments]

Tip - If you have only one Smart-Relays card plugged in, the stack-level is 0.

  • Turn relay number 2 ON

# General syntax:
# 4rel4in <stack-level> relwr <relay-number> <state>

4rel4in 0 relwr 2 1
  • Read instantaneous current on relay 1

# Query the live (instantaneous) current flowing through relay 1
4rel4in 0 crtrd 1
  • Read RMS current on relay 1

# Query the RMS (root-mean-square) current on relay 1
4rel4in 0 crtrmsrd 1

What is RMS?

For AC or rapidly varying signals, the current is constantly swinging above and below zero. RMS is a kind of smart average: the device squares every sample (so negatives become positive), averages those squares over a full cycle, and then takes the square root. The result is the effective or “DC-equivalent” current - the number that tells you how much heat the load will generate and how thick your wires need to be.

When to use it:

  • Any AC load (motors, heaters, lamps on the mains, etc.)
  • Noisy or pulsed DC where the current isn’t steady

You can read more about RMS on wiki.


  • Two-point current calibration

Calibrating stores a line (offset + gain) so readings match a trusted meter.

  1. Apply your first known current (e.g. 1.021 A) through relay 3

  2. Store that point:

    4rel4in 0 crtcal 3 1.021
  3. Apply a second, significantly different current (the farther apart, the more accurate), e.g. 6.376 A, and store it:

    4rel4in 0 crtcal 3 6.376

Your relay-3 current channel is now calibrated.

  • After calibration, verify with an intermediate current to confirm linearity.

  • Reset calibration (if you made a mistake)

# Clear all calibration data for relay 3 and revert to factory defaults
4rel4in 0 crtcrst 3

More Resources

↑ Back to top