golb

Microcontrollers

Raspberry Pico: relp a program with rshell

Raspberry Pico: upload a program with pyboard

ESP32: upload a program with Arduino IDE

Arduino core for the ESP32: https://github.com/espressif/arduino-esp32

Using arduino-cli

# for example with `nix-env`
nix-env -iA nixpkgs.arduino-cli

# we will need access to the `/dev/ttyACM0` as a simple user.
# another unelegant solution is to run all the commands as root.
# add the current user to the group "dialout"
sudo usermod -a -G dialout

# to ensure that your current shell is using the `dialout` group, you can use the command `id`.
# if you don't have the `dialout` group you can force reloading your shell by using `su - $USER`

# list the boards
arduino-cli board list
# this command should shows the correct tty (for example `/dev/ttyACM0`) and the "Fully Qualified Board Name" also known as `fqbn`

# install a library
arduino-cli lib install LIBRARY_NAME

# compile the sketch
arduino-cli compile --fqbn arduino:avr:uno sketch.ino

# upload the sketch
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno sketch.ino

# other useful commands
arduino-cli config init # create a config file

arduino-cli core update-index  # update the index

arduino-cli core install arduino:avr ## install arduino AVR family board

arduino-cli board listall # list supported board

arduino-cli board details -b arduino:avr:nano # show detail on this board (to find the correct option)

# command line completion
arduino-cli completion bash > arduino-cli.sh
mv arduino-cli.sh /etc/bash_completion.d/ # need root

Interact with the serial port

When using the default arduino software, we have an integrated serial monitor. But here, we are using the CLI and de facto there are no GUI so we will use the useful screen command!

To do so, we need:

screen /dev/ttyACM0 115200

To leave the screen session we can use Ctrl+a then k (for kill), the screen should then ask a confirmation with y key