How to use Raspberry Pi to Program Arduino Over a Network


If you have any sort of Raspberry Pi sitting around, and a need to program or monitor an Arduino board in an awkward location, it’s very easy to get started programming that Arduino over your LAN!

In this guide, I’ll be using a Raspberry Pi Zero W (First generation)

However, these steps should work with any Raspberry Pi.

Set Up Your Pi:

First, you’ll need to write a SD card for your Raspberry Pi. This is easily accomplished using the Raspberry Pi imager located here.

After you have downloaded and installed the Raspberry Pi imager, choose the following options:

First, click “CHOOSE OS” and then click Raspberry Pi OS (other) as shown:

Then, choose “Raspberry Pi OS Lite (32-bit)

Finally, you’ll need to select your SD card location under “CHOOSE STORAGE”

Now click the gear icon in the bottom right of the window to choose what options to apply to the operating system you’re about to burn onto the SD card.

  • Set the hostname to “pi-duino” as shown.
  • Enable SSH and choose “Use password authentication”
  • Make the username “arduino” and set the password to something you’ll remember.
  • If you’re going to be using Wi-Fi then enable wireless LAN and:
    • Input your Wi-Fi’s network name under SSID, carefully.
    • Enter your Wi-Fi password.
    • Select your country code from the dropdown.
  • Finally, hit the checkbox for locale settings and input the appropriate values for your location.

Hit save, then click “WRITE” and sit back and wait a minute.

Connecting to your Pi:

Wait for the SD card to finish writing, and insert it into your Pi.

Plug in power your Pi and give it around ten minutes. This will cover the initial boot and time to get on your network.

Open powershell, if you’re on Windows, and run the following:

ssh arduino@pi-duino.local

You should get a message about a key fingerprint. You can safely respond “yes” to this, and hit enter. You should then be asked for a password.

This whole process should look like this:

Now input your password that you set in the Raspberry Pi Imager for the “arduino” user and hit enter.

Note: Unlike Windows passwords, you won’t see any asterisks appear while you type.

After you’ve input the password and pressed enter, you will now be connected to your Raspberry Pi over your network as shown:

Setting up arduino-cli:

Now that we have a connection to the Pi, run the following:

curl -fsSL https://raw.githubusercontent.com/PockyBum522/Raspberry-Pi-Arduino-LAN-Programming-Platform/main/arduino_platform_setup.sh | sudo sh

Note: Always be careful running scripts from unknown sources, especially when using sudo or su. Check the script contents first.

After the script finishes, your Pi will reboot. When it comes back up, you’ll have arduino-cli set up. You are now ready to compile and upload.

Using arduino-cli:

It also sets up a blink.ino example that you can compile with:

arduino-cli compile -b arduino:avr:uno /home/arduino/arduino/sketches/blink/blink.ino

Then upload using:

arduino-cli upload -p /dev/ttyACM0 -b arduino:avr:uno /home/arduino/arduino/sketches/blink/blink.ino

Useful things:

The script also sets up a basic serial monitor Python script that can be run with:

python3 /home/arduino/arduino/python_serial_monitor.py

Exploring further:

  • For more information on arduino-cli and how to use it, check out their awesome getting started section!
  • If you’d like to help make the setup script better, feel free to submit a pull request here.


One response to “How to use Raspberry Pi to Program Arduino Over a Network”

Leave a Reply

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