Day 192 – Using the UDOO x86’s Arduino with Arduino-CLI

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.

Day 158 – Arduino and UDOO Communication

Since then however, an official Arduino command line tool has been released! Which means it’s time for another tutorial!

If you’re doing this over SSH, you very likely might want to allow access to hardware (like serial ports) over SSH. Otherwise, you’ll need to run arduino-cli as root to upload.

First we must download arduino-cli. You used to have to download the arduino-cli binary itself, but as of 18/09/2019, the Arduino team now provide an installer script, so we can use that instead:

This will install the binary in /home/sart/Arduino/bin

Then we want to add it to our PATH so we can run it anywhere:

I also had to make sure the ~/.arduino15  directory was owned by my user, or running arduino-cli would give a Permission Denied error.

The first thing we must do it update the index:

Then we want to install support for the Intel Curie / 101 board. We can do this with the board manager:

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:

This installs the Adafruit libraries for most of the sensors we use. You can also use arduino-cli lib search to search for libraries.

In case you’ve never used the Arduino before. You’ll likely need to do the following to fix an issue where uploads won’t work. See here for more details.

To compile a sketch, move to the sketch directory and use:

Finally to upload a sketch, you should be able to run:

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.

This post was updated on 18/09/2019 since the Arduino team changed the way you install the program. Plus I added a bit more useful stuff.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.