Skip to main content

relay

Control relay modules for switching high-power loads with pulse mode support.

Overview

The relay node controls relay modules for switching high-power loads such as lights, fans, pumps, and appliances. It supports both latching (on/off) and pulse mode for momentary activation, making it ideal for home automation, industrial control, and IoT switching applications.

250V
Max AC Voltage
10A
Max Current
3.3V
Signal Level
Pulse
Mode Support

Properties

Property Type Required Default Description
pin number Yes 0 Relay control GPIO pin (BCM numbering)
initialState boolean No false Initial relay state on deploy (false = OFF)
activeLow boolean No false Invert logic for active-low relay modules
pulseMode boolean No false Enable pulse mode for momentary activation
pulseDuration number No 100 Pulse duration in milliseconds

Inputs

msg.payload

Controls the relay state or triggers a pulse.

true Activate relay (ON)
false Deactivate relay (OFF)
"pulse" Momentary pulse activation

Outputs

State Confirmation

Outputs current relay state with metadata.

{
  "state": true,
  "pin": 17,
  "pulseMode": false,
  "timestamp": 1709251200000
}

Wiring / Connection Diagram

Relay Module to Raspberry Pi

  Raspberry Pi                 Relay Module
  +-----------+               +-------------+
  |           |               |             |
  |  GPIO 17  |----[Signal]---| IN          |
  |           |               |             |
  |  5V       |----[Power]----| VCC         |     Load (Lamp, Fan, etc.)
  |           |               |             |       +--------+
  |  GND      |----[Ground]---| GND     COM |-------| AC/DC  |
  |           |               |          NO |-------| Device |
  +-----------+               |          NC |       +--------+
                              +-------------+
                                                      |
  Note: NO = Normally Open (closes on activate)     [Mains/
        NC = Normally Closed (opens on activate)     Power]

Safety: High-voltage relay wiring should only be done by qualified personnel. Always disconnect mains power before wiring. Use appropriate fuses and enclosures.

Example Use Cases

Scheduled Light Control

Turn a light on at sunset and off at sunrise using a schedule node.

schedule relay
[
  {
    "id": "sunset-schedule",
    "type": "schedule",
    "cron": "0 18 * * *",
    "payload": true
  },
  {
    "id": "light-relay",
    "type": "relay",
    "pin": 17,
    "activeLow": true,
    "initialState": false
  }
]

Temperature-Based Fan Control

Activate a cooling fan when temperature exceeds threshold.

dht22 switch relay
[
  {
    "id": "temp-sensor",
    "type": "dht22",
    "pin": 4,
    "interval": 5000
  },
  {
    "id": "temp-check",
    "type": "switch",
    "property": "payload.temperature",
    "rules": [
      { "t": "gt", "v": "30" },
      { "t": "lte", "v": "25" }
    ]
  },
  {
    "id": "fan-relay",
    "type": "relay",
    "pin": 27,
    "activeLow": false
  }
]

Garage Door Pulse Trigger

Use pulse mode to momentarily trigger a garage door opener.

button relay (pulse)
[
  {
    "id": "dash-button",
    "type": "button",
    "label": "Open Garage",
    "payload": "pulse"
  },
  {
    "id": "garage-relay",
    "type": "relay",
    "pin": 22,
    "pulseMode": true,
    "pulseDuration": 500
  }
]

Common Use Cases

Home Lighting

Switch mains-powered lights on/off remotely

Irrigation Control

Activate water pumps and solenoid valves

Appliance Automation

Control heaters, fans, and AC units

Access Control

Pulse-trigger door locks and gate openers

Related Nodes