LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

raspi-gpio

Query and set Raspberry Pi GPIO pin states

TLDR

Show all GPIO pin states
$ raspi-gpio get
copy
Get the state of a specific pin
$ raspi-gpio get [17]
copy
Configure a pin as output
$ sudo raspi-gpio set [17] op
copy
Drive a pin high
$ sudo raspi-gpio set [17] dh
copy
Drive a pin low
$ sudo raspi-gpio set [17] dl
copy
Set as input with pull-up
$ sudo raspi-gpio set [18] ip pu
copy
List alternate functions for a pin
$ raspi-gpio funcs [17]
copy
Dump raw register values
$ sudo raspi-gpio raw
copy

SYNOPSIS

raspi-gpio command [pin] [options]

DESCRIPTION

raspi-gpio is a low-level tool for inspecting and manipulating GPIO pins on Raspberry Pi boards. It writes directly to the BCM GPIO controller registers via /dev/gpiomem (or /dev/mem when run as root), bypassing higher-level libraries like libgpiod.The tool is mainly intended for debugging hardware setups, verifying that DT overlays applied the expected pin functions, and one-off scripting. For production use, the kernel gpiod interface (via libgpiod's gpioget/gpioset) is recommended because it integrates with the kernel's GPIO subsystem and respects kernel-claimed lines.

COMMANDS

get [pin|pin1,pin2,...]

Show pin states. Without a pin number, shows all GPIOs (0-53).
set pin options...
Configure pin direction, drive level, pull, or alternate function.
funcs [pin]
Print the BCM-defined alternate functions for the given pin (or all pins).
raw
Print the raw GPIO register values.

OPTIONS FOR SET

ip / op

Set as input / output.
a0 ... a5
Select alternate function 0-5.
dl / dh
Drive low / drive high (only meaningful when op is set).
pu / pd / pn
Pull up / pull down / no pull.

CAVEATS

Raspberry Pi specific. set and raw require root because they write to the hardware. Writing the wrong direction or drive level on a pin connected to external hardware can damage the SoC. The numbering used is BCM (Broadcom) — not the physical board pin numbers.

HISTORY

raspi-gpio is included with Raspberry Pi OS as a small utility maintained by the Raspberry Pi Foundation. It complements higher-level libraries like wiringPi (deprecated) and the kernel gpiod interface.

SEE ALSO

gpio(1), vcgencmd(1)

Copied to clipboard
Kai