Arduino has just announced the release of the Arduino CLI version 1.0.0, the first stable release for which users and developers can be confident the software API won’t change over time, or at least with minimal changes that will not impact the workflow of applications based on it.
We first looked at the Arduino CLI when it was still at the alpha stage way back in 2018. Arduino CLI version 1.0.0 was actually quietly released about two months ago, but Arduino only announced it now and the utility is now at version 1.0.4 with several bug fixes.
Arduino CLI 1.0 release
The goal of the API is to easily program the boards from the command line without having to use the Arduino IDE, and the CLI can be integrated into your own script to automatize various processes.
Arduino explains there are three ways to integrate and utilize the capabilities of the utility:
- Command line interface to manage boards and libraries, compile sketches, and upload code to Arduino boards.
- gRPC interface to allows developers to interact with the CLI using their preferred programming language, allowing for the creation of custom applications and services that leverage the full functionality of the Arduino ecosystem. It can notably be used to create custom IDEs or plugins.
- Go module to use Arduino CLI’s packages within custom applications written in the Go programming language.
You’ll find a detailed changelog for Arduino CLI 1.0.0 to 1.0.4 on GitHub.
Testing Arduino CLI with Raspberry Pi Pico 2
I installed Arduino CLI 1.0.4 on my machine, a Ubuntu 22.04 laptop, to give it a quick try. A lot has changed since the alpha version was released six years ago, starting with the installation procedure:
1 2 |
cd ~/edev/arduino curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh |
It will install arduino-cli in the bin directory of the current directory, in my case ~/edev/arduino/bin. Most people should consider installing it in a directory that’s in their PATH.
It has several extra commands such as burn-bootloader, daemon to run the Arduino CLI as a gRPC daemon, upgrade to upgrade installed cores and libraries, and others:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
jaufranc@CNX-LAPTOP-5:~/edev/Arduino/bin$ ./arduino-cli version arduino-cli Version: 1.0.4 Commit: a0d912da Date: 2024-08-12T13:42:36Z jaufranc@CNX-LAPTOP-5:~/edev/Arduino/bin$ ./arduino-cli Arduino Command Line Interface (arduino-cli). Usage: arduino-cli [command] Examples: ./arduino-cli <command> [flags...] Available Commands: board Arduino board commands. burn-bootloader Upload the bootloader. cache Arduino cache commands. compile Compiles Arduino sketches. completion Generates completion scripts config Arduino configuration commands. core Arduino core operations. daemon Run the Arduino CLI as a gRPC daemon. debug Debug Arduino sketches. help Help about any command lib Arduino commands about libraries. monitor Open a communication port with a board. outdated Lists cores and libraries that can be upgraded sketch Arduino CLI sketch commands. update Updates the index of cores and libraries upgrade Upgrades installed cores and libraries. upload Upload Arduino sketches. version Shows version number of Arduino CLI. Flags: --additional-urls strings Comma-separated list of additional URLs for the Boards Manager. --config-dir string Sets the default data directory (Arduino CLI will look for configuration file in this directory). --config-file string The custom config file (if not specified the default will be used). -h, --help help for arduino-cli --json Print the output in JSON format. --log Print the logs on the standard output. --log-file string Path to the file where logs will be written. --log-format string The output format for the logs, can be: text, json (default "text") --log-level string Messages with this level and above will be logged. Valid levels are: trace, debug, info, warn, error, fatal, panic (default "info") --no-color Disable colored output. Use "arduino-cli [command] --help" for more information about a command. |
You’ll be able to perform most tasks done in the Arduino IDE from the command line. Let’s follow the getting started guide in the documentation by first creating a default configuration file for arduino-cli:
1 2 |
jaufranc@CNX-LAPTOP-5:~/edev/Arduino$ arduino-cli config init Config file written to: /home/jaufranc/.arduino15/arduino-cli.yaml |
We can check the content of the YAML file:
1 2 3 |
jaufranc@CNX-LAPTOP-5:~/edev/Arduino$ cat ~/.arduino15/arduino-cli.yaml board_manager: additional_urls: [] |
I have a Raspberry Pi Pico 2 board on my desk, so let’s try since it is supported by the Raspberry Pi Pico Arduino Core 4.0.x. I manually added the board URL to the YAML file:
1 2 |
additional_urls: - https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json |
But after further reading the documentation, I noticed it’s possible to add a board URL (e.g. for ESP32) as follows:
1 |
arduino-cli core update-index --additional-urls https://espressif.github.io/arduino-esp32/package_esp32_index.json |
We can update the local cache of selected platforms and libraries:
1 2 3 |
jaufranc@CNX-LAPTOP-5:~/edev/Arduino$ arduino-cli core update-index Downloading index: package_index.tar.bz2 downloaded Downloading index: package_rp2040_index.json downloaded |
Let’s create a sketch directory…
1 2 |
$ arduino-cli sketch new cnxsoft-sketch cd cnxsoft-sketch/ |
… and write a blink sample in the just created cnxsoft-sketch.ino file:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } |
Let’s connect the Raspberry Pi Pico 2 to the laptop in bootloader mode. The board should be listed:
1 2 3 |
$ arduino-cli board list Port Protocol Type Board Name FQBN Core UF2_Board uf2conv UF2 Devices Unknown |
I was hoping for something nicer, but maybe it’s because it’s a generic RP2350 board:
1 2 3 4 5 6 |
./arduino-cli board search rp2350 Board Name FQBN Platform ID Generic RP2350 rp2040:rp2040:generic_rp2350 rp2040:rp2040 Solder Party RP2350 Stamp rp2040:rp2040:solderparty_rp2350_stamp rp2040:rp2040 Solder Party RP2350 Stamp XL rp2040:rp2040:solderparty_rp2350_stamp_xl rp2040:rp2040 SparkFun ProMicro RP2350 rp2040:rp2040:sparkfun_promicrorp2350 rp2040:rp2040 |
The FQBN (Fully Qualified Board Name) is the important part as we’ll need it to compile our sample:
1 2 3 4 5 6 |
jaufranc@CNX-LAPTOP-5:~/edev/Arduino$ arduino-cli compile --fqbn rp2040:rp2040:generic_rp2350 cnxsoft-sketch Sketch uses 49840 bytes (0%) of program storage space. Maximum is 16769024 bytes. Global variables use 9764 bytes (1%) of dynamic memory, leaving 514524 bytes for local variables. Maximum is 524288 bytes. Used platform Version Path rp2040:rp2040 4.0.1 /home/jaufranc/.arduino15/packages/rp2040/hardware/rp2040/4.0.1 |
It looks good so far. The final step is to upload the firmware to the Raspberry Pi Pico 2 board:
1 2 3 4 5 6 |
jaufranc@CNX-LAPTOP-5:~/edev/Arduino$ arduino-cli upload -p /media/jaufranc/RP2350/ --fqbn rp2040:rp2040:generic_rp2350 cnxsoft-sketch Converting to uf2, output size: 112128, start address: 0x2000 Scanning for RP2040 devices Flashing /media/jaufranc/RP2350 (RP2350) Wrote 112128 bytes to /media/jaufranc/RP2350/NEW.UF2 New upload port: /media/jaufranc/RP2350/ (serial) |
That’s it, and the built-in LED of my board is indeed blinking now. That was relatively easy to get started, and it may boost the productivity of people preferring to work from the command line compared to using the Arduino IDE.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
Interesting. Actually it’s not just working from the command line, it’s also using your editor of choice.
Which, in this case, is anything other than the Arduino IDE. Maybe i’m being an inflexible baby, but i have trouble working in that environment. It’s nice, but just not for me. YMMV etc.
written on GO !?!
Sono pazzi questi Romani 🙂