Arduino: Difference between revisions

From NixOS Wiki
imported>Milahu
Created page with "== shell.nix == <syntaxHighlight lang=nix> { pkgs ? import <nixpkgs> {} }: with pkgs; mkShell { buildInputs = [ arduino #gnumake # upload with Makefile #scree..."
 
imported>Clerie
No edit summary
Line 1: Line 1:
== shell.nix ==
 
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 <code>arduino-ide</code>
 
== Arduino IDE 1.x ==
 
This is the old Arduino IDE and it is available as <code>arduino</code> in nixpkgs.
It is still used for many projects.
 
=== shell.nix ===


<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
Line 15: Line 28:
</syntaxHighlight>
</syntaxHighlight>


== Upload program ==
=== Upload program ===


Upload to an <code>Arduino Nano</code> board
Upload to an <code>Arduino Nano</code> board
Line 35: Line 48:
todo: make this faster
todo: make this faster


=== Upload with Makefile ===
==== Upload with Makefile ====


https://github.com/sudar/Arduino-Makefile
https://github.com/sudar/Arduino-Makefile
Line 61: Line 74:


-->
-->
== Arduino CLI ==
The Arduino CLI is available as <code>arduino-cli</code> 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 ==
== Serial console ==



Revision as of 18:16, 17 December 2023

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> {} }:

with pkgs;

mkShell {
  buildInputs = [
    arduino
    #gnumake # upload with Makefile
    #screen # serial console
  ];
}

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

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