Jump to content
Search

The new Ubuntu Wiki is live. Legacy content may be unavailable and page links may have changed. Read the announcement on Discourse.

Install the Arduino IDE

From Ubuntu Wiki

To get us up and running with Arduino microcontrollers, we are going to install the Arduino IDE, a program that will help us write code for the Arduino, and run our code on the board.[1]

Before you start

Goals

  • How to install the Arduino IDE
  • How to add a user to a group (here, the dialout group)

Prerequisites

  • Ubuntu Desktop 20.04 or later
  • An Arduino board, and included mini-USB cable
  • Some basic command-line knowledge (including how to use cd to change directories)

Install dependencies

Currently, the Arduino IDE requires the FUSE 2 library to run. Install it in a terminal:

sudo apt install libfuse2

Install the IDE

We can download the latest version of the Arduino IDE as an AppImage. An AppImage is a self-contained application package that can be launched on any Linux distribution, including Ubuntu. In some ways, it's similar to a snap.

Warning
Although there are deb and snap packages for the Arduino IDE in the Ubuntu repositories, these have not been updated for a while. They still contain the Arduino IDE version 1 while the current version is 2. As such, we do not recommend installing these deb and snap packages, as asking for support when using outdated software is more difficult.

Download the package

Go to the Arduino website. In the menu, select Linux AppImage (64-bit X86-64).

Make the package executable

In the Files app, right-click the recently downloaded AppImage file.

Go to Properties.

Enable the Executable as Program switch.

In a terminal, go to the folder where the AppImage file is located, such as your Downloads folder:

cd Downloads

Add the permission to execute (x):

chmod +x arduino-ide_2.3.10_Linux_64bit.AppImage

Replace the file name with the exact version that you have.

First launch

Before launching the IDE, connect your Arduino board to your computer with a USB cable.

Launch the IDE:

Double-click the AppImage file in the Files app.

While being in the same folder as the AppImage file, execute it:

<
./arduino-ide_2.3.10_Linux_64bit.AppImage

Accept the Terms of Service

The IDE starts by displaying its Terms of Service in a new window. Click Agree.

Application crash?

If the IDE crashes immediately, or appears not to start at all, try running it with the legacy X11 graphical back end:

./arduino-ide_2.3.10_Linux_64bit.AppImage --ozone-platform=x11

The editor

After that, we should see the IDE’s main editor window.

The IDE comes with example files that we can use to test if everything works. Let’s try open one such file:

Under FileExamples01.Basics, choose Blink.

Try running the code on your Arduino board by clicking the Upload button (the right arrow in the tool bar at the top).

We should get an error:

Binary sketch size: 1,054 bytes (of a 32,256 byte maximum) processing.app.SerialNotFoundException: Serial port 'COM1' not found. Did you select the right one from the Tools > Serial Port menu? (...)

But if we try following the suggestion in the error above, the Serial Port menu is greyed out and can’t be entered.

What’s going on?

The dialout group and udev

This is happening because the IDE doesn’t have sufficient permissions to access the Arduino device.

File permissions

We can look at the connected Arduino device using the following command:

ls -l /dev/ttyACM*

The output looks mostly like this:

crw-rw---- 1 root dialout 166, 0 Des 14 09:47 /dev/ttyACM0

The 0 at the end of ACM might be different, and multiple entries might be listed, but the parts we need to focus on are the string of letters and dashes in front, and the two names root and dialout.

The first name root is the owner of the device, and dialout is the owner group of the device.

The letters and dashes in front, starting after c, represent the permissions for the device by user:

  • The first triplet rw- mean that the owner (root) can read and write to this device.
  • The second triplet rw- mean that members of the owner group (dialout) can read and write to this device.
  • The third triplet --- means that other users have no permissions at all (meaning that nobody else can read and write to the device).

In short, nobody except root and members of the dialout group can do anything with the Arduino board; since we aren’t running the IDE as root or as a member of dialout, the IDE can’t access the Arduino board due to insufficient permissions.

Add yourself to the dialout group

Join the dialout group using the following command:

sudo usermod -a -G dialout $USER

Add necessary udev rules

Recent Arduino boards also require adding certain system rules for handling devices. These enable you to upload code or flash new firmware into the board.

Download the Arduino script to add udev rules:

wget https://content.arduino.cc/assets/arduino-udev-setup.sh
Warning
By running this script, you trust the makers of Arduino to make any changes to your system. If you can read shell scripts, we recommend that you review the content of the file first.

Run the script as root:

sudo bash arduino-udev-setup.sh

Reload the settings

Save your work, log out, and log back in again for the changes to take effect. Reconnect your Arduino board and restart the IDE.

After you log back in and launch the Arduino IDE, the Serial Port option should be available.

Change the Serial Port, and we should be able to upload the Blink code to your Arduino board.

That’s all folks!

Congratulations, you made it!

You’ve just installed the Arduino IDE on your computer; you’ve also learned how permissions and groups work in Linux!

Next Steps

Further readings

Notes

  1. Originally authored by the Canonical Web Team on the Ubuntu Discourse: https://discourse.ubuntu.com/t/install-the-arduino-ide/13990