Top Related Projects
Arduino core for the ESP32
Your Gateway to Embedded Software Development Excellence :alien:
STM32 core support for Arduino
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
Quick Overview
Arduino CLI is a command-line tool for Arduino that provides a versatile interface for compiling, uploading, and managing Arduino sketches and libraries. It's designed to be used in various scenarios, from simple command-line interactions to integration with IDEs and CI/CD pipelines.
Pros
- Cross-platform compatibility (Windows, macOS, Linux)
- Supports automation and integration with other tools
- Provides a powerful API for developers
- Enables headless operations for Arduino development
Cons
- Steeper learning curve compared to the Arduino IDE
- Limited GUI, which may be challenging for visual learners
- Requires command-line knowledge
- Some features may not be as intuitive as in the Arduino IDE
Code Examples
- Compile a sketch:
arduino-cli compile --fqbn arduino:avr:uno MySketch
This command compiles the "MySketch" for an Arduino Uno board.
- Upload a sketch:
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno MySketch
This uploads the compiled "MySketch" to an Arduino Uno connected to the specified port.
- Install a library:
arduino-cli lib install "Servo"
This command installs the Servo library from the Arduino Library Manager.
Getting Started
-
Install Arduino CLI:
- Download the latest release from the GitHub repository
- Extract the archive and add the binary to your system PATH
-
Initialize the configuration:
arduino-cli config init
- Update the index of available platforms:
arduino-cli core update-index
- Install the core for your board (e.g., Arduino Uno):
arduino-cli core install arduino:avr
- Create a new sketch:
arduino-cli sketch new MyFirstSketch
- Compile and upload your sketch:
arduino-cli compile --fqbn arduino:avr:uno MyFirstSketch
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno MyFirstSketch
Replace /dev/ttyACM0
with the appropriate port for your system.
Competitor Comparisons
Arduino core for the ESP32
Pros of arduino-esp32
- Specifically designed for ESP32 microcontrollers, offering optimized performance and features
- Includes built-in Wi-Fi and Bluetooth functionality, enabling IoT applications
- Provides access to ESP32-specific hardware features and peripherals
Cons of arduino-esp32
- Limited to ESP32 boards, lacking support for other Arduino-compatible hardware
- May have a steeper learning curve for users unfamiliar with ESP32 architecture
- Potentially less stable or mature compared to the official Arduino CLI
Code Comparison
arduino-cli:
#include <Arduino.h>
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello from Arduino!");
delay(1000);
}
arduino-esp32:
#include <Arduino.h>
#include <WiFi.h>
void setup() {
Serial.begin(115200);
WiFi.begin("SSID", "PASSWORD");
}
void loop() {
Serial.println("Hello from ESP32!");
delay(1000);
}
The arduino-esp32 example demonstrates built-in Wi-Fi functionality, while the arduino-cli example shows a more generic Arduino sketch. The ESP32 code uses a higher baud rate (115200) for serial communication, which is common for ESP32 boards.
Your Gateway to Embedded Software Development Excellence :alien:
Pros of PlatformIO Core
- Supports a wider range of boards and platforms beyond Arduino
- Offers a more flexible and powerful build system
- Integrates well with various IDEs and text editors
Cons of PlatformIO Core
- Steeper learning curve for beginners
- May require more setup and configuration
- Larger installation size and resource usage
Code Comparison
Arduino CLI:
#include <Arduino.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
PlatformIO Core:
#include <Arduino.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
The code for both platforms is identical in this basic example. However, PlatformIO Core allows for more advanced project structures and build configurations, which can be specified in a platformio.ini
file:
[env:uno]
platform = atmelavr
board = uno
framework = arduino
This configuration file demonstrates PlatformIO's flexibility in specifying project settings, which is not directly available in Arduino CLI.
STM32 core support for Arduino
Pros of Arduino_Core_STM32
- Specialized support for STM32 microcontrollers, offering optimized performance
- Extensive library of STM32-specific functions and features
- Seamless integration with STM32CubeMX for easy pin configuration
Cons of Arduino_Core_STM32
- Limited to STM32 boards, lacking support for other Arduino-compatible platforms
- May require additional setup and configuration compared to the more universal arduino-cli
- Smaller community and fewer resources compared to the main Arduino ecosystem
Code Comparison
Arduino_Core_STM32:
#include <STM32duino.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
arduino-cli:
#include <Arduino.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
The code structure is similar, but Arduino_Core_STM32 uses STM32-specific headers and may offer additional functions tailored for STM32 boards. arduino-cli provides a more generic approach, suitable for various Arduino-compatible platforms.
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
Pros of MicroPython
- Supports a wider range of microcontrollers and boards
- Offers a more Python-like programming experience
- Includes an interactive REPL for quick testing and development
Cons of MicroPython
- Generally requires more memory and processing power
- May have slower execution speed for certain operations
- Less extensive library ecosystem compared to Arduino
Code Comparison
MicroPython:
from machine import Pin
import time
led = Pin(2, Pin.OUT)
while True:
led.toggle()
time.sleep(1)
Arduino CLI:
int ledPin = 2;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, !digitalRead(ledPin));
delay(1000);
}
Summary
MicroPython offers a more Python-like experience and supports a wider range of boards, but may require more resources and have slower execution in some cases. Arduino CLI provides a more traditional C++ approach with a larger ecosystem of libraries and potentially faster execution, but with a steeper learning curve for beginners. The choice between the two depends on the specific project requirements, hardware constraints, and developer preferences.
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
Pros of nodemcu-firmware
- Built-in Wi-Fi capabilities, making it easier to create IoT projects
- Lua scripting support, offering a more accessible programming environment
- Extensive built-in libraries for common IoT tasks
Cons of nodemcu-firmware
- Limited hardware compatibility compared to Arduino's wide range of boards
- Smaller community and fewer resources compared to Arduino's ecosystem
- Less suitable for low-level hardware control and timing-critical applications
Code Comparison
NodeMCU (Lua):
wifi.setmode(wifi.STATION)
wifi.sta.config({ssid="MyNetwork", pwd="password"})
mqtt = require("mqtt")
m = mqtt.Client("clientid", 120)
m:connect("broker.example.com", 1883)
Arduino (C++):
#include <WiFi.h>
#include <PubSubClient.h>
WiFiClient wifiClient;
PubSubClient client(wifiClient);
void setup() {
WiFi.begin("MyNetwork", "password");
client.setServer("broker.example.com", 1883);
}
The code comparison shows that NodeMCU's Lua scripting offers a more concise syntax for common IoT tasks like Wi-Fi and MQTT setup, while Arduino provides a more familiar C++ environment with greater flexibility for advanced users.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
arduino-cli
Arduino CLI is an all-in-one solution that provides Boards/Library Managers, sketch builder, board detection, uploader, and many other tools needed to use any Arduino compatible board and platform from command line or machine interfaces.
Docs
For guidance on installation and development, see the User documentation.
Quickstart
- Install the Arduino CLI
- Follow the Getting Started guide to check out what the CLI can do
- Browse the Commands reference to see all the available commands
- Should you have an issue, read the FAQ page
How to contribute
Contributions are welcome!
Please read the document How to contribute which will show you how to build the source code, run the tests, and contribute your changes to the project.
:sparkles: Thanks to all our contributors! :sparkles:
Testing builds
Nightly builds are available for testing.
Security
If you think you found a vulnerability or other security-related bug in the Arduino CLI, please read our security policy and report the bug to our Security Team ð¡ï¸ Thank you!
e-mail contact: security@arduino.cc
License
Arduino CLI is licensed under the GPL 3.0 license.
You can be released from the requirements of the above license by purchasing a commercial license. Buying such a license is mandatory if you want to modify or otherwise use the software for commercial activities involving the Arduino software without disclosing the source code of your own applications. To purchase a commercial license, send an email to license@arduino.cc
Top Related Projects
Arduino core for the ESP32
Your Gateway to Embedded Software Development Excellence :alien:
STM32 core support for Arduino
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems
Lua based interactive firmware for ESP8266, ESP8285 and ESP32
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot