November 21, 2024

How to Install Arduino IDE in Linux (Ubuntu)

In this tutorial, we explain how to install Arduino IDE in Linux (Ubuntu). We are using Ubuntu 22.04. However, everything explained in this tutorial can be used for other versions of Ubuntu. The YouTube video accompanying this tutorial is given below.

STEP 1- Download

Go to the Arduino IDE Download page and download the Arduino file. You can do that by either “googling” Arduino download or directly go the official download page

https://www.arduino.cc/en/software

Search for a Linux download option, the downloaded file should look like this

arduino-ide_2.3.2_Linux_64bit.AppImage

Where the number “2.3.2” is the current number. In your case, this number might be different.

STEP 2- Create an Installation Directory, Copy File, and Configure

Create an Arduino directory in the home folder (you can also install it somewhere else if you wish). Open a terminal and type

mkdir Arduino

Then we need to copy the downloaded file from the download directory to the newly created directory.

cp ~/Downloads/arduino-ide_2.3.2_Linux_64bit.AppImage ~/Arduino

Make sure that the file is copied to the correct location

cd Arduino
ls -l

You should see the copied file in the folder.

Where the bold highlighted numbers represent the current Linux version. Open a command prompt and type

sudo add-apt-repository universe
sudo apt install libfuse2

to install FUSE such that you can run the file without any problems. To be able to execute the file, we need to add the executable permissions to the file. To do that, we type

chmod +x arduino-ide_2.3.2_Linux_64bit.AppImage

To execute the file, we type

./arduino-ide_2.3.2_Linux_64bit.AppImage

This will start the Arduino IDE.  Write the following code

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!");
}

Connect the Arduino by using the USB port. Click on Tools/Port and select the port. Then, select Tools/Board and select your board. Try to upload the code. You will see the following error

avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
Failed uploading: uploading error: exit status 1

To fix this error, you need to set the read/write permissions to the corresponding port. Close Arduino. First, open a terminal and type

ls -la /dev | grep ttyACM0

To confirm that the port exist. To set the read/write permissions, set the following

sudo usermod -a -G dialout <your username>

In my case, I type

sudo usermod -a -G dialout aleksandar

Then type:

sudo chmod a+rw /dev/ttyACM0

Finally, confirm the permissions:

ls -la /dev | grep ttyACM0

Next, let us start Arduino again. Type:

./arduino-ide_2.3.2_Linux_64bit.AppImage

Set the port and board number. Type the code, and upload the code. Open a Serial Monitor and “Hello World” will be displayed.

Next, we need to create a shortcut such that we do not need to start Arduino every time from a terminal window. Type

sudo apt install gedit
cd ~/.local/share/applications
gedit arduino.desktop

Type the following in the file

[Desktop Entry]
Type=Application
Name=Arduino IDE  2.3.2
Exec=/home/aleksandar/Arduino/arduino-ide_2.3.2_Linux_64bit.AppImage

This will create a shortcut. Click on “Show Applications” and search for Arduino. You will be able to start Arduino.