Using Platformio for Code Development

I’ve recently been evaluating switching over to PlatformIO for controller code editor. Its Arduino compatible but looks to be a more modern take on embedded development.

A few pros for us:

  • Arduino compatible - works with all of the OpenPPG controllers. (So far tested on the V2 hardware aka SAMD21)
  • Manages dependencies. There are 10+ libraries mentioned in the readme that currently have to be manually installed in the Arduino IDE library manager. (arduino-cli may be an alternative). PlatformIO allows proper dependency management so new setups only have to run one install command.
  • Works with VSCode. I’m basically already using VSCode for actual code development because, well, the Arduino IDE kinda sucks. VSCode is one of the most popular and fastest growing code editors with lots of other plugins too. Plus its all open-source!
  • Modern automation. Besides easy library installs we can get access to automated testing. This is huge because it theoretically allows for anyone to develop OpenPPG code without needing to physically test on the hardware, it can all be run in the “cloud” via free services like CircleCI and Jenkins.

Some drawbacks:

  • Need to restructure some of the code. We’ll probably want to migrate the .ino files to .cpp. It will take extra work to update old branches of the code (eg. batch 2)
  • Less mature than the ArduinoIDE. Its popular but Arduino has been around for a long time.
  • Slightly higher learning curve. There are more settings (which is nice) but it may be daunting for new users (not as nice)

I’d love to hear if anyone has experience with PlatformIO and/or its alternatives!

PS. The X4 hub code wont be touched by this since its already not using Arduino.

5 Likes

that’s neat!
i use PlatformIO in VS code to program my 3d printer’s bigtreetech board. It works well with marlin.
I just change my settings and load the small file on a SD card, plug it into to control board and power it on.
I did have one issue with the memory retaining old setting data. might be the logic controller but it would start up with 8 micro steps even though i set it to 16 or 32 micro stepping. I had to power it up and hit the reset button for it to load my settings correctly. I think a long duration with it unplugged finally fixed the problem
hopefully that’s not an issue with what your using it for.
id like to try it out for real development at some point. it seems easier to flash boards without having to plug it into the computer.

I added a new branch with initial PlatformIO setup.

It also has full support for automated build using Github actions/CI where it downloads the dependency libraries and compiles the binary.
Check out the first run here https://github.com/openppg/eppg-controller/runs/863022382

2 Likes