Skip to main content

Arduino CLI

Arduino CLI is a command line tool for compiling and uploading Arduino sketches. It is a wrapper around the Arduino IDE and provides a faster and more flexible alternative to the Arduino IDE.

Usage

Check board list:

arduino-cli core update-index
arduino-cli board list

Install core:

arduino-cli core install arduino:avr

Compile sketch:

arduino-cli compile --fqbn arduino:avr:uno /path/to/sketch

Upload sketch:

arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno /path/to/sketch

Note: Ensure your user has access to /dev/ttyACM0 or whichever port your Arduino is connected to.

If not, you can do the following:

sudo chmod a+rw /dev/ttyACM0

Add libraries:

arduino-cli lib search Servo
# Pick the right name from the list
arduino-cli lib install "Servo"