Skip to content

plagtech/rtp-pi-demo

Repository files navigation

RTP Pi Demo — Raspberry Pi Servo Robot

An agent pays 0.01 USDC → servo motor rotates → task confirmed → payment released. Physical proof that x402 controls real hardware.

RTP x402 Spraay Raspberry Pi


What This Is

A real, working RTP robot on a Raspberry Pi. AI agents discover it via the Spraay gateway, pay with x402, and a servo motor physically moves. No simulation — real hardware, real payments.


Hardware Shopping List

Everything available on Amazon, total ~$75:

Item Purpose ~Cost
Raspberry Pi 4 (2GB) Runs the RTP SDK $45
32GB microSD card OS storage $10
SG90 Micro Servo Motor The "robot" actuator $6
Breadboard + jumper wires kit Wiring $8
USB-C power supply (5V 3A) Power for Pi $10

Optional but great for the demo video:

Item Cost
Small claw/gripper attachment for servo $8
Pi Camera Module $15

Wiring Diagram

Raspberry Pi GPIO        SG90 Servo
─────────────────        ──────────
Pin 2  (5V)      ──────► Red wire   (power)
Pin 6  (GND)     ──────► Brown wire (ground)
Pin 11 (GPIO 17) ──────► Orange wire (signal)

That's it. Three wires.


Software Setup

Step 1 — Flash the SD card

Download Raspberry Pi Imager, flash Raspberry Pi OS Lite (64-bit) to the SD card. Before flashing, click the gear icon and:

  • Enable SSH ✅
  • Set username: pi
  • Set password: something you'll remember
  • Configure WiFi with your network name + password ✅

The Pi connects to your WiFi and you can SSH in immediately — no keyboard or monitor needed.

Step 2 — SSH in and install Node.js

ssh [email protected]

# Update system
sudo apt-get update && sudo apt-get upgrade -y

# Install Node.js 20
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

# Verify
node --version   # should show v20.x.x
npm --version

Step 3 — Clone and install

git clone https://github.com/plagtech/rtp-pi-demo.git
cd rtp-pi-demo
npm install
cp .env.example .env
# Fill in your wallet address and Spraay API key

Step 4 — Make it publicly accessible

The Pi needs a public URL for the webhook. Easiest way:

# Install ngrok
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc
sudo apt-get install ngrok

# Start tunnel
ngrok http 3100
# Copy the https://xxx.ngrok.io URL → set as PUBLIC_IP in .env

Or if you have a static IP, just open port 3100 on your router.

Step 5 — Run it

npx ts-node index.ts

You should see:

🤖 ServoBot-Pi-01 starting up...
✅ Servo homed
📡 Registered as: robo_abc123
💧 x402 endpoint: https://gateway.spraay.app/robots/robo_abc123/task
👂 Listening for tasks on port 3100...

Ready to accept x402 payments 🚀

Step 6 — Test it with an agent

From any machine:

import { RTPClient } from '@spraay/rtp-sdk'

const client = new RTPClient({ wallet: myX402Wallet })

const robots = await client.discover({ capability: 'pick' })
const result = await client.hire(robots[0], {
  task: 'pick',
  parameters: { item: 'test-object' }
})

console.log(result.status)  // COMPLETED
// Servo physically moved ✅

Auto-start on Boot

So the robot is always on and listening:

sudo cp rtp-robot.service /etc/systemd/system/
sudo systemctl enable rtp-robot
sudo systemctl start rtp-robot

Now the robot boots up, connects to WiFi, registers with Spraay, and starts accepting x402 payments — all automatically.


Capabilities

Task What happens Servo position
pick Reach down to grab 0° → home
place Reach across to drop 180° → home
scan Angle for scanning (2s hold) 45° → home
move Go to any angle 0–180° custom angle

Related


Built by Spraay Protocol

About

Raspberry Pi servo robot connected to the x402 payment network — $79 hardware demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors