Complete Raspberry Pi OpenClaw Setup
|

Install OpenClaw on Raspberry Pi and Control Arduino with AI (2026 Guide)

Install OpenClaw on Raspberry Pi and use it as an AI agent to write, compile and upload Arduino sketches automatically. Step-by-step guide with security tips.

Last Updated: April 14, 2026 | OpenClaw v2026.4.10 | Raspberry Pi OS Bookworm Lite (64-bit) | Node.js 24.x

I watched my Raspberry Pi write an Arduino sketch, compile it and upload it to a connected board – without me touching a single line of code. That’s what OpenClaw does. This guide walks you through installing OpenClaw on a Raspberry Pi 4 or 5, setting it up properly and using it to automate real Arduino projects through plain English prompts. If you’re into electronics, robotics or home automation and want to stop writing the same boilerplate code over and over, this one’s for you.


Table of Contents

  1. What OpenClaw Actually Is (and Why It’s Different)
  2. What You Need Before Starting
  3. Flash the OS and Connect via SSH
  4. Update the System and Install Dependencies
  5. Install Node.js 24 from NodeSource
  6. Configure Swap Memory – Don’t Skip This
  7. Install OpenClaw on Raspberry Pi
  8. Onboarding and Gateway Configuration
  9. Accessing the OpenClaw Dashboard
  10. Arduino Projects with OpenClaw
  11. Security, Isolation and Safe Configuration
  12. Troubleshooting Common Issues

What OpenClaw Actually Is (and Why It’s Different)

Most people hear “AI agent” and think of a smarter chatbot. OpenClaw isn’t that. When you ask ChatGPT or Claude something, it replies with text and you still have to do the actual work. OpenClaw takes action. It doesn’t just tell you how to blink an LED on an Arduino – it writes the sketch, compiles it and uploads it to the board while you watch.

Programming Arduino with Raspberry Pi OpenClaw

For makers, this is a genuinely big deal. Here’s what it can do on a Raspberry Pi:

  • Write files and save them directly to the Pi’s filesystem.
  • Run terminal commands and shell scripts on your behalf, without you typing them manually.
  • Install Arduino CLI, write a sketch for your specific board, compile it and upload it – all triggered by a single sentence.
  • Search the web for library documentation, pinouts or datasheet information.
  • Send you alerts and confirmations through Telegram or WhatsApp.
  • Run scheduled tasks and monitoring workflows around the clock, even when you’re not there.

The AI processing happens in the cloud through an API provider – Anthropic, Google or others. Your Pi only runs the coordination layer, which is lightweight enough to work fine on a Pi 4. So you’re not trying to run a language model on 4GB of RAM. The Pi just orchestrates everything.

Warning: OpenClaw has deep access to your system. It can read and write files, run shell commands, install software and interact with connected hardware. That’s exactly what makes it useful – and also what makes security configuration non-negotiable. Don’t skip the security section at the end of this guide.


What You Need Before Starting

Get these sorted before you start so you’re not hunting around mid-install:

  • Raspberry Pi 4 (4GB or 8GB) or Pi 5. The 4GB Pi 4 works but it runs closer to its limits during installation. If you have the 8GB version or a Pi 5, use that.
  • MicroSD card – 32GB minimum, Class 10 or A2 rated. A USB SSD is much better for daily use because OpenClaw does a lot of small reads and writes to its database, which wears out SD cards faster than you’d expect.
  • The official Raspberry Pi USB-C power supply. Don’t use a generic phone charger. During the Node.js installation and AI workloads, the Pi draws more current than most cheap chargers can sustain, which causes random reboots and sometimes corrupts the SD card.
  • (Optional) An Arduino board connected via USB. I tested this with an Arduino UNO R4 Minima and an UNO R4 WiFi. Other boards should work too as long as Arduino CLI supports them.
  • (Optional) An API key from a supported LLM provider. Anthropic (Claude) is the most tested option. You’ll need to add at least $5 USD in credits before the key becomes active – more on that later. Google Gemini has a free tier that’s fine for testing.
  • (Optional) A Telegram bot token (worth having). You can create one for free using BotFather on Telegram.

Tip: If you have a USB SSD, boot from it instead of the SD card. The OpenClaw installation takes 15 to 30 minutes on a good SD card. On a USB SSD that drops to about 3 to 5 minutes. It also protects your storage from excessive write cycles over time.


