arduino-cli
is an all-in-one solution that provides builder, boards/library manager, uploader, discovery and many other tools needed to use any Arduino compatible board and platforms.
This software is currently in alpha state: new features will be added and some may be changed.
It will be soon used as a building block in the Arduino IDE and Arduino Create.
This is not yet available until the first stable version is released.
- You should have a recent Go compiler installed.
- Run
go get -u github.com/bcmi-labs/arduino-cli
- The
arduino-cli
executable will be produced in$GOPATH/bin/arduino-cli
You may want to copy the executable into a directory which is in your PATH
environment variable
(such as /usr/local/bin/
).
The goal of the Arduino CLI is to be used by either including it in Makefile or in any kind of script for the Command Line. The Arduino CLI aims to replace the majority of features the Arduino IDE has without the graphical UI.
The command will create a new empty sketch named MyFirstSketch in the default directory under $HOME/Arduino/
$ arduino-cli sketch new MyFirstSketch
Sketch created in: /home/luca/Arduino/MyFirstSketch
$ cat /home/luca/Arduino/MyFirstSketch/MyFirstSketch.ino
void setup() {
}
void loop() {
}
Use your favourite file editor or IDE to modify the .ino file under: $HOME/Arduino/MyFirstSketch/MyFirstSketch.ino
and change the file to look like this one:
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Just connect the board to your PCs by using the USB cable. In this example we will use the MKR1000 board.
$ arduino-cli board list
FQBN Port ID Board Name
/dev/ttyACM0 2341:804E unknown
the board has been discovered but we do not have the correct core to program it yet. Let's install it!
We have to look at the core available with the core search
command. It will provide a list of available cores matching the name arduino
$ arduino-cli core search arduino
Searching for platforms matching 'arduino'
ID Version Installed Name
Intel:arc32 2.0.2 No Intel Curie Boards
arduino:avr 1.6.21 No Arduino AVR Boards
arduino:nrf52 1.0.2 No Arduino nRF52 Boards
arduino:sam 1.6.11 No Arduino SAM Boards (32-bits ARM Cortex-M3)
arduino:samd 1.6.18 No Arduino SAMD Boards (32-bits ARM Cortex-M0+)
arduino:stm32f4 1.0.1 No Arduino STM32F4 Boards
littleBits:avr 1.0.0 No littleBits Arduino AVR Modules
The right one for the Arduino MKR1000 is arduino:samd, now we can install it
$ arduino-cli core install arduino:samd
Downloading tools...
arduino:[email protected] downloaded
arduino:[email protected] downloaded
arduino:[email protected] downloaded
arduino:[email protected] downloaded
arduino:[email protected] downloaded
arduino:[email protected] downloaded
Downloading cores...
arduino:[email protected] downloaded
Installing tools...
Installing platforms...
Results:
arduino:[email protected] - Installed
arduino:[email protected] - Already Installed
arduino:[email protected] - Already Installed
arduino:[email protected] - Already Installed
arduino:[email protected] - Already Installed
arduino:[email protected] - Already Installed
arduino:[email protected] - Already Installed
Now verify we have installed the core properly by running
$ arduino-cli core list
ID Installed Latest Name
arduino:samd 1.6.18 1.6.18 Arduino SAMD Boards (32-bits ARM Cortex-M0+)
We can finally chek if the board is now recognized as a MKR1000
$ arduino-cli board list
FQBN Port ID Board Name
arduino:samd:mkr1000 /dev/ttyACM0 2341:804E Arduino/Genuino MKR1000
Great! Now the Board FQBN (Fully Qualified Board Name) and the Board Name look good, we are ready to compile and upload the sketch
To compile the sketch we have to
arduino-cli
is a container of commands, to see the full list just run:
$ arduino-cli
Arduino Command Line Interface (arduino-cli).
Usage:
arduino-cli [command]
Examples:
arduino <command> [flags...]
Available Commands:
board Arduino board commands.
compile Compiles Arduino sketches.
config Arduino Configuration Commands.
core Arduino Core operations.
help Help about any command
lib Arduino commands about libraries.
login Creates default credentials for an Arduino Create Session.
logout Clears credentials for the Arduino Create Session.
sketch Arduino CLI Sketch Commands.
upload Upload Arduino sketches.
validate Validates Arduino installation.
version Shows version number of arduino CLI.
....
Each command has his own specific help that can be obtained with the help
command, for example:
$ arduino-cli help core
Arduino Core operations.
Usage:
arduino-cli core [command]
Examples:
arduino core update-index # to update the package index file.
Available Commands:
download Downloads one or more cores and corresponding tool dependencies.
install Installs one or more cores and corresponding tool dependencies.
list Shows the list of installed cores.
update-index Updates the index of cores.
Flags:
-h, --help help for core
Global Flags:
--config-file string The custom config file (if not specified ./.cli-config.yml will be used). (default "/home/megabug/Workspace/go/src/github.com/bcmi-labs/arduino-cli/.cli-config.yml")
--debug Enables debug output (super verbose, used to debug the CLI).
--format string The output format, can be [text|json]. (default "text")
Use "arduino-cli core [command] --help" for more information about a command.