DEV Community

Clamper ai
Clamper ai

Posted on • Originally published at clamper.tech

Setting Up OpenClaw on a Raspberry Pi: Complete Step-by-Step Guide

Run your own AI agent 24/7 on a $35 Raspberry Pi. This guide covers everything from hardware selection to a fully running OpenClaw agent with systemd, security hardening, and performance tuning.


Originally published on clamper.tech


Running an AI agent on a Raspberry Pi sounds like a contradiction. You've got a $35 single-board computer with a fraction of the power of a modern laptop, and you want it to run an autonomous agent that manages your email, monitors your smart home, and sends you reminders. But here's the thing — it works brilliantly, and thousands of people are already doing it.

The reason is simple: OpenClaw doesn't need local GPU power. The heavy lifting — the actual language model inference — happens on remote API servers (Anthropic, OpenAI, Google, or whatever provider you choose). Your Raspberry Pi just needs to run the agent runtime, manage memory files, execute skills, and stay connected to the internet. A Pi 4 with 4GB of RAM handles all of that without breaking a sweat.

This guide walks you through the entire setup from unboxing to a fully running OpenClaw agent. No shortcuts, no hand-waving.

Why a Raspberry Pi?

  • Always-on for pennies. A Raspberry Pi 4 draws about 3-5 watts under typical load. That's roughly $5-8 per year in electricity. Compare that to leaving a laptop running 24/7 or paying for a cloud VPS.
  • Your data stays home. Everything — memory files, conversation logs, API keys, skill configurations — lives on hardware you physically control.
  • Dead simple networking. It sits on your home network. It can access local services, smart home devices, NAS, and anything else on your LAN without exposing ports to the internet.
  • Surprisingly capable. The Pi 5 (8GB) or even the Pi 4 (4GB) runs Node.js, Python, shell scripts, and the full OpenClaw runtime without any performance issues.
  • Great learning platform. If you're new to self-hosting, a Pi is the safest way to learn. Worst case, you reflash the SD card and start over in 15 minutes.

What You'll Need

Required Hardware

  • Raspberry Pi 4 (4GB) or Pi 5 (4GB/8GB) — Don't bother with the 2GB model.
  • MicroSD card (32GB minimum, 64GB recommended) — Samsung EVO Select or SanDisk Extreme.
  • USB-C power supply — Use the official one. Underpowering causes random crashes.
  • Ethernet cable or WiFi — Wired is more reliable.
  • A case with passive cooling — Flirc case or aluminum heatsink case.

Optional but Recommended

  • USB SSD (120GB+) — Boot from SSD instead of microSD. Night and day difference.
  • UPS hat or battery backup — PiSugar or Geekworm UPS hats.

Step 1: Flash the Operating System

We're using Raspberry Pi OS Lite (64-bit). No desktop environment needed for a headless agent server.

  1. Download Raspberry Pi Imager
  2. Choose OS → Raspberry Pi OS (other) → Raspberry Pi OS Lite (64-bit)
  3. Click the gear icon for advanced options:
    • Set hostname: openclaw
    • Enable SSH with password authentication
    • Set username and strong password
    • Configure WiFi if needed
  4. Flash and insert into Pi

Step 2: Connect via SSH

ssh pi@openclaw.local
# Or use IP: ssh pi@192.168.1.xxx
Enter fullscreen mode Exit fullscreen mode

Run initial updates:

sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl wget build-essential
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Node.js

OpenClaw requires Node.js 18+:

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

node --version  # v22.x.x
npm --version   # 10.x.x
Enter fullscreen mode Exit fullscreen mode

Step 4: Install OpenClaw

npm install -g openclaw
mkdir -p ~/.openclaw/workspace
cd ~/.openclaw/workspace
openclaw init
Enter fullscreen mode Exit fullscreen mode

The init wizard asks for your model provider, API key, and messaging channel. A minimal config:

# ~/.openclaw/config.yaml
model:
  default: anthropic/claude-sonnet-4-20250514
  provider:
    anthropic:
      apiKey: sk-ant-your-key-here

channels:
  telegram:
    botToken: "123456:ABC-your-bot-token"
    allowedUsers:
      - your_telegram_username

workspace:
  path: ~/.openclaw/workspace
Enter fullscreen mode Exit fullscreen mode

Step 5: Configure for Low-Resource Usage

