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 two things that most people conflate: the Gateway (the always-on process that manages your agent's sessions, channels, and crons) and the models (Claude, GPT-4, whatever you're using). Models run in the cloud via API. The Gateway can run anywhere with Node.js and a network connection.
That split is what makes the Pi viable. You're not running inference on the Pi — you're running a Node.js process that routes messages and executes orchestration. That's maybe 200–400MB of RAM at peak, well within the Pi 4's 4GB.
The practical 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. No cloud bill, no SSH into a VPS to restart a crashed service, no worrying about whether your laptop is awake.
Which Pi to Get
Here's the honest breakdown from the OpenClaw docs:
- Pi 5 (4GB or 8GB) — Fastest, recommended if you're buying new. ~$60–80.
- Pi 4 (4GB) — Sweet spot. Handles everything OpenClaw needs, widely available, proven. ~$55.
- Pi 4 (2GB) — Works, but add swap (covered below). ~$45.
- Pi 4 (1GB) — Tight. Possible with swap and a minimal config, but you'll feel it.
- 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 if you want proven reliability, Pi 5 4GB if you want the fastest option. Either will run OpenClaw without issues.
One more thing: skip the SD card for storage if you can. A USB SSD ($15–20) dramatically improves performance and longevity. SD cards wear out under constant read/write. An SSD lasts years.
Step 1: Flash the OS
Use Raspberry Pi OS Lite (64-bit). No desktop — you don't need it and it just wastes RAM. Headless is the right call.
- Download Raspberry Pi Imager
- Select OS → Raspberry Pi OS Lite (64-bit)
- Click the gear icon (⚙️) to pre-configure before flashing:
- Hostname: something like
gateway-host - Enable SSH (password or key-based)
- Set your username and password
- WiFi credentials if you're not on Ethernet
- Hostname: something like
- Flash to your SD card or USB SSD
- Insert and power on
Pre-configuring in the imager saves you from needing a monitor and keyboard. SSH in from your laptop once it boots.
ssh user@gateway-host
# or by IP
ssh user@192.168.x.x Step 2: System Setup
# Update everything first
sudo apt update && sudo apt upgrade -y
# Install essentials
sudo apt install -y git curl build-essential
# Set your timezone (critical for cron schedules)
sudo timedatectl set-timezone Asia/Calcutta The timezone setting matters a lot if you're using OpenClaw's cron system. Wrong timezone means your morning briefing fires at 3 PM. Set it correctly now.
Step 3: Install Node.js 22
OpenClaw requires Node.js 22. Install it via NodeSource — the Pi OS default is usually outdated:
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
# Verify
node --version # Should show v22.x.x
npm --version Step 4: Add Swap (Important for 2GB or Less)
If you're on a 2GB Pi, swap prevents out-of-memory crashes during peak activity:
# Create a 2GB swap file
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Make it permanent across reboots
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# Reduce swappiness so RAM is preferred over swap
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p Even if you have 4GB, adding 1GB of swap as a safety net is a reasonable call. It costs nothing.
Step 5: Install OpenClaw
curl -fsSL https://openclaw.ai/install.sh | bash That's it for the standard install. If you want direct access to logs and internals (useful for debugging ARM-specific issues), use the hackable install instead:
git clone https://github.com/openclaw/openclaw.git
cd openclaw
npm install
npm run build
npm link Step 6: Run Onboarding
openclaw onboard --install-daemon The wizard walks you through everything. For headless Pi setup, a few specific recommendations:
- Gateway mode: Local
- Auth: API keys. OAuth flows are designed for browsers and can be finicky on headless installs.
- Channel: Telegram is the easiest to start with — pure JS, works on ARM64 with zero issues.
- Daemon: Yes. Install as a systemd service so it auto-starts on boot.
Step 7: Verify It's Running
# Check status
openclaw status
# Check the systemd service
sudo systemctl status openclaw
# Follow logs live
journalctl -u openclaw -f If the service is running and you can see activity in the logs, you're live. Your agent is now running 24/7 on your Pi.
Accessing the Dashboard from Your Laptop
The Pi is headless, so you can't just open localhost:18789. Two options:
SSH tunnel (quick):
# From your laptop
ssh -L 18789:localhost:18789 user@gateway-host
# Then open in your browser
open http://localhost:18789 Tailscale (persistent, recommended):
# On the Pi
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
# Update OpenClaw config to bind to the Tailscale network
openclaw config set gateway.bind tailnet
sudo systemctl restart openclaw With Tailscale, you can reach the dashboard from anywhere — your laptop, phone, any device on your Tailscale network. No port forwarding, no dynamic DNS headaches.
Performance Optimizations
The Pi handles OpenClaw fine out of the box, but a few tweaks make a meaningful difference.
Enable Node Module Compile Cache
On lower-power Pi hosts, the OpenClaw CLI startup can be slow on the first few runs. The module compile cache speeds up subsequent invocations:
grep -q 'NODE_COMPILE_CACHE=/var/tmp/openclaw-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 OPENCLAW_NO_RESPAWN=1 avoids the extra startup overhead from CLI self-respawn. First run warms the cache; every run after that is noticeably faster.
Tune the systemd Service
sudo systemctl edit openclaw 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 sudo systemctl daemon-reload
sudo systemctl restart openclaw The Restart=always policy means the Gateway auto-recovers if it crashes for any reason. Critical for true 24/7 ops.
Reduce GPU and Bluetooth Memory
# Reduce GPU memory allocation (no display needed)
echo 'gpu_mem=16' | sudo tee -a /boot/config.txt
# Disable Bluetooth if unused
sudo systemctl disable bluetooth This frees up a few dozen MB of RAM — not massive, but worth doing on a headless server.
Prevent WiFi Power Management Drops
If you're on WiFi (Ethernet is better but not always possible), disable power management to prevent the interface from going to sleep and dropping your connection:
sudo iwconfig wlan0 power off
# Make it permanent
echo 'wireless-power off' | sudo tee -a /etc/network/interfaces ARM64 Compatibility Notes
Most OpenClaw functionality works on ARM64 without any extra steps. A few things to know:
- Always use 64-bit OS. Check with
uname -m— it should showaarch64. If you seearmv7l, you're on 32-bit and Node.js 22 won't work properly. - Telegram and WhatsApp (Baileys) — pure JS, ARM64 is fine.
- Chromium (browser tool) — install with
sudo apt install chromium-browser. Works on ARM64. - Skills with external binaries — check if the binary has an ARM64 build. Most modern Go/Rust tools do. If you get "exec format error" from a skill, that's an ARM binary mismatch.
Model Config for a Pi Setup
One thing to be explicit about: don't run local LLMs on a Pi. Even small models like Llama 3 7B are too slow for real-time agent use. The Pi is the Gateway, not the compute.
Your model config should point to cloud APIs:
The Pi routes the request. Claude handles the thinking. That's the right division of labor.
Cost Comparison: Pi vs Cloud
Here's the honest math:
- Pi 4 (4GB) — ~$55 one-time + ~$5/year in electricity. Break-even vs DigitalOcean ($6/mo) in about 9 months.
- Pi 5 (4GB) — ~$60 one-time. Break-even in ~10 months.
- DigitalOcean droplet — $0 upfront, $6/month = $72/year forever.
- Hetzner VPS — €3.79/month = ~$50/year forever.
After year one, the Pi is just the electricity bill. If you're running a long-lived agent setup — and you should be — the Pi wins on cost. The tradeoff is that it's physical hardware you're responsible for. If it overheats, floods, or gets unplugged, that's on you. Cloud VPS handles uptime for you.
For most home/small-team setups, the Pi is the better call. For production-critical operations where uptime guarantees matter, consider a VPS or pair a Pi with a cloud fallback.
Monitoring Your Pi
# Memory usage
free -h
# CPU temperature (watch for throttling)
vcgencmd measure_temp
# Check for CPU throttling
vcgencmd get_throttled
# Should return 0x0 — anything else means the Pi is/was throttled
# Live process monitoring
htop If you're seeing high temperatures, check your enclosure and airflow. The Pi 4 runs warm — a heatsink or small fan makes a real difference. Throttling kills performance and will cause slowdowns you'll notice.
Troubleshooting
Service won't start:
journalctl -u openclaw --no-pager -n 100 Read the last 100 lines of logs. Most start failures are misconfigured API keys or a port already in use.
Out of memory crashes:
free -h If you're near the limit, add more swap (Step 4) or reduce other services running on the Pi.
ARM binary error from a skill:
Check if the skill's external binary has an ARM64 release. Most do — look for an arm64 or aarch64 build in the binary's releases. If not, build from source or run via Docker with ARM support.
WiFi keeps dropping:
Run the power management fix above. Or, better, use Ethernet.
What to Set Up Next
Once your Pi is running, the natural next step is scheduling. A 24/7 agent without crons is just a fancy chatbot. Add cron jobs and it becomes something that actually does work while you sleep:
- Morning briefings delivered to Telegram or Slack
- Nightly content generation
- Hourly service health checks
- Weekly reviews and summaries
Check out the OpenClaw cron guide for exactly how to set those up. And if you haven't connected your agent to a messaging channel yet, the Slack setup guide walks through that step-by-step.
The Pi is infrastructure. What you build on top of it is the interesting part.
Want the complete guide? Get The OpenClaw Playbook — $9.99