Video Tutorial

If you prefer to follow along visually, I’ve put together a full video walkthrough of this guide on the RootSaid YouTube channel. It covers every step shown here – from flashing the OS all the way through uploading the Arduino sketches with OpenClaw. The written guide below has additional detail on security configuration and troubleshooting that isn’t in the video, so it’s worth keeping this page open alongside.

Prefer reading? Keep scrolling – everything in the video is covered in full below, with all the commands you need.


Flash the OS and Connect via SSH

Download Raspberry Pi Imager on your laptop. Open it, click Choose OS, and select Raspberry Pi OS Lite (64-bit). We’re using Lite because we don’t need a desktop – it saves RAM and CPU that OpenClaw can use instead. And 64-bit is not optional here. Node.js 24 packages from NodeSource are built for ARM64, so 32-bit Raspberry Pi OS will fail partway through installation with errors that aren’t obvious to debug.

Before flashing, click the settings gear icon in Imager and configure everything upfront:

  • Set a hostname – something like openclaw-pi works well.
  • Enable SSH and set your username and password.
  • Add your WiFi credentials if you’re not using Ethernet.
  • Set your locale and timezone – this matters later for scheduled tasks.

Flash, insert the SD card or SSD into the Pi, and power it on. Give it about 60 seconds to boot, then SSH in from your laptop:

ssh your-username@openclaw-pi

If hostname resolution doesn’t work on your network, find the Pi’s IP address from your router’s connected devices list and SSH directly to the IP instead.

Common Mistake: Flashing the 32-bit version of Raspberry Pi OS. The Imager defaults to showing both versions and it’s easy to pick the wrong one. After booting, verify with uname -m – you should see aarch64. If you see armv7l, you’ll need to reflash with the 64-bit version.


Update the System and Install Dependencies

First thing after logging in – update everything and pull in the packages you’ll need for the installation. This group of commands updates the package index and upgrades installed packages, installs git, curl and build-essential (needed to compile native Node modules) and sets your timezone.

sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl build-essential
sudo timedatectl set-timezone Europe/Madrid

Replace Europe/Madrid with your own timezone. Run timedatectl list-timezones to find the exact string you need.

Tip: The timezone setting is easy to skip and annoying to fix later. OpenClaw uses it for scheduled reminders and cron-based automation tasks. If your Pi is set to UTC and you’re in Spain, scheduled tasks will run at the wrong local time.


Install Node.js 24 from NodeSource

OpenClaw needs Node.js 22 or higher. The version that comes with Raspberry Pi OS repositories is usually several major versions behind, so don’t use that. Install directly from NodeSource instead. These two commands add the NodeSource repository for Node.js 24 and then install it.

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

Check it worked:

node --version
npm --version

On my Pi 4 I got v24.14.1 for Node and 11.11.0 for npm. If you see anything below v22, the NodeSource setup didn’t work – rerun the first command and check your internet connection before trying again.

Common Mistake: Running sudo apt install nodejs without adding the NodeSource repository first. This installs the outdated OS-bundled version and OpenClaw will fail during installation with a version compatibility error. Always add the NodeSource repo first.


Configure Swap Memory – Don’t Skip This

This is probably the most important step people skip, and then wonder why the installation freezes. During the npm install phase, OpenClaw downloads and builds a lot of dependencies. On a Pi 4 with 4GB RAM, memory usage spikes enough that without swap the Linux OOM killer just terminates the process silently. You end up staring at a frozen terminal with no idea why.

Its not that bad once you get used to it – but you do need to do it every time you set up a new Pi for this kind of workload. These commands create a 2GB swap file, lock down its permissions, activate it, add it to /etc/fstab so it persists across reboots and set swappiness to 10 (which tells the kernel to use swap only as a last resort, protecting your SD card from unnecessary writes).

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

Confirm it’s active:

free -h

You should see a Swap line showing about 2.0GB total. If it shows 0, run sudo swapon /swapfile again and check for errors in the output.

Warning: I tested skipping this step on a 4GB Pi 4 and the installation hung at around 60% every single time. Adding swap resolved it on the first retry. Even if you have an 8GB Pi, configuring swap is still good practice for any Node.js-heavy workload.


