0

FYI (AKA before people start down voting)

enter image description here

I have a simple sketch called test.ino. I can run it from my macbook without issue. However, when I try to hook the Arduino Uno directly up to the raspberry pi (2) I see the port that is being used is ttyACM0 but when I run sudo arduino --upload test.ino --port /dev/ttyACM0, I get...

Caused by: java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it.

How do I avoid this?

Update

***@robotbrain:~/Code/rpi/green$ lsusb
Bus 001 Device 005: ID 2341:0001 Arduino SA Uno (CDC ACM)
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

You can confirm no x11 by...

...@robotbrain:~$ xdpyinfo | grep version
xdpyinfo:  unable to open display "".
11
  • 1
    You will have to run the command line Arduino utility. Ask on the Arduino site
    – Milliways
    Apr 11, 2020 at 2:54
  • @Milliways I did they transferred it here problems with SO :-(
    – Jackie
    Apr 11, 2020 at 3:03
  • 1
    you do not upload ino files ... you upload compiled hex files ... use avrdude for that
    – jsotola
    Apr 11, 2020 at 3:06
  • Awesome @jsotola give me the way to compile an ino file to hex so I can use avrdude and you get the nod ;-)
    – Jackie
    Apr 11, 2020 at 3:07
  • Rt but per the post the arduino cli still requires X11
    – Jackie
    Apr 11, 2020 at 3:15

2 Answers 2

1

For compiling Arduino code on the command line, I usually use Sudar Muthu's Makefile. It is available on Raspbian as the arduino-mk package:

sudo apt install arduino-mk
mkdir arduino-test
cd arduino-test
cat > arduino-test.ino <<EOF
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    delay(200);
}
EOF
cat > Makefile <<EOF
BOARD_TAG = uno
include /usr/share/arduino/Arduino.mk
EOF
make
make upload

The only problem is that you end up using the Arduino core version 1.0.5, which is quite ancient. You can set up the per-project Makefile for using a more recent core, but this requires some configuration. Here is a Makefile I use on Ubuntu with a 1.8.10 core unpacked in /opt:

ARDMK_DIR     = /usr/share/arduino
ARDUINO_DIR   = /opt/arduino-1.8.10
AVRDUDE_CONF  = /etc/avrdude.conf
USER_LIB_PATH = $(realpath ../..)
ARDUINO_LIBS  = Wire RTClib
ARDUINO_QUIET = 1
BOARD_TAG     = uno

include $(ARDMK_DIR)/Arduino.mk

I didn't check it works on Raspbian though.

0

Raspberry Pi 2 and Arduino Uno

I am not going to accept this as the answer because I want to compile the ino on the pi!

I could do this...

  1. Compile the ino file to a hex file on an os with an IDE (my case my macbook pro)
  2. SCP the .hex file up to the raspberry pi (assuming test.hex)
  3. SSH into the raspberry pi
  4. Run the following... sudo avrdude -p m328p -carduino -e -U flash:w:test.hex -P/dev/ttyACM0
2
  • Why would you want to go through this complex process when you could just run Arduino on the Mac (or indeed any other computer) or even use the on-line version.
    – Milliways
    Apr 11, 2020 at 4:02
  • Because I want to automate it and not have to control the flow of my artifact. Why would we ask why and not figure that things can be contained without outside influence?
    – Jackie
    Apr 11, 2020 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.