ESP32: Using arduino-cli

3 minute read

This is a raw dump of my exploring using the arduino-cli with the ESP32. I wanted to find something that was better than the Arduino IDE, however, not as complex as VS Code/PlatformIO. Using arduino-cli, allows me to use my programming editor, Sublime Text as my code editor as well as some simple automation (coming later).

Using arduino-cli with ESP32

Install arduino-cli

# install from github
curl -fsSL | sh
# verify installation
arduino-cli version

# if the system is unable to find arduino-cli, see note below.
bash: command not found: arduino-cli

# add an alias to make it easier to use (add to the .bashrc file)
alias ac="arduino-cli"

# setup configuration file
arduino-cli config init
Config file written: /home/username/.arduino15/arduino-cli.yaml
# Documentation for file: 

# if using a 3rd party board, add to yaml file
arduino-cli core update-index
arduino-cli board listall
arduino-cli core install esp32:esp32
Platform esp32:esp32@2.0.2 already installed


Upon installing, arduino-cli, a great way to test it is to verify its version using arduino-cli version. However if the system is unable to find arduino-cli, you will get this:

arduino-cli version
bash: command not found: arduino-cli

This means the path of arduino-cli is in not in the execution PATH. In my install, the arduino-cli path was $home/bin, which is new to my execution path. The easiest (or most simple) method to solve this is by adding to your shell rc file (.bashrc or zshrc):

which arduino-cli
# add to .bashrc file
export PATH=":/home/lkoepsel/bin/:$PATH"

Be sure to use the path found for your installation of arduino-cli.

Ensure ESP32 core is installed

arduino-cli core list
ID          Installed Latest Name 
esp32:esp32 2.0.2     2.0.2  esp32

Confirm release version with, the version numbers need to be the same. In my case 2.0.2.

Edit and Compile/Link/Load

Create and Edit

arduino-cli sketch new blink
Sketch created in: /home/username/blink
cd blink
nano blink.ino
void setup() {

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    digitalWrite(LED_BUILTIN, LOW);
# save and exit nano

Compile/Link/Load (CLL)

arduino-cli compile --fqbn esp32:esp32:nodemcu-32s blink
Sketch uses 206957 bytes (15%) of program storage space. Maximum is 1310720 bytes.
Global variables use 16220 bytes (4%) of dynamic memory, leaving 311460 bytes for local variables. Maximum is 327680 bytes.

# upload to board
arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:nodemcu-32s blink v3.1
Serial port /dev/ttyUSB0
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 24:0a:c4:58:e3:f8
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Configuring flash size...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00010000 to 0x00042fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 682.6 kbit/s)...
Hash of data verified.
Compressed 17104 bytes to 11804...
Wrote 17104 bytes (11804 compressed) at 0x00001000 in 0.4 seconds (effective 383.5 kbit/s)...
Hash of data verified.
Compressed 207344 bytes to 112836...
Wrote 207344 bytes (112836 compressed) at 0x00010000 in 2.1 seconds (effective 804.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 557.6 kbit/s)...
Hash of data verified.

Hard resetting via RTS pin...

And with luck you see a blinking LED!

Comments powered by Talkyard.