Install OpenClaw on Raspberry Pi

With Node.js and swap in place, you can run the OpenClaw installer. This single command downloads and runs the official install script. It detects your OS, configures npm for user-local installs, downloads OpenClaw and all its dependencies, and sets up the systemd service files.

curl -fsSL https://openclaw.ai/install.sh | bash

Now go make a coffee. Seriously. On a Pi 4 with a good SD card, this takes 15 to 30 minutes. The SD card I/O is the bottleneck and there’s not much you can do about it other than use a USB SSD. To confirm it hasn’t frozen, open a second SSH session and run top – you should see an npm process actively using CPU. As long as that’s there, it’s working.

When it finishes, you’ll see something like this:

✔ OpenClaw npm package installed
✔ OpenClaw installed
🦞 OpenClaw installed successfully (OpenClaw 2026.4.10)!

There’ll be a PATH warning after this. Fix it now so you don’t run into “command not found” later:

echo 'export PATH="/home/YOUR_USERNAME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Swap YOUR_USERNAME for your actual Pi username. Then verify:

openclaw --version

Common Mistake: Pressing Ctrl+C because the terminal has been quiet for a while. There are long silent periods during the npm install where it’s just writing files to disk. Check top in another terminal first. Cancelling mid-install leaves a broken node_modules directory and you’ll need to clean up and start over.


Onboarding and Gateway Configuration

After installation, run the onboarding wizard. The --install-daemon flag registers OpenClaw as a systemd service so the gateway starts automatically on every boot – you don’t want to SSH in and manually start it every time the Pi reboots.

openclaw onboard --install-daemon

Choosing a Setup Mode

The wizard will ask between Quick Start and Manual. For a headless Pi, always choose Manual. Quick Start applies default settings tuned for desktop machines, not servers. Manual mode takes a few extra minutes but gives you control over every setting that matters for a secure, stable deployment.

Model Provider and API Key

Select Anthropic as the provider and choose API Key as the authentication method. OAuth requires a browser login flow and doesn’t work well on a headless Pi. Paste your Anthropic API key when prompted – this key gives OpenClaw access to Claude, so don’t share it with anyone.

Choosing AI Model in OpenClaw

For the model, the wizard will default to claude-sonnet-4-6. Change it to claude-haiku-4-5. It’s faster, cheaper, and more than capable for Arduino sketch generation, shell commands and general maker automation. You can always switch to a more powerful model later in the config file if you find it’s not keeping up.

Important: Your Anthropic account needs a positive credit balance before the API key will work. The minimum top-up is $5 USD. I spent about 30 minutes wondering why OpenClaw wasn’t responding to messages before I realised my account balance was zero. Check console.anthropic.com before you start testing – save yourself the frustration.

Setting Up a Communication Channel

The wizard will ask about channels – this is how you communicate with OpenClaw beyond the web UI. Telegram is the easiest to configure and honestly the most useful in practice because you can recieve messages and send commands from your phone while you’re working on a project. Create a bot using BotFather on Telegram, copy the bot token, and paste it when the wizard asks.

Gateway Configuration

After onboarding, configure the gateway so you can reach the web UI from your laptop. This part trips people up so pay attention here.

openclaw configure --section gateway

Answer the prompts as follows:

  • Where will the gateway run? – Select Local (this machine). If you accidentally select Remote, the gateway will fail to start with exit code 78.
  • Gateway bind mode – Select LAN (All interfaces).
  • Gateway authentication – Select Token and let it generate one. Keep that token private.
  • Tailscale – Select Off unless you’ve already set up Tailscale on this Pi.

Then start the gateway and enable it on boot:

openclaw gateway start
sudo systemctl enable openclaw-gateway.service

Verify it’s running:

openclaw status
openclaw gateway status --deep

Accessing the OpenClaw Dashboard

From the Pi Itself

If you’re using Raspberry Pi Connect for graphical remote access or have a monitor plugged in, open Chromium on the Pi and go to http://127.0.0.1:18789. To get the full URL with the token already in it, run:

openclaw dashboard
Accessing OpenClaw from Raspberry Pi

From Another Device on Your Network

