LinuxCommandLibrary

arduino

Upload code to Arduino boards

TLDR

Build a sketch

$ arduino --verify [path/to/file.ino]
copy

Build and upload a sketch
$ arduino --upload [path/to/file.ino]
copy

Build and upload a sketch to an Arduino Nano with an Atmega328p CPU, connected on port /dev/ttyACM0
$ arduino --board [arduino:avr:nano:cpu=atmega328p] --port [/dev/ttyACM0] --upload [path/to/file.ino]
copy

Set the preference name to a given value
$ arduino --pref [name]=[value]
copy

Build a sketch, put the build results in the build directory, and reuse any previous build results in that directory
$ arduino --pref build.path=[path/to/build_directory] --verify [path/to/file.ino]
copy

Save any (changed) preferences to preferences.txt
$ arduino --save-prefs
copy

Install the latest SAM board
$ arduino --install-boards "[arduino:sam]"
copy

Install Bridge and Servo libraries
$ arduino --install-library "[Bridge:1.0.0,Servo:1.2.0]"
copy

SYNOPSIS

arduino [options] [sketch.ino]

PARAMETERS

--board
    Target board FQBN (e.g., arduino:avr:uno)

--port
    Serial port (e.g., /dev/ttyUSB0 or COM3)

--verify
    Compile and verify sketch

--upload
    Compile and upload to board

--monitor
    Open serial monitor post-upload

--pref =
    Set IDE preference (e.g., boardmanager.additional_urls=https://...)

--save-prefs
    Save current preferences to file

--get-pref
    Retrieve preference value

--install-boards
    Add boards manager URL

--config-file
    Use alternate preferences file

--help
    Display usage help

--version
    Print Arduino IDE version

DESCRIPTION

The arduino command launches the Arduino Integrated Development Environment (IDE) or performs command-line tasks like compiling (verify) and uploading sketches to boards. Installed via packages like arduino in Debian/Ubuntu or AUR in Arch, it supports headless operation for automation.

Specify target hardware with --board (e.g., arduino:avr:uno) and serial port with --port. Combine flags like --verify to check code without GUI, or --upload to program the device. Manage settings via --pref for keys like boardmanager.additional_urls, and persist with --save-prefs. Also supports board installation from URLs and serial monitoring.

Ideal for scripts, CI/CD, or embedded systems without display. Note: Arduino IDE 2.x may use arduino-ide; check your distro. Full CLI alternative is arduino-cli. Requires USB rules for board access.

CAVEATS

May depend on GUI libs (e.g., Qt) even in CLI mode; run sudo usermod -a -G dialout $USER for port access. IDE 2.x often named arduino-ide.

EXAMPLES

arduino --verify --board arduino:avr:uno Blink.ino
arduino --upload --board esp32:esp32:node32s --port /dev/ttyUSB0 sketch.ino --monitor

BOARD FQBN

Find via Boards Manager in IDE or arduino-cli board list. Format: <package>:<arch>:<id>[:key=value].

HISTORY

CLI options added in Arduino IDE 1.0 (2011); evolved for better automation in 1.6+ (2015). IDE 2.0 (2022) shifts to arduino-ide with similar flags.

SEE ALSO

arduino-cli(1), avrdude(1), stty(1)

Copied to clipboard