How to put platformIO on the Gitpod cloud for free

If you have not yet tried Gitpod.io you should. It takes any github site and puts it in a debian linux container in your browser. Free account allows 100 hours per month which is fine for most hobbyist. It does need a Github or Gitlab login.

I have a playlist of how to use it here. My fairly advanced install of PlatformIO, with the Nordic SDK and Openthread is here (Note: These three programs do not inter communicate. The other 2 need nrf-connect for desktop to install on a Nordic nRF52840 USB dongle)

Steps to use Gitpod with PaltformIO

Load any github as a gitpod by simply inserting Dashboard — Gitpod infront of the github url.

Once you have loaded the gitpod you can fully install PlatformIO by entering this python3 command

python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"

These commands work immediately, assuming you have a local (Python3) PlatformIO running with the agent started

pio account login
pio remote agent start

Then on the Cloud Gitpod you can do the following

pio account login
mkdir test
cd test
pio init -b uno
pio remote run -t upload
pio remote device monitor

I use this simple main.cpp file which flashes the UNO LED and shows info on the monitor.

#include <Arduino.h>

void setup() {
  
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  
}


void loop() {

  int sensorValue = analogRead(A0);
  float voltage = sensorValue * (5.0 / 1023.0);
  Serial.print("blink3 fast, A0 Voltage: --> ");
  Serial.println(voltage);
  
  digitalWrite(LED_BUILTIN, HIGH);   
  delay(100);                      
  digitalWrite(LED_BUILTIN, LOW);     
  delay(3000);  
                   
}

Hope this is helpful. I just found out about PlatformIO and I am very impressed with it

2 Likes

Thanks Rocksetta for this quick tuto!
It works well for me, I just add this .gitpod.yml

vscode:
  extensions:
    - ms-vscode.cpptools@0.26.2:Pq/tmf2WN3SanVzB4xZc1g== # to add C/C++ extension

tasks:
  - before: pip3 install -U platformio
    command: platformio run -e eval_f072vb # where eval_f072vb is my variable

@nicoluos and @Antoine have a look here :grinning:

But I still have a issue, I would like to use and automatically importe the PIO extension, not only bash tool and I don’t know how to do. Then I found a .vsix file for PIO but Gitpod always ask me to reload and reload and reload and reload when it’s installing. Could you help me?

4 Likes

Being able to import the PIO extension would be nice, however, it may take a little more effort.
I used the following dockerfile to install platformio core

FROM gitpod/workspace-full

USER gitpod

ENV PIP_USER=false
ENV PLATFORMIO_PENV_DIR=/home/gitpod/.platformio
ENV PATH="${PLATFORMIO_PENV_DIR}/bin:${PATH}"
RUN python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"

The plugin will load but points to the wrong url. It’s very likely that gitpod port forward causes this problem.

A temporary solution would be using pio home directly without using the extension. However, currently pio home generates wrong backend url for websocket over https. I would imagine this to be a simple patch.