This is where it gets a bit fiddly. Browser security policies block plain WebSocket connections from a remote origin, which means you can’t just type the Pi’s IP address into a browser on your laptop and expect it to work. The cleanest solution is an SSH tunnel.

On your laptop, open a terminal and run:

ssh -N -L 18789:127.0.0.1:18789 your-username@192.168.1.XXX

Replace 192.168.1.XXX with your Pi’s actual IP address. Keep that terminal open – it’s maintaining the tunnel. Then in your laptop’s browser, open:

http://127.0.0.1:18789/#token=YOUR_TOKEN_HERE

Because the browser sees this as a localhost connection, it passes the security checks and the dashboard loads. The openclaw dashboard command outputs the complete URL with the token already included – copy and use that exact string.

Accessing OpenClaw from a different device

Tip: The dashboard shows connected channels, active sessions, installed skills and usage stats. You can also chat directly from the web UI – you don’t need Telegram for basic interaction, but Telegram is much more convenient when you’re moving around the workshop.


Arduino Projects with OpenClaw on Raspberry Pi

This is the part I find most impressive. With an Arduino connected to the Pi via USB, you can describe what you want and OpenClaw figures out the rest – including whether it needs to install Arduino CLI first. It checks, installs if needed, writes the sketch, compiles and uploads. All from a single prompt. Let me show you what I actually ran.

Project 1 – LED Fade on Arduino UNO R4 Minima

I connected an LED to Pin 3 of an Arduino UNO R4 Minima and plugged the board into the Pi via USB. Then in the OpenClaw chat I sent this:

I need you to create and upload an LED fade effect sketch to the Arduino UNO R4 Minima connected to the USB port of this Raspberry Pi. The LED is on Pin 3. Check if all necessary tools are installed, create the code, compile it and upload it. Don’t ask me any questions – just do it and let me know when it’s done.

OpenClaw checked whether Arduino CLI was installed (it wasn’t), installed it, detected the board on the USB port, wrote the fade sketch, compiled it for the R4 Minima, and uploaded it. When it confirmed the upload was done, the LED was already fading. No IDE, no manual compilation, no me typing a single line of code.

If you want to understand what’s happening under the hood, our guide on Arduino CLI for compiling and uploading from the command line covers exactly the commands OpenClaw runs on your behalf.

Project 2 – Arduino UNO R4 WiFi Web Server

Swapped to the Arduino UNO R4 WiFi and sent this prompt:

I’ve connected an Arduino UNO R4 WiFi to this Raspberry Pi via USB. Create an Arduino sketch that sets up a colorful, interactive single-page web server as a homepage for RootSaid Robotics. Use the same WiFi network this Raspberry Pi is connected to. Compile and upload the sketch, find the Arduino’s IP address once it connects, and give me the URL. Don’t ask questions – just execute.

OpenClaw tried to read the WiFi credentials from the Pi’s network configuration. This part is worth knowing: it can usually read the SSID but often can’t read the actual password from /etc/wpa_supplicant/wpa_supplicant.conf without elevated permissions. When that happens, it asks you for the password in the chat. That’s not a bug – just type the password in response and it continues from there.

Once uploaded, it scanned the local network, found the Arduino’s IP address, and shared the full URL. I opened it in a browser and there was the web page – hosted directly on the Arduino UNO R4 WiFi. The whole process from prompt to working URL took a few minutes.

And if Telegram is configured, you can trigger all of this from your phone. Send a message to your bot describing what you want done and it handles it while you’re doing something else. For more on how Arduino and Raspberry Pi talk over USB, see our Arduino and Raspberry Pi serial communication guide.


Security, Isolation and Safe Configuration

I want to spend some time on this because honestly people rush through the security steps and then wonder why something went wrong. OpenClaw is not a toy. It can delete files, modify system config, install software and interact with connected hardware autonomously. That’s the whole point – but it means you need to think about what you’re giving it access to.

Keep It on a Trusted Private Network

Never open port 18789 on your router’s firewall. The OpenClaw gateway is designed for private network use only. If you need access from outside your home, use an SSH tunnel or Tailscale – both encrypt the traffic. Exposing the gateway directly to the internet without additional protection would let anyone who finds the port attempt to connect to your Pi.

Restrict Telegram Access to Yourself

