Using the Arduino CLI

Enfield Cat's Blog: Arduino and other projects.


Introduction

The Arduino CLI allows you to compile and upload Arduino projects from the command line interface. This allows Arduino projects be:

Install and configure the CLI

Compiling for your board

And finally flash the update to your board...

If you are using over the air (OTA) updates, then this might be as simple as copying the resultant binary to the appropriate location on your web server. If your board is connected via usb, check what port it is connected to, then use the cli update command to flash your code, eg:

arduino-cli board list
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:lolin32 myProject

Maintain your installation

Your installation will need updating from time to time to benefit from fixes applied to the libraries. If a library contains an important security or bug fix, you will need to recompile your projects and reflash your Arduino / esp32 devices.

For both function libraries and cores, use the lib update-index and upgrade sub-commends, eg:

$ arduino-cli lib update-index
Updating index: library_index.json downloaded
$ arduino-cli lib upgrade
Downloading ArduinoOTA@1.0.7...
ArduinoOTA@1.0.7 downloaded
Downloading ArduinoOTA@1.0.7...
ArduinoOTA@1.0.7 already downloaded
Downloading Ticker@4.4.0...
Ticker@4.4.0 downloaded
Downloading Ticker@4.4.0...
Ticker@4.4.0 already downloaded
Downloading Ethernet@2.0.0...
Ethernet@2.0.0 downloaded
$ arduino-cli core update-index
Updating index: package_index.json downloaded
Updating index: package_index.json.sig downloaded
Updating index: package_esp32_index.json downloaded
Updating index: package_esp8266com_index.json downloaded
Updating index: package_damellis_attiny_index.json downloaded
[2021-09-26 13:30:47]
$ arduino-cli core upgrade
Tool esp32:mkspiffs@0.2.3 already installed
Downloading packages...
esp32:xtensa-esp32-elf-gcc@1.22.0-97-gc752ad5-5.2.0 4.96 MiB / 48.31 MiB   10.27
esp32:xtensa-esp32-elf-gcc@1.22.0-97-gc752ad5-5.2.0 11.22 MiB / 48.31 MiB   23.2
esp32:xtensa-esp32-elf-gcc@1.22.0-97-gc752ad5-5.2.0 17.12 MiB / 48.31 MiB   35.4



Thank you for visiting camelthorn.cloudHome