I finally managed to set up a raspberry pi 3 as a remote agent. Since I had some difficulty on the road, I’ll share my setup script here to help others with this setup.
Comments
- I’m using a system wide installation of platformio instead of the virtualenv installation, because a) it’s the only way I could get it to work and b) I’m not using the raspi for anything else.
- Some of the insallation steps can take quite a while on the raspi, be patient!
Prerequisites
- Raspberry Pi 3
- SD card with at least 4GB space (2GB is not enough)
- rpi-imager installed
Steps
- Use rpi-imager to prepare the sd card
- Select “Raspberry Pi OS (32-bit) Lite”
- This guide was created using Version: August 2020
- Mount the sd card and open the boot partition
- Setup wifi (if needed)
- in the boot partition, create
ẁpa_supplicant.conf
file with the wlan config:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>
network={
ssid="<Name of your wireless LAN>"
psk="<Password for your wireless LAN>"
}
- In the boot partition, create an empty file called
ssh
to enable ssh on boot. - Insert the card into the raspberry pi and connect the power. The raspi will boot up and do the initial setup.
- Connect via ssh
ssh pi@raspberrypi
- the initial password is
raspberry
- Set a new password
passwd
- Install platformio
# update system
sudo apt update
sudo apt upgrade -y
# install required packages
sudo apt install python3-pip libffi-dev libssl-dev
# install platformio
sudo pip3 install platformio
# install required libraries for the remote agent
pio remote agent
- Get the platformio auth token (you can do this on any computer)
# login to platformio
pio account login
# get the auth token
pio account token
- save the token for the next step
- Install the remote agent as a service
- create a file
/etc/systemd/system/pio-remote.service
:
[Unit]
Description=pio remote agent
Requires=network-online.target
After=network-online.target
[Service]
Type=simple
User=pi
Group=pi
Environment="PLATFORMIO_AUTH_TOKEN=<insert your auth token from last step>"
WorkingDirectory=/home/pi
ExecStart=/usr/local/bin/platformio remote agent start
Restart=always
[Install]
WantedBy=multi-user.target
- Start the service
sudo systemctl start pio-remote
- Check that the service is running
systemctl status pio-remote
- In case of errors, check the error log
journalctl -e -t platformio
Done!
The service should be running and you can access the remote agent from any platformio installation by logging in to your account.
Let me know if you have any questions or issues regarding this guide.