Foreword

This development system enables PlatformIO to build the image on the remote computer and run the flashing process remotely. This is especially useful when you want to work from home or you don’t want to run back and forth between the lab and the greenhouse dozen times a day. In my experiemnt, the ESP32 board was connected to a Raspberry Pi 4 SBC in the greenhouse. This development workflow saved me plenty of time as I was able to manage everthing on my cute laptop.

System Requirements

  • OS: Ubuntu Server 20.04
  • Internet connectivity: Netplan setup
  • Packages status: APT (Updated & Upgraded)

Steps

Install PlatformIO by the official installation guide and login pio

Refer to this Installation docs

Install some dependencies

bash
1
sudo apt-get install build-essential libssl-dev libffi-dev python3-dev rustc

Enter the command to build necessary packages

bash
1
pio remote

Link some executables to system path

bash
1
2
3
ln -s ~/.platformio/penv/bin/platformio /usr/local/bin/platformio
ln -s ~/.platformio/penv/bin/pio /usr/local/bin/pio
ln -s ~/.platformio/penv/bin/piodebuggdb /usr/local/bin/piodebuggdb

Create systemd file to autostart the service

bash
1
sudo nano /etc/systemd/system/pio-remote.service

Add the content below

plaintext
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[Unit]
Description=pio remote agent
Requires=network-online.target
After=network-online.target

[Service]
Type=simple
User=ubuntu
Group=ubuntu
Environment="PLATFORMIO_AUTH_TOKEN=Enter_your_token""
WorkingDirectory=/home/ubuntu
ExecStart=/usr/local/bin/platformio remote agent start
Restart=always

[Install]
WantedBy=multi-user.target

Now start the pio-remote service using systemd agent

bash
1
sudo systemctl start pio-remote

Check the service status

bash
1
sudo systemctl status pio-remote

Normally should return "Successfully authorized"
Now enable the systemd service

bash
1
sudo systemctl enable pio-remote

Now reboot the system and check the service status.

References

PlatformIO Docs - Remote Development
PlatformIO Docs - PlatformIO Core (CLI)