Skip to main content

gpio-out

Control digital output pins to drive LEDs, relays, motors, and other actuators on Raspberry Pi.

Overview

The gpio-out node controls digital output pins on Raspberry Pi and compatible single-board computers. Use it to turn LEDs on/off, switch relays, control motors through driver boards, and any other digital output control.

3.3V
Output Voltage
16mA
Max Current per Pin
50mA
Max Total Current

Important Safety Notice

Never connect GPIO pins directly to loads drawing more than 16mA. Use transistors, MOSFETs, or relay modules for motors, solenoids, and other high-current devices. Exceeding current limits can permanently damage your Pi.

Common Use Cases

LED Control

Drive status LEDs and indicator lights

Relay Switching

Control high-power devices via relay modules

Motor Direction

Control H-bridge motor drivers for direction

Buzzer/Alarm

Trigger audible alerts and notifications

Properties

Property Type Required Default Description
pin number Yes - GPIO pin number (BCM numbering)
initialValue boolean No false Initial output state on deploy
invert boolean No false Invert output logic (HIGH=0 for active-low devices)
persistState boolean No false Persist pin state across restarts
stateFile string No /var/lib/edgeflow/gpio_states.json File path for persisted state
failsafeMode boolean No false Enable failsafe — set pin to a safe state on error or cleanup
failsafeValue boolean No false Value to set when failsafe triggers (false = LOW)
driveStrength number No - Drive strength in mA (for supported pins)

Inputs

msg.payload

Controls the output state of the GPIO pin. Accepts multiple field names and formats.

value: true → Set HIGH
value: false → Set LOW
state / on / payload → Also accepted as field names
numeric > 0 → Treated as true (HIGH)

Outputs

Status Confirmation

Passes through the input message with updated state.

{
  "payload": {
    "pin": 17,
    "value": true    // actual written value (after invert)
  }
}

Wiring Examples

LED with Resistor

GPIO 18 → 330Ω Resistor → LED (+) → LED (-) → GND

Current = (3.3V - 2V) / 330Ω ≈ 4mA (safe)

Standard indicator LED circuit

Relay Module (Active-Low)

GPIO 23 → IN (Relay)

5V → VCC (Relay)

GND → GND (Relay)

Set invert: true for active-low relays

Example Flows

Blink LED Every Second

Use inject node's toggle mode to alternate true/false automatically — no Function node needed.

inject (1s, toggle) gpio-out (pin 17)
[
  {
    "id": "blink-inject",
    "type": "inject",
    "name": "Toggle 1s",
    "intervalType": "seconds",
    "intervalValue": 1,
    "repeat": true,
    "toggle": true,
    "payload": { "value": true }
  },
  {
    "id": "led-out",
    "type": "gpio-out",
    "name": "LED Pin 17",
    "pin": 17
  }
]
The inject node's toggle option makes payload.value alternate between true and false on each tick.

Motion-Activated Light

Turn on light when motion detected, auto-off after 30 seconds.

gpio-in (PIR) switch gpio-out / delay (30s) gpio-out

Failsafe & State Persistence

Failsafe Mode

When enabled, the pin is set to a known safe state on errors or when EdgeFlow shuts down. Critical for controlling heaters, pumps, or other devices that should default to OFF.

failsafeMode: true — enable failsafe

failsafeValue: false — set LOW on error/shutdown

State Persistence

Enable persistState to save pin state to disk. After a restart, the pin will be restored to its last known state.

Default state file: /var/lib/edgeflow/gpio_states.json

Customize with the stateFile property

Troubleshooting

LED not turning on
  • Check LED polarity (long leg is positive/anode)
  • Verify resistor value is not too high
  • Test with multimeter: should read ~3.3V when HIGH
  • Try a different GPIO pin
Relay clicking but not switching load
  • Check if using NO (Normally Open) vs NC (Normally Closed) terminals
  • Verify relay module is powered with 5V (not 3.3V)
  • Ensure load wiring is secure in screw terminals
Output stays LOW/HIGH permanently
  • Check if another process is controlling the same pin
  • Redeploy flows to reset pin state
  • Verify pin is not reserved for system use (I2C, SPI, UART)

Related Nodes