November 22, 2024

Install Arduino in Linux (Ubuntu)

In this tutorial, we will learn how to properly install Arduino in Ubuntu. This might be a far from trivial task for people who are not familiar with the Linux command line and with the Linux operating system. The YouTube tutorial accompanying this post is given below.

We explain how to download and install Arduino IDE 2.X.X, where X.X. is the current version.
Our first step is to download the installation file. For that purpose, go to https://www.arduino.cc/en/software and click on on the link “AppImage 64 bits (X86-64)”. After clicking on this link, the download process should start. After downloading the file, the file name should be “arduino-ide_nightly-20230823_Linux_64bit.AppImage” or a similar name depending on the current version being downloaded. The file should be stored in the download folder. You also have an option for downloading the zip file and this is explained in the second tutorial.

The next step is to change the name of the file in order to make our typing easier. I will change the name of the downloaded file to  “arduino-ide20.AppImage”. You can also select another name if you want.

Then, we need to create a new folder where we will copy the file. I will create a folder called “Arduino” in the home folder and I will copy the file over there. Let us do that in the command line. Open a terminal, and type

cd ~  

mkdir Arduino

cp ~/Downloads/arduino-ide20.AppImage ~/Arduino

sudo apt update

The first command will go to the home folder. The second command will create the folder called Arduino. The third command will copy the file to the new folder, and the fourth command will update the Linux environment.

Next, let us change the folder. Let us go to our Arduino folder

cd ~/Arduino

Next, we need to add the execution permission to our downloaded file:

chmod +x arduino-ide20.AppImage

We can launch the Arduino program by typing from the Arduino folder

./arduino-ide20.AppImage

Next, connect your Arduino and try to upload an empty sketch. You will get the following error:

avrdude: ser_open(): can’t open device “/dev/ttyACM0”: Permission denied

To solve this problem, we do the following. Close the Arduino environment. Open a new terminal and type:

sudo usermod -a -G dialout aleksandar

sudo chmod a+rw /dev/ttyACM0

The general form of the first command should be

sudo usermod -a -G dialout  <username>

The <username> is your current Linux username.

Then, close the terminal and restart the computer or log-out and log in again. After doing this, start again Arduino, by opening the terminal window, and typing

cd ~/Arduino
./arduino-ide20.AppImage

and try to upload an empty sketch. You will be able to upload it without problems. Also, test the installation by loading this sketch

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Hello World!");
}

Open Serial Plotter. This sketch should print “Hello World” on our screen.

Next, let us add a shortcut to our start menu and search window. To do that, open the terminal and type

gedit

This will start the Geditor. Then, in the opened file, type the following script:

[Desktop Entry]
Type=Application
Name=Arduino IDE 2.0.0
Exec=/home/aleksandar/Arduino/arduino-ide20.AppImage

This will create the script that will add the Arduino shortcut. The “Exec” parameter should be the path to our Arduino source file. In my case “aleksandar” is my username. In your case, the username should be different and adjusted. Next, we need to save this file in the appropriate folder. We need to save this file in the following folder

/home/aleksandar/.local/share/applications

The name of the file should be

“arduino.desktop”