33

My OS is Ubuntu 18.04 and arduino was working until now.

Although there are a few solutions, none of them seems to work for me.

I followed these instructions on the arduino website.

Then I tried this on arduino Stack Exchange, which should work in cases where the first solution didn't. The answer says we should create a few rules on /etc/udev/ruled.d/ path.

But none of them worked for me.

I also tested arduino in Windows 10 to see if it was a hardware problem, but it worked fine.

Does anyone have any other ideas on how to solve this issue?

UPDATE:

  • My username, sergio, is part of both groups (tty and dialout);
  • I logged out and back in as arduino official tutorial explains;
  • In Arduino IDE, the configurations are correct: Arduino UNO and ttyACM0
  • This is the output of ll /dev/ttyACM0 after running the tutorial commands:

    crw-rw-rw- 1 root dialout 166, 0 Jul 15 05:41 /dev/ttyACM0
    

UPDATE 2:

I've created a script to solve this: https://github.com/sergiomafra/iniarduino

7
  • 5
    Possible duplicate of How to install latest Arduino IDE? Did you forgot to logout and login again after running usermod? – N0rbert Jul 15 '18 at 12:51
  • Nope. First I tried to log out and in. Then I tried to restart my notebook. Nothing seems to work... – sergiomafra Jul 15 '18 at 12:54
  • crw-rw-rw- 1 root dialout 166, 0 Jul 15 05:41 /dev/ttyACM0 Login: sergio Name: Sérgio Mafra Directory: /home/sergio Shell: /bin/bash On since Sun Jul 15 08:26 (-03) on :0 from :0 (messages off) No mail. No Plan. – sergiomafra Jul 15 '18 at 12:59
  • dialout:x:20:sergio. When I tried to run the second command, bash returned to me No such file or directory – sergiomafra Jul 15 '18 at 13:15
  • 2
    @N0rbert I don't think that this question should be closed as a duplicate of How to install latest Arduino IDE? because the accepted answer to this question is more specific to the question that was asked. – karel Jul 17 '18 at 13:12

10 Answers 10

50

I had a similar issue when I tried to upload a sketch to Arduino. The issue was connected to the lack of permissions to read/write to the serial port. I was able to fix by using the following command:

To confirm the port exists enter the following from the root directory.

ls /dev/ttyACM0

To set read/write permissions, enter the following

sudo chmod a+rw /dev/ttyACM0
3
  • Didn't work for me – titusfx Sep 14 '20 at 14:29
  • 1
    This works for me, but this setting is not permanent for me. I have to this almost every time I upload a sketch – August Oct 23 '20 at 14:21
  • Or you can add the current user to the group dialog. – Pierre Jan 15 at 18:48
11

Reinstall your arduino installed from Ubuntu software center:

sudo apt install --reinstall arduino

Reinstalling is necessary since your which avrdude command according to your comment returns nothing, but should be /usr/bin/avrdude. Check again:

which avrdude

Run your Arduino IDE after reinstalling and close it.

Check your arduino configuration. Open /home/sergio/.arduino/preferences.txt file and check there serial.port option. Try to change it to /dev/ttyACM0. Open that file:

sudo nano /home/sergio/.arduino/preferences.txt

and apply corresponding changes, i.e. the option should look

serial.port=/dev/ttyACM0

Restart computer afterwards.

1
  • 1
    Thanks for all the help. I uninstalled it from Ubuntu Software Center and installed the version from arduino website and it worked. – sergiomafra Jul 15 '18 at 15:11
5

Here's what worked for me:

  • Uninstall the version from Apt, it doesn't work properly (sudo apt uninstall arduino; sudo apt autoremove)
  • Install the version from the Arduino website
  • sudo apt install avrdude since the one from the website doesn't include it
  • sudo usermod -a -G dialout $USER since the one from the website doesn't do this automatically (the dialout group owns the device file; this adds the current user to that group)

And now everything's working again!

1
  • It may be necessary to log out and back in, or even restart for the usermod command to take effect. – ESV Jul 19 '20 at 13:42
2

In combination with all the posts I read, this is what I did to solve that issue by following directions from this thread.

In a new terminal, I typed the following as shown below.

https://i.stack.imgur.com/ifRmx.png

Please note that fourplus is my username.

2
  • 2
    Welcome to ask ubuntu. In the future you should post text instead of images wherever possible. – Jeff Mar 10 '19 at 5:15
  • Didn't work for me – titusfx Sep 14 '20 at 14:29
2

This worked to fix the 'unable to open serial port' problem (put your Ubuntu username in instead of $USER) after downloading Arduino from Ubuntu Software.

sudo usermod -a -G dialout $USER  
sudo chmod a+rw /dev/ttyUSB0
1
  • Only these 2 changes (add user to dialout group AND permission change) worked for me, but you may have to change the number in ttyUSB0 for your case. – Henrique de Sousa Oct 20 '20 at 14:22
1

I see that the question is already accepted but none of the solutions did it for me so I've got a different solution. I installed the arduino IDE via the Ubuntu software installer. What you need to do is.

  1. Go to arduino IDE in Ubuntu software store
  2. click permissions
  3. set Access usb hardware directly on on
1
  • I've that setting by default and I have the problem – titusfx Sep 14 '20 at 14:26
1

ha I'm a newbie and I made some mistakes)) Don't do it the way I do.

  1. First of all, in my book there was a bad picture about the led connection scheme. I found new one and reconnected wires. Now they are connected correctly.
  2. Then I connected arudino to the computer (it's important).
  3. Then I executed the following commands:

    • ls -l /dev/ttyACM0
    • sudo usermod -a -G dialout [my_username]
    • sudo chmod a+rw /dev/ttyACM0

When I was looking for a board in menu of arduino programm (Tools -> Board) I did not find an 'Arduino/Genuino Uno' just there was an 'Arduino Uno' (I guess it's OK)

1

For me mixture of above two answers worked: First was I couldn't find avrdude, which avrdude this gave me nothing. So, I had to reinstall the arduino.

sudo apt install --reinstall arduino

This installed avrdude, and I could find it in /usr/bin/avrdude. Next thing was to set read/write permission to the serial port:

sudo chmod a+rw /dev/ttyACM0

Then I could upload the sketch on to my arduino!

1

I had the same issue, I tried installing from Ubuntu Store on 18.04 and try everysolution here. Nothing worked for me. So I downloaded the latest

I extracted and ran the following command to install it: $ sudo ./install.sh

After installing, I ran the script that came with the latest version by running the following:

$ ./arduino-linux-setup.sh <user_name>

Once the script is complete, it show you a message of "Please Rebook you system". I didn't restart when I try the solutions here, may be this is something that next users should try.

Important: When you install the software following these steps you need to go to Ubuntu Software and Give Permission to "Access Usb Hardware directly".

0

I got a solution.

  1. Find your port to which the Arduino is connected (e.g. mine was /dev/ttyUSB0). You may find it mentioned in the error message in Arduino IDE.

  2. Open the terminal (Ctrl+Alt+T).

  3. In the terminal run:

    sudo chmod 777 /dev/ttyUSB0
    

    The above command sets the required permissions.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.