Arduino Module¶
This module provides several functions to download the arduino-cli and install firmware on an Arduino board.
- automationshield.arduino.script_dir: Path¶
Path to the directory containing the Arduino script directories.
- automationshield.arduino.download_cli(system: str)[source]¶
Download the
arduino-clifor the appropriate system. The executable is placed incli_dir.- Parameters:
system (str) – Name of operating system. Result of calling
platform.system().
- automationshield.arduino.setup_cli()[source]¶
Run setup for
arduino-cli. This function calls the following methods of thearduino-cli:1arduino-cli core update-index 2arduino-cli core install arduino:avr
These respectively update the index of cores to the latest version and downloads the core for AVR boards, which includes a.o. the Arduino UNO, Mega (2560) and Leonardo.
- automationshield.arduino.compile_script(device: str, script: str)[source]¶
Compile an Arduino script for a specific Arduino board and Automationshield.
1arduino-cli compile 2 --fqbn {device} 3 --clean 4 --libraries {arduino.script_dir}/lib 5 --export-binaries 6 {arduino.script_dir}/{script}
- Parameters:
device (str) – FQBN of Arduino board.
script (str) – Directory name of the Arduino code to be installed. Script directory are provided as a property of the shield classes, e.g.:
automationshield.AeroShield.script.
- automationshield.arduino.upload_script(device: str, script: str, port: str, hex: str | None = None)[source]¶
Upload compiled script onto Arduino board.
1arduino-cli upload 2 --input-file {file} 3 --fqbn {device} 4 --port {port} 5 {arduino.script_dir}/{script}
In the command, the file argument points to the appropriate
.hexfile inarduino.out_dir. This can be overridden by providing thehexargument.- Parameters:
device (str) – FQBN of Arduino board.
script (str) – Directory name of the Arduino code to be installed. Script directory are provided as a property of the shield classes, e.g.:
automationshield.AeroShield.script.port (str) – Port where the Arduino board is connected. Shield classes provide a
portattribute that can be used.hex (str | None) –
.hexfile to upload. Optional, defaults to the appropriate file inout_dir.