# Increase swap (important for 4GB Pi)
sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=2048/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
free -h  # Should show 2GB swap
Enter fullscreen mode Exit fullscreen mode

Optimization tips:

  • Use a smaller default model (Haiku, GPT-4o-mini) for routine tasks
  • Set heartbeat intervals to 30-60 minutes
  • Limit concurrent sub-agents to 1-2

Step 6: Install Essential Skills

npm install -g clawhub
clawhub search
clawhub install weather
clawhub install quick-reminders
clawhub install imap-smtp-email
clawhub install github
Enter fullscreen mode Exit fullscreen mode

If you're using Clamper, sync your config across devices:

npm install -g clamper
export CLAMPER_API_KEY="your-key"
clamper sync
Enter fullscreen mode Exit fullscreen mode

Step 7: Start as a System Service

Create a systemd service so OpenClaw starts on boot and restarts on crash:

sudo tee /etc/systemd/system/openclaw.service > /dev/null << 'EOF'
[Unit]
Description=OpenClaw AI Agent
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/.openclaw/workspace
ExecStart=/usr/bin/openclaw gateway start --foreground
Restart=always
RestartSec=10
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw
sudo systemctl status openclaw
Enter fullscreen mode Exit fullscreen mode

Check logs: journalctl -u openclaw -f

Step 8: Secure Your Pi

SSH Hardening

ssh-keygen -t ed25519          # on your main computer
ssh-copy-id pi@openclaw.local  # copy key to Pi

# Disable password auth
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo systemctl restart sshd
Enter fullscreen mode Exit fullscreen mode

Firewall

sudo apt install -y ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw enable
Enter fullscreen mode Exit fullscreen mode

Automatic Updates

sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
Enter fullscreen mode Exit fullscreen mode

Step 9: Monitor and Maintain

Temperature

vcgencmd measure_temp  # Stay below 70°C
Enter fullscreen mode Exit fullscreen mode

Disk Space

df -h /
sudo journalctl --vacuum-time=7d
Enter fullscreen mode Exit fullscreen mode

SD Card Health

  • Move to USB SSD boot — the single biggest reliability improvement
  • Mount /tmp as tmpfs to reduce writes
  • Keep ~/.openclaw/ backed up

Performance: What to Expect

Real numbers from a Pi 4 (4GB) with 6 skills:

  • Memory: ~800MB idle, ~1.2GB active
  • CPU: 2-5% idle, 15-30% during skill execution
  • Response time: Identical to desktop — bottleneck is API latency, not local processing
  • Boot to ready: ~45 seconds
  • Uptime: Months without issues (on SSD)

Common Troubleshooting

Issue Fix
Agent won't start Check node --version (18+), openclaw gateway status, logs
High memory Increase swap, limit sub-agents, use lighter model
SD corruption Switch to USB SSD, enable fsck, keep backups
WiFi drops Use Ethernet, disable power save: sudo iw wlan0 set power_save off

What People Are Building

  • Home automation hub — MQTT sensors, lights, thermostat control
  • Email assistant — Inbox triage every 30 min, draft replies, flag urgent
  • Dev monitor — GitHub issues, CI status, daily standup summaries
  • Family calendar — Shared Google Calendar management, reminders

Wrapping Up

A Raspberry Pi running OpenClaw is one of the best cost-to-value setups in the AI agent space. Under $50 in hardware, a few dollars a month in API costs, and you get a personal AI assistant that's always on, fully private, and infinitely customizable.

If you want a dashboard to manage your Pi-hosted agent — track costs, sync skills, monitor usage — check out Clamper. It works from any browser, so you can manage your Pi agent from your phone.

FAQ

Can I run OpenClaw on a Raspberry Pi Zero?
Technically yes, but not recommended. The Pi Zero 2 W has only 512MB RAM, which is tight. Stick with Pi 4 (4GB) minimum.

Do I need a monitor?
No. Fully headless via SSH. The Pi can sit in a drawer.

How much will API costs be?
Light personal use runs $5-15/month with Claude Sonnet. Haiku for routine tasks cuts that significantly.

Can I run local LLMs on the Pi?
Small models (<3B params) can run on Pi 5 8GB via Ollama, but quality is lower. Better to use Pi as runtime + point to a local LLM server on a more powerful machine.

Is it safe to expose my Pi to the internet?
OpenClaw doesn't need inbound connections. Use a VPN (WireGuard or Tailscale) for remote access instead of exposing ports.

Top comments (0)