Skip to main content

GPIO Toolkit

Control Raspberry Pi GPIO pins with read, write, edge watching, and software PWM. Compatible with Pi 5 (chip 4) and Pi 4 (chip 0). Requires node-libgpiod as an optional peer dependency.

Quick Start


Config

number
default:"0"
GPIO chip number. Use 4 for Pi 5, 0 for Pi 4 and earlier.
number[]
default:"[]"
Allowlist of pin numbers. Empty array = all pins allowed.
number
default:"1000"
Maximum software PWM frequency in Hz.

Tools


Safety

Pin Allowlisting

The allowedPins config restricts which GPIO pins the agent can access. This prevents accidental writes to system-critical pins (e.g., I2C, SPI, UART lines):
If the agent tries to access a pin not in allowedPins, the tool returns an error:

Best Practices

  • Always set allowedPins in production to prevent unintended hardware interaction
  • Use descriptive instructions that tell the agent which pins correspond to which hardware:
  • Limit PWM frequency with maxPwmFrequency to protect sensitive components
  • Test in simulation first — use a breadboard with LEDs before connecting to production hardware

Example: LED and Button