By default, any Telegram user who knows your bot token can send commands to OpenClaw. That’s a problem if the token ever leaks. Fix it by restricting access to your own Telegram user ID. Run openclaw configure --section channels and add your ID under the allowFrom field. You can find your user ID by messaging @userinfobot on Telegram. This one step makes a big difference.

Run OpenClaw as a Non-Root User

The installer sets this up correctly by default – OpenClaw runs as your regular Pi user account. Don’t override this by running openclaw commands with sudo unless a specific operation explicitly requires it. Running the gateway as root gives it unnecessary elevated privileges across the entire system.

Restrict What Commands OpenClaw Can Run

The config file at ~/.openclaw/openclaw.json has a nodes.denyCommands array. Use it to block capabilities you don’t need. For a maker setup focused on Arduino and local automation, you can safely deny things like contacts.add, calendar.add, sms.send and browser automation commands. This limits what OpenClaw can do even if a prompt goes wrong or the bot token gets misused.

Enable the Command Logger

Turn on the command-logger hook during onboarding (or add it later via openclaw configure --section hooks). This keeps a record of every command OpenClaw executes, which is useful both for debugging and for spotting if something ran that you didn’t expect. Check it periodically, especially when you start using new skills or prompts.

openclaw logs --follow

Keep It Updated

OpenClaw releases security patches regularly. Update it with:

npm update -g openclaw
openclaw gateway restart

Run the Built-In Security Audit

OpenClaw has a built-in audit tool. Run it after setup and after any major configuration change:

openclaw security audit

Pay attention to anything flagged as CRITICAL or WARN and fix those before using OpenClaw for anything that matters. When I ran this after my initial setup, it caught the missing Telegram allowlist – fixing that took two minutes but would have left the bot open to anyone who found the token.

Warning: A badly worded prompt, a compromised Telegram token or an exposed gateway port can lead to unintended and irreversible actions on your Pi. Take security configuration seriously – it’s not optional for a tool with this level of system access.


Troubleshooting Common Issues

Installation Freezes and Doesn’t Complete

Check swap is active with free -h. If the Swap line shows 0, the process ran out of memory and was killed. Enable swap (Step 4 above), clean the npm cache with npm cache clean --force and retry. This is the most common cause of a stalled install.

openclaw: command not found After Installation

The npm global bin directory isn’t in your PATH. Add it:

echo 'export PATH="/home/YOUR_USERNAME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Gateway Fails to Start with Exit Code 78

This almost always means the gateway mode is set to remote instead of local – often because the configure wizard was run and Remote was accidentally selected. Run openclaw configure --section gateway, explicitly choose Local (this machine) and restart:

openclaw gateway stop
openclaw gateway start

No Response After Sending a Message

Nine times out of ten this is an empty Anthropic credit balance. Log into console.anthropic.com and check. A zero balance blocks API calls silently – there’s no error in the chat UI. Also check live logs while sending a test message:

openclaw logs --follow

Arduino Not Detected on USB Port

Run arduino-cli board list to check if the board appears. If it shows as Unknown, udev rules for your board probably aren’t installed. For the Arduino UNO R4 series specifically, this occured consistently for me until I added the rule manually:

sudo bash -c 'echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"2341\", ATTRS{idProduct}==\"0069\", GROUP=\"plugdev\", MODE=\"0666\"" > /etc/udev/rules.d/99-arduino-uno-r4.rules'
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo usermod -a -G plugdev YOUR_USERNAME

Log out and back in after the usermod command for the group change to take effect.

Pi Becomes Sluggish After OpenClaw Has Been Running a While

Check memory with htop. If Node.js is using more than 3GB on a 4GB Pi, reduce the number of active skills, make sure you’re using claude-haiku-4-5 rather than a larger model and check whether anything else is running alongside OpenClaw. Don’t try to run a local LLM like Ollama on the same Pi at the same time – see our guide on running Ollama on Raspberry Pi for what to expect from that setup.


Related Guides


Written by Jithin at RootSaid. Last updated April 14, 2026. All steps verified on a Raspberry Pi 4 (4GB) running Raspberry Pi OS Bookworm Lite 64-bit with OpenClaw v2026.4.10, Node.js v24.14.1 and an Arduino UNO R4 Minima and UNO R4 WiFi connected via USB. Questions or issues? Drop them in the comments.


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *