Overview
Peripherals implement thePeripheral trait, which provides:
- Connection management: Connect to hardware over serial, native GPIO, or network
- Tool exposure: Each peripheral exposes tools the agent can use
- Health monitoring: Check device connectivity and status
Supported Hardware
ZeroClaw supports multiple hardware platforms:Raspberry Pi GPIO
Native GPIO control via rppal (BCM pin numbering)
STM32 Nucleo
Serial-connected microcontrollers (Nucleo-F401RE, etc.)
Arduino
Arduino Uno and compatible boards
Arduino Uno Q
WiFi-connected Arduino via Bridge app
Step-by-Step Setup
Raspberry Pi GPIO Example
Here’s how the Raspberry Pi GPIO peripheral is implemented (src/peripherals/rpi.rs):
GPIO Read Tool
GPIO Write Tool
Serial Peripheral Communication
For STM32 and Arduino boards, ZeroClaw uses a serial protocol to communicate with firmware:Protocol Format
Commands are JSON-based over serial:Serial Transport
Fromsrc/peripherals/serial.rs:
Arduino Uno Q (WiFi Bridge)
For wireless control, use the Arduino Uno Q Bridge:Setup Bridge
Bridge Configuration
Creating Custom Peripherals
Best Practices
Use appropriate transports
Use appropriate transports
- Serial: STM32, Arduino, ESP32 (reliable, wired)
- Native: Raspberry Pi GPIO (fastest, direct access)
- Bridge/Network: Wireless devices (flexible, may have latency)
Handle connection failures gracefully
Handle connection failures gracefully
Validate pin numbers and ranges
Validate pin numbers and ranges
Use blocking tasks for synchronous hardware APIs
Use blocking tasks for synchronous hardware APIs
Add firmware version checks
Add firmware version checks
Troubleshooting
Permission denied on /dev/ttyACM0 or /dev/ttyUSB0
Permission denied on /dev/ttyACM0 or /dev/ttyUSB0
Add your user to the
dialout group:GPIO access denied on Raspberry Pi
GPIO access denied on Raspberry Pi
Run with appropriate permissions or add user to gpio group:
Serial communication hangs
Serial communication hangs
Check baud rate, connection, and firmware:
Firmware not responding after flash
Firmware not responding after flash
Press reset button on the board after flashing:
Next Steps
Creating Tools
Learn how to create custom tools
Gateway Setup
Expose your agent via HTTP