Arduino: Difference between revisions
m add titles to links |
m style improvements |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
The Arduino ecosystem offers two Versions of the Arduino IDE and an Arduino CLI that both base on. | The Arduino ecosystem offers two Versions of the Arduino IDE and an Arduino CLI that both base on. | ||
The latter can be used for building Arduino projects with nix. | The latter can be used for building Arduino projects with nix. | ||
| Line 5: | Line 4: | ||
== Arduino IDE 2.x == | == Arduino IDE 2.x == | ||
The Arduino IDE 2.x is available in nixpkgs as <code> | The Arduino IDE 2.x is available in nixpkgs as {{nixos:package|arduino-ide}} | ||
When trying to upload to your board, you may get the following error: | |||
<code> | |||
Cannot perform port reset: 1200-bps touch: opening port at 1200bps: Permission denied | |||
No device found on ttyACM0 | |||
</code> | |||
This is a serial port permissions issue. Add your user to the <code>dialout</code> group, rebuild your system, then log out and back in or reboot to apply: | |||
<syntaxhighlight lang="nix"> | |||
{ | |||
users.users.<myuser>.extraGroups = [ "dialout" ]; | |||
} | |||
</syntaxhighlight> | |||
== Arduino IDE 1.x == | == Arduino IDE 1.x == | ||
This is the old Arduino IDE and it is available as | This is the old Arduino IDE and it is available as {{nixos:package|arduino}} in nixpkgs. | ||
It is still used for many projects. | It is still used for many projects. | ||
| Line 36: | Line 50: | ||
Upload to an <code>Arduino Nano</code> board | Upload to an <code>Arduino Nano</code> board | ||
< | <syntaxhighlight lang=console> | ||
time \ | $ time \ | ||
arduino --board arduino:avr:nano --port /dev/ttyUSB0 --upload Blink.cpp | arduino --board arduino:avr:nano --port /dev/ttyUSB0 --upload Blink.cpp | ||
| Line 47: | Line 61: | ||
real 0m28.913s | real 0m28.913s | ||
</ | </syntaxhighlight> | ||
<!-- | <!-- | ||
| Line 81: | Line 95: | ||
== Arduino CLI == | == Arduino CLI == | ||
The Arduino CLI is available as | The Arduino CLI is available as {{nixos:package|arduino-cli}} in nixpkgs. | ||
=== Build Arduino project with Nix === | === Build Arduino project with Nix === | ||
| Line 95: | Line 109: | ||
See: [[Serial Console]] | See: [[Serial Console]] | ||
< | <syntaxhighlight lang=console> | ||
screen /dev/ttyUSB0 | $ screen /dev/ttyUSB0 | ||
# set baud rate. default is 9600 | $ # set baud rate. default is 9600 | ||
screen /dev/ttyUSB0 9600 | $ screen /dev/ttyUSB0 9600 | ||
</ | </syntaxhighlight> | ||
see also: https://wiki.archlinux.org/title/GNU_Screen | see also: https://wiki.archlinux.org/title/GNU_Screen | ||
Latest revision as of 18:16, 19 July 2026
The Arduino ecosystem offers two Versions of the Arduino IDE and an Arduino CLI that both base on. The latter can be used for building Arduino projects with nix.
Arduino IDE 2.x
The Arduino IDE 2.x is available in nixpkgs as arduino-ide
When trying to upload to your board, you may get the following error:
Cannot perform port reset: 1200-bps touch: opening port at 1200bps: Permission denied
No device found on ttyACM0
This is a serial port permissions issue. Add your user to the dialout group, rebuild your system, then log out and back in or reboot to apply:
{
users.users.<myuser>.extraGroups = [ "dialout" ];
}
Arduino IDE 1.x
This is the old Arduino IDE and it is available as arduino in nixpkgs.
It is still used for many projects.
shell.nix
{
pkgs ? import <nixpkgs> { },
}:
pkgs.callPackage (
{
mkShell,
arduino,
}:
mkShell {
strictDeps = true;
nativeBuildInputs = [
arduino
];
}
) { }
Upload program
Upload to an Arduino Nano board
$ time \
arduino --board arduino:avr:nano --port /dev/ttyUSB0 --upload Blink.cpp
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
Uploading...
real 0m28.913s
Arduino CLI
The Arduino CLI is available as arduino-cli in nixpkgs.
Build Arduino project with Nix
Ardunio-Nix allows generating all dependencies from an Arduino project as Nix dependencies. The Arduino-Env patch makes it possible to build these Arduino project within Nix.
- Arduino-Nix: https://github.com/bouk/arduino-nix
- Ardunio-Env patch: https://github.com/clerie/arduino-nix/tree/clerie/arduino-env
Serial console
See: Serial Console
$ screen /dev/ttyUSB0
$ # set baud rate. default is 9600
$ screen /dev/ttyUSB0 9600
see also: https://wiki.archlinux.org/title/GNU_Screen
see also: https://wiki.archlinux.org/title/Working_with_the_serial_console