Arudino Development using PlatformIO IDE

Because getting started should not be a struggle

Dave Newson - August 1st 2016

I have two fundamental issues with the "Getting Started" part of AVR (Arduino, Teensy) development;

  • Setting up the toolchain, and making it work with your IDE.
  • Setting up an IDE that won't make your eyes bleed, and making it work with the toolchain.

Ok, so really that's one massive thing, but while the toolchain is a requirement-of-entry, your choice of IDE should be entirely personal choice.

Getting both to play nicely together is, sometimes, like trying to teach gentry to Beavis and Butthead.

Problem example: Teensy 3.2

If you haven't noticed, I have a lot of love for the Teensy 3.2.

The PJRC Website, has a Getting Started Guide in which they tell you how to get the Teensy development toolchain up and running:

  • Install the Arduino software (including IDE)
  • Install any additional drivers you need for your OS.
  • Install the Teensyduino software

From here, you can use the Arduino IDE to write code, and the Teensy uploader is automagically hooked in, which sends the code to your plugged-in Teensy.

Whats wrong with the setup process?

Technically, nothing.

Practically, lots of things. I really cannot convey how much I truly dislike the Arduino IDE.
I should mention that I come from web-dev land where my IDE of choice helps me jump around, debug, modularised and manage my code with ease. The Arduino IDE helps me with none of this, and comes in a close second to Notepad as my least-favourite way to write code.

What about using a different IDE?

That's fine, you can try and use something like Eclipse or VisualStudio or CLion instead (oh, how I wanted to like you, CLion), but you've got to fight with the configurations and spend time making the toolchain work nicely.
Some might say "setting up VS isn't that hard", but again, VS is not my IDE of choice.

I'm also very strongly of the opinion that toolchain setup should be near instant and as hands-off as possible on the first go. In web-land you might liken this to using Vagrant to bring up a developer environment for a new starter. It's always better to begin with things working and not knowing how, and then giving you the option to customise and explore, than to lose days setting things up.

Yes, Arduino IDE and Teensy do give you this in some manner, but you end up with a crippled IDE. I want to use an IDE that I actually like, and that actually helps me to write code.

Further to that, I just want to write code.


PlatformIO is advertised as an "Environment for Internet of Things development", which isn't very informative.

What you actually get:

  • Cross-platform development environment (Window, Mac, Linux)
  • Automatic installation of toolchains for a huge variety of hardware
  • Build-in serial monitor, terminal, debugger
  • Integrated, professional IDE
  • And most importantly: super easy setup

There are 3 options for installing PlatformIO;

  • PlatformIO CLI: Use PlatformIO from the command-line, and keep it clean and separate.
  • PlatformIO Integration: Integration with a number of your favourite IDEs.
  • PlatformIO IDE: Use PlatformIO as part of its own IDE (using Atom, a powerful open-source IDE).

PlatformIO IDE gives you the greatest amount of power in the least amount of work, so let's take a quick look at that.

Installing PlatformIO IDE

Consider reading the PlatformIO Installation Guide, which is no doubt better than this one.

Dependencies (Python 2.7)

PlatformIO requires Python 2.7. Some people see this as a hinderence, but come on. It's Python. Live a little.

When installing on Windows, don't forget to enable the "Path" option.

Enabling Path registration during Python Install

If you happen to forget to install Python first, PlatformIO will badger you to install it. You may need to reboot before PlatformIO can find it, if you do it that way around.


Install it, and you're done.

Under windows you'll find the IDE under "Atom" on your start menu.

Using PlatformIO

Consider reading the official PlatformIO Getting Started Guide, which will no doubt be better than this one.

Let's take a look at everyones favourite bad example; a blink script.

Create a Project

From the PlatformIO homepage, click the Project Examples button.

PlatformIO IDE Homepage

Select an example project from the list. We'll be using amtelavr-and-arduino\ardunio-blink.

PlatformIO IDE Example Project Selection

PlatformIO IDE Example Project Selection

When initialising the project PlatformIO will take a little while to download the required toolchain. Once this finishes, your IDE should look like this:

Clicking on the src/main.cpp you should see your code:

Hardware toolchain

For my Teensy I need to install the toolchain for the Teensy hardware. Let's do this now.

Click the "Initialise new PlatformIO project or modify existing ... " button, or find the same option in the PlatformIO menu.

Next, find the Teensy 3.2 in the "Select board" drop-down, to add support to your project.

Finally, you'll need to change your build target, in order for the code to build onto the teensy.

Find the "Build Target" button in the very bottom-left of the IDE.

All done.

Run your code

Hit the "Upload" button, and your code should be compiled and sent to your hardware. Awesome.

Why PlatformIO

Hopefully this article has given you a really quick insight into how easy it is to get off the ground when you use PlatformIO; the environment feels easy, professional, and I didn't have to mess around with anything complicated.

I love that PlatformIO and Atom are all open-source tools, too. Unlike some closed-source counterparts, if you encounter a problem and it annoys you enough you can try to submit a fix, or at least engauge the authors and see if they're willing to solve the problem for you.

This is what Arduino and AVR development should be. Now I can concentrate on the software, and not on all the bridges I need to build.


comments powered by Disqus