Arduino Releases Command Line Interface (CLI) Alpha Preview

So far, AFAIK the only official ways to program Arduino boards were through the Arduino IDE program, or the cloud-based Arduino Create which works in your web browser and does not require any installation on your computer.

While graphical interfaces are nice and user-friendly, many of us are more productive while working using the command line,  especially if commands can be scripted. So Arduino decided to work on a command line interface (CLI) for professional users, and have just announced a preview release.

arduino-cli

arduino-cli works in Windows, Linux, and Mac OS, and allows you install libraries, boards, and cores (e.g. esp32 Arduino core), compile the code, and upload the binary to the target board.

If you want to get started quickly, you can download the binary “alpha” releases in the announcement board, but instead I opted to build the client myself as explained on Github. Everything below is done in Ubuntu 18.04.


I don’t have a board handy right now, so I’ll just try some commands to create new project, install boards, and build the code again mostly following the README in github.

  • Creating a new sketch


This create a Sketch with minimal code:

  • Modifying the code with vi/emacs, or other editors

  • Finding core and install it:


There’s no ESP32, so I used esp8266 instead, and it’s already installed on my system so nothing to do here if you plan to go with ESP8266, but if you had another board with the core not installed, that’s how we’d go:

  • Listing and installing libraries

Command the list already installed libraries:


Command to search for a library to install:


Installing the library:

  • Building our sketch for MKR1000

  • Checking board connection

While I don’t have a board here with me, I do has a USB to TTL debug board detected by the following command:


It shows “unknown” because it’s not an Arduino board, but you’d have the same results if the Arduino core for your board was not installed for example. If it is, the board name will be displayed.

  • JSON parsing

They also implemented an option to output JSON data for parsing by other program. e.g.:


jq is a command line JSON processor used to “beautify” the output.

arduino-cli json

Arduino Command Line Interface is a welcomed development, and it looks to work reasonably well considering it’s still alpha stage software.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
6 Comments
oldest
newest
willy
willy
6 years ago

That’s a great news for two reasons. The first one is that it will significantly simplify CLI usage. I’ve mostly used arduino via the CLI already because their IDE is a real pain to use, the editor almost doesn’t work, it does everything it can to annoy you. So I enabled verbose mode for executed commands, took note of them and placed them inside makefiles. But that was really not trivial to use, especially when it comes to dependencies. So at least now I should be able to compile regular programs without having to edit them in their awful editor.… Read more »

geokon
geokon
6 years ago

Man.. the embedded space is so bizarre, it always seems like they sorta reinvented the wheel instead of using existing tools. They say “Many of you requested a way to use our tools in Makefiles” and then present some weird custom solution of theirs – instead of a way to build a link things in a sane/standard way. They’ve done a LOT of the hard work of making stuff “just-work”, but why didn’t they do all this using the normal tool-chain like CMake/git/GNU-tools/crosstool-NG/etc.? (well the only obvious reason is Arduino/Platformio/and-company try to establish lock in)

zoobab
6 years ago

Normally you do the other way around: first you design the CLI, then you map the GUI on top of it to execute those commands. Here it is the other way around…

I am now building a gitlab-ci example, together with a deployment based on a Kubernetes cluster running on an armbian box for the flashing, stay tuned…

zoobab
6 years ago

Idea: a vim plugin 🙂

errepunto
errepunto
6 years ago

This seems very similar to platformIO…

relghuar
relghuar
6 years ago

Well, I’m using arduino-builder for over a year already, works quite fine once you know how to set up the build.options.json file. Works also perfectly on arm architechtures, so you can for example develop/fix stuff easily directly on the ras-pi board working as a long-term base for your arduino project…

Boardcon Rockchip and Allwinner SoM and SBC products