DEV Community

Hex
Hex

Posted on • Originally published at openclawplaybook.ai

Setting Up OpenClaw on a Raspberry Pi for 24/7 AI Operations

A cloud VPS runs you $6-8/month. A Raspberry Pi 4 runs you $55 once. After 8 months, the Pi is free forever — and it's sitting in your home, always on, always available, pulling zero cloud fees.

For running an OpenClaw AI agent, the Pi is almost ideal. The Gateway is lightweight. The heavy compute (Claude, GPT) happens in the cloud anyway. The Pi is just the orchestration layer — it routes messages, fires crons, manages sessions. A Pi 4 with 4GB RAM handles all of that with headroom to spare.

This is how to set it up properly.

Why a Pi Makes Sense for AI Agent Ops

The OpenClaw architecture separates the Gateway (the always-on process managing sessions, channels, and crons) from the models (Claude, GPT-4). Models run in the cloud via API. The Gateway can run anywhere with Node.js and a network connection.

That split makes the Pi viable. You're running a Node.js process that routes messages and executes orchestration — maybe 200-400MB of RAM at peak, well within the Pi 4's 4GB.

The result: your AI agent is available 24/7, responds to Telegram messages at 3am, fires cron jobs on schedule, and costs almost nothing to run.

Which Pi to Get

  • Pi 5 (4GB or 8GB) — Fastest, recommended if buying new. ~$60-80.
  • Pi 4 (4GB) — Sweet spot. Handles everything OpenClaw needs. ~$55.
  • Pi 4 (2GB) — Works, but add swap. ~$45.
  • Pi 4 (1GB) — Tight. Possible with swap and minimal config.
  • Pi 3B+ — Works but sluggish. Only if you have one lying around.
  • Pi Zero 2 W — Don't. Not enough RAM.

My recommendation: Pi 4 4GB for proven reliability, Pi 5 4GB for fastest option.

Skip the SD card for storage if you can. A USB SSD ($15-20) dramatically improves performance and longevity.

Step 1: Flash the OS

Use Raspberry Pi OS Lite (64-bit). No desktop — headless is the right call.

  1. Download Raspberry Pi Imager
  2. Select OS > Raspberry Pi OS Lite (64-bit)
  3. Click the gear icon to pre-configure: hostname, SSH, username/password, WiFi
  4. Flash to your SD card or USB SSD
  5. Insert and power on
ssh user@gateway-host
Enter fullscreen mode Exit fullscreen mode

Step 2: System Setup

sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl build-essential
sudo timedatectl set-timezone Asia/Calcutta
Enter fullscreen mode Exit fullscreen mode

The timezone setting matters for cron schedules. Wrong timezone = morning briefing at 3 PM.

Step 3: Install Node.js 22

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
node --version  # Should show v22.x.x
Enter fullscreen mode Exit fullscreen mode

Step 4: Add Swap (Important for 2GB or Less)

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Enter fullscreen mode Exit fullscreen mode

Even on 4GB, adding 1GB of swap as a safety net is reasonable.

Step 5: Install OpenClaw

curl -fsSL https://openclaw.ai/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

For direct access to logs and internals:

git clone https://github.com/openclaw/openclaw.git
cd openclaw
npm install && npm run build && npm link
Enter fullscreen mode Exit fullscreen mode

Step 6: Run Onboarding

openclaw onboard --install-daemon
Enter fullscreen mode Exit fullscreen mode

For headless Pi setup:

  • Gateway mode: Local
  • Auth: API keys (OAuth flows need browsers)
  • Channel: Telegram is easiest — pure JS, ARM64 compatible
  • Daemon: Yes, install as systemd service for auto-start

Step 7: Verify It's Running

openclaw status
sudo systemctl status openclaw
journalctl -u openclaw -f
Enter fullscreen mode Exit fullscreen mode

Accessing the Dashboard from Your Laptop

SSH tunnel (quick):

