Arduino: Difference between revisions

From NixOS Wiki
Artturin (talk | contribs)
tweak shell.nix
Klinger (talk | contribs)
m Category:IDE added
 
(One intermediate revision by the same user not shown)
Line 116: Line 116:
* [https://gist.github.com/CMCDragonkai/d00201ec143c9f749fc49533034e5009 Arduino Connection on NixOS]
* [https://gist.github.com/CMCDragonkai/d00201ec143c9f749fc49533034e5009 Arduino Connection on NixOS]
* https://rzetterberg.github.io/teensy-development-on-nixos.html
* https://rzetterberg.github.io/teensy-development-on-nixos.html
[[Category:Development]]
[[Category:Applications]]
[[Category:IDE]]

Latest revision as of 20:02, 28 December 2024

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

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.

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

See also