DEV Community

Cover image for Why using arduino-cli is better than building from Arduino IDE
Kate
Kate

Posted on

Why using arduino-cli is better than building from Arduino IDE

Detailed version of this article is published on EmbeddedK8.

Did you know you don’t need the Arduino IDE to build and upload sketches? With the Arduino CLI, you can compile and upload directly from the command line—using the same underlying process as the IDE.

Why use Arduino CLI?

- Configuration flags and custom #define options

Control compiler flags, board settings, and custom #define values per project without touching configuration files. This allows fine-grained control for each board or sketch.

- Automated builds and CI/CD integration

Scripts for building, uploading, and testing can run on headless systems like Docker containers. This enables seamless integration into CI/CD pipelines for fully automated Arduino workflows.

- Reproducible builds across machines

Everyone on your team can build with the same setup and dependencies, eliminating the classic “it works on my machine” problem.

- IDE flexibility

Work in your favorite editor instead of the Arduino IDE.

- Per-project library version control

Specify exact library versions for each project, avoiding conflicts when multiple projects require different versions of the same library.

Example Makefile

# FQBN for your board (change if needed)
FQBN := arduino:renesas_uno:unor4wifi

# Serial port (change if needed)
PORT := /dev/ttyACM0

# Build dirs
BUILD_DEBUG := build/debug
BUILD_RELEASE := build/release

# Arduino CLI executable
ARDUINO_CLI := arduino-cli

# Default build release
all: release

debug:
    $(ARDUINO_CLI) compile \
        --fqbn $(FQBN) \
        --build-path $(BUILD_DEBUG) \
        --optimize-for-debug \
        --verbose

release:
    $(ARDUINO_CLI) compile \
        --fqbn $(FQBN) \
        --build-path $(BUILD_RELEASE) \
        --verbose

upload-debug: debug
    $(ARDUINO_CLI) upload \
        -p $(PORT) \
        --fqbn $(FQBN) \
        --input-dir $(BUILD_DEBUG)

upload-release: release
    $(ARDUINO_CLI) upload \
        -p $(PORT) \
        --fqbn $(FQBN) \
        --input-dir $(BUILD_RELEASE)

monitor:
    $(ARDUINO_CLI) monitor -p $(PORT)

clean:
    rm -rf build


.PHONY: all debug release upload-debug upload-release clean monitor
Enter fullscreen mode Exit fullscreen mode

Using the Arduino CLI together with a simple Makefile makes building, uploading, and managing Arduino projects faster, more reproducible, and easier to automate. Whether you’re working solo or in a team, it gives you full control over compiler options, board settings, and dependencies—all without relying on the Arduino IDE.

Give it a try, and you’ll see how much smoother your Arduino workflow can become!

Top comments (0)