In a previous blog post, I wrote about using the official Arduino IDE with the on-board Arduino 101 on the UDOO x86 Ultra. Since our robot is headless, i.e. doesn’t run a display server, we wanted the IDE to run from the command line. While the IDE had support for using its functionality from the command line, it still, for some reason, required a display server to run. I solved this by creating a virtual X11 wrapper and running it inside that. Which was fine, but slow and pretty dodgy.
Since then however, an official Arduino command line tool has been released! Which means it’s time for another tutorial!
Download the arduino-cli binary. I’m using the Linux 64 binary, since the UDOO uses a 64 bit x86 CPU, but binaries are available for ARM and a few other platforms as well, just replace the last bit of the URL.
Extract it with:
tar jxf arduino-cli-latest-linux64.tar.bz2
Rename the file with:
mv arduino-cli-0.3.6-alpha.preview-linux64 arduino-cli
You’ll likely want to move it somewhere in your $PATH, such as /usr/local/bin
The first thing we want to do is install support for the Intel Curie / 101 board. We can do this with the board manager:
arduino-cli core install Intel:arc32
The arduino-cli program is easy to use. To install libraries, which we need to do for any sensor we use, we can just do this:
arduino-cli lib install "Adafruit_VL53L0X"
arduino-cli lib install "Adafruit AMG88xx Library"
arduino-cli lib install "Adafruit MLX90614 Library"
arduino-cli lib install "Adafruit SGP30 Sensor"
This installs the Adafruit libraries for most of the sensors we use. You can also use arduino-cli lib search to search for libraries.
To compile a sketch, move to the sketch directory and use:
arduino-cli compile -b Intel:arc32:arduino_101
Finally to upload a sketch, you should be able to run:
sudo arduino-cli upload -b Intel:arc32:arduino_101 -p /dev/ttyACM0
That’s all there is to it. This is naturally much quicker than the old method and should be easier to debug, not to mention much easier to set up.