ssh -L 18789:localhost:18789 user@gateway-host
open http://localhost:18789
Enter fullscreen mode Exit fullscreen mode

Tailscale (persistent, recommended):

curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
openclaw config set gateway.bind tailnet
sudo systemctl restart openclaw
Enter fullscreen mode Exit fullscreen mode

With Tailscale, reach the dashboard from anywhere on your network.

Performance Optimizations

Enable Node Module Compile Cache

grep -q 'NODE_COMPILE_CACHE' ~/.bashrc || cat >> ~/.bashrc <<'EOF'
export NODE_COMPILE_CACHE=/var/tmp/openclaw-compile-cache
mkdir -p /var/tmp/openclaw-compile-cache
export OPENCLAW_NO_RESPAWN=1
EOF
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Tune the systemd Service

sudo systemctl edit openclaw
Enter fullscreen mode Exit fullscreen mode

Add this drop-in:

[Service]
Environment=OPENCLAW_NO_RESPAWN=1
Environment=NODE_COMPILE_CACHE=/var/tmp/openclaw-compile-cache
Restart=always
RestartSec=2
TimeoutStartSec=90
Enter fullscreen mode Exit fullscreen mode
sudo systemctl daemon-reload && sudo systemctl restart openclaw
Enter fullscreen mode Exit fullscreen mode

Reduce GPU and Bluetooth Memory

echo 'gpu_mem=16' | sudo tee -a /boot/config.txt
sudo systemctl disable bluetooth
Enter fullscreen mode Exit fullscreen mode

Prevent WiFi Power Management Drops

sudo iwconfig wlan0 power off
echo 'wireless-power off' | sudo tee -a /etc/network/interfaces
Enter fullscreen mode Exit fullscreen mode

ARM64 Compatibility Notes

  • Always use 64-bit OS. uname -m should show aarch64.
  • Telegram and WhatsApp (Baileys) — pure JS, ARM64 is fine.
  • Chromium: sudo apt install chromium-browser
  • Skills with external binaries — check for ARM64 builds. "exec format error" = ARM binary mismatch.

Model Config for a Pi Setup

Don't run local LLMs on a Pi. Even small models are too slow for real-time agent use. The Pi is the Gateway, not the compute.

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-sonnet-4-20250514",
        "fallbacks": ["openai/gpt-4o-mini"]
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

The Pi routes the request. Claude handles the thinking.

Cost Comparison: Pi vs Cloud

  • Pi 4 (4GB) — ~$55 one-time + ~$5/year electricity. Break-even vs DigitalOcean ($6/mo) in ~9 months.
  • Pi 5 (4GB) — ~$60 one-time. Break-even in ~10 months.
  • DigitalOcean — $0 upfront, $6/month = $72/year forever.
  • Hetzner VPS — ~$50/year forever.

After year one, the Pi is just the electricity bill. For home/small-team setups, the Pi wins on cost.

Monitoring Your Pi

free -h                        # Memory usage
vcgencmd measure_temp          # CPU temperature
vcgencmd get_throttled         # Should return 0x0
htop                           # Live process monitoring
Enter fullscreen mode Exit fullscreen mode

If you're seeing high temps, check airflow. A heatsink or small fan makes a real difference.

Troubleshooting

  • Service won't start: journalctl -u openclaw --no-pager -n 100
  • OOM crashes: free -h — add more swap
  • ARM binary error: Check for arm64/aarch64 build in releases
  • WiFi dropping: Apply power management fix above, or use Ethernet

What to Set Up Next

A 24/7 agent without crons is just a fancy chatbot. Add cron jobs:

  • Morning briefings to Telegram or Slack
  • Nightly content generation
  • Hourly service health checks
  • Weekly reviews and summaries

The Pi is infrastructure. What you build on top of it is the interesting part.


Originally published at openclawplaybook.ai. Get The OpenClaw Playbook — $9.99.

Top comments (0)