Avatar

ttyrex's blog

Flash Arduino MCU from Raspberry Pi GPIO (No USB)

— By ttyrex

Arduino Cli

Compile and flash a sketch

pi@raspberrypi:~ $ arduino-cli sketch new test
pi@raspberrypi:~ $ arduino-cli core update-index
pi@raspberrypi:~ $ arduino-cli core install arduino:avr

Test the serial console…

pi@raspberrypi:~/test $ vi test.ino 
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.print("foo");
  Serial.println();
}
pi@raspberrypi:~/test $ arduino-cli compile --fqbn arduino:avr:nano .
Sketch uses 1484 bytes (4%) of program storage space. Maximum is 30720 bytes.
Global variables use 198 bytes (9%) of dynamic memory, leaving 1850 bytes for local variables. Maximum is 2048 bytes.

When connected from RX/TX + Serial Level Converter, you need to push the reset btn on the arduino. RPi zero is slow, push several times 😄

How to connect 5V RPI to 3.3 Arduino using Serial Level Converter ?

$ arduino-cli upload -p /dev/ttyS0 --fqbn arduino:avr:nano . -v

Use minicom to check output.

Arduino Nano pinout reminder

^EOF

/arduino/ /raspberrypi/