Overview
The gpio-in node reads digital input states from GPIO pins on Raspberry Pi and compatible
single-board computers. It can detect button presses, switch states, sensor triggers, and any digital HIGH/LOW signals.
Common Use Cases
Button Detection
Detect physical button presses with debouncing
Motion Sensors
Read PIR sensor triggers for motion detection
Door/Window Sensors
Monitor magnetic reed switches for security
Limit Switches
Detect end positions in motorized systems
Properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| pin | number | Yes | - | GPIO pin number (BCM numbering) |
| resistor | string | No | "pulldown" | Internal resistor: "pullup", "pulldown", or "none" |
| debounce | number | No | 25 | Debounce time in milliseconds |
| read | string | No | "both" | When to trigger: "rising", "falling", or "both" |
| invert | boolean | No | false | Invert the input signal logic |
| initialRead | boolean | No | false | Send initial state on flow deploy |
Inputs
Any incoming message will trigger an immediate read of the current pin state.
// Trigger immediate read
msg.payload = "read";
return msg; Outputs
Outputs a message when the pin state changes.
{
"payload": 1, // 0 or 1
"topic": "gpio/17", // gpio/{pin}
"pin": 17,
"edge": "rising" // rising or falling
} Wiring Guide
Button with Pull-Down
GPIO Pin --- Button --- 3.3V
Internal pull-down keeps pin LOW until button pressed
Set resistor to "pulldown" in node config
Button with Pull-Up
GPIO Pin --- Button --- GND
Internal pull-up keeps pin HIGH until button pressed
Set resistor to "pullup" and invert to true
Example Flow
Button Press Counter
Count button presses and display on dashboard.
[
{
"id": "gpio-btn",
"type": "gpio-in",
"pin": 17,
"resistor": "pulldown",
"debounce": 50,
"read": "rising"
},
{
"id": "counter",
"type": "function",
"func": "var count = flow.get('btnCount') || 0;
count++;
flow.set('btnCount', count);
msg.payload = count;
return msg;"
},
{
"id": "display",
"type": "ui_text",
"label": "Button Presses",
"format": "{{msg.payload}}"
}
] Troubleshooting
Pin reads random values
This typically means the pin is "floating" without a defined state.
- Enable internal pull-up or pull-down resistor
- Add an external 10kΩ resistor to GND or 3.3V
- Check for loose connections
Button triggers multiple times
Button contacts can "bounce" causing multiple triggers.
- Increase the debounce time (try 50-100ms)
- Use "rising" or "falling" instead of "both"
- Add a hardware debounce capacitor (0.1µF)
Permission denied error
EdgeFlow needs permission to access GPIO pins.
sudo usermod -a -G gpio $USER
sudo reboot