Arduino Development in Atom Editor

Eli Fatsi, Former Development Director

Article Category: #Code

Posted on

If you've played with Arduinos for more than 5 minutes, you'll know that the provided IDE is not the coolest thing about Arduino. You're more or less stuck with it however as it's the only means of verifying your code is correct, and uploading it on to your device. I set out to change that.

This has to exist already...

There exists a very full featured Atom package for doing all things Arduino - nino. Like stino for Sublime Text, it looks great and I'm sure it would be ... if I could ever get it to work. But new editor versions come out, alongside new versions of Arduino, and new versions of operating systems - I can never get these things to work. Besides, figuring out a solution personally is way more fun!

The Solution

I figured I could accomplish this if I could tackle two smaller tasks.

  1. Compile/Upload Arduino code from the command line
  2. Run terminal commands from Atom with a key binding

Task 1

I discovered PlatformIO as a great solution for this. The only downside is you have to organize your code in a specific file structure (isn't life hard). Aside from that it's exactly what I was looking for -- I can verify, compile, upload code, as well as monitor communication over serial port, all through the command line.

I was tempted to stop here since I could now develop code in any text editor and use the command line for everything else. Free from the constraints of the Arduino editor, life was good. But as some smart person once said:

Hours of programming now can save you minutes of something else later

Task 2

Creating a custom Atom package was incredibly easy. The editor itself does all the boilerplate work for you, this tutorial is solid, and the mass amount of existing open packages are extremely helpful and inspiring as well - all praise open source software!

The package I created, platomformio (get it?), is very simple. It makes use of Atom's BufferedProcess, runs the PlatformIO commands in a separate process, and pipes the output into nice div at the bottom of the editor. The result is that I can work on my code in a fantastic text editor, and build and upload code to Arduino devices without leaving Atom.





Feel free to give this a try for yourself - If you run into any issues, submit an issue and we'll try to get you sorted!

Related Articles