Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Uploading simple sketches seems to work when I run the Arduino program as root (sudo). I would like to run it as a regular user. Has anyone faced the same problem before and fixed it?

Here is what I obtained from lsusb:

$ lsusb
Bus 002 Device 022: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)

And the Arduino program identifies it as /dev/ttyACM0. Here are its permissions:

$ ls -l /dev/ttyACM0 
crw-rw---T 1 root dialout 166, 0 Mar 14 22:03 /dev/ttyACM0

Here is the output from id

groups=1000(abhiram),20(dialout),24(cdrom),25(floppy),29(audio),
30(dip),44(video),46(plugdev),105(scanner),110(bluetooth),112(netdev)

When I upload an sketch from the examples, as a regular user, I encounter this error:

avrdude:stk500_recv(): programmer not responding

Any suggestions are welcome.

share|improve this question
    
See if this helps, section "SET THE PERMISSION" –  alexan_e Mar 14 at 17:06
1  
And +1 for not accepting the situation to run the IDE as root, but trying to figure out how to properly solve the issue. –  jippie Mar 14 at 18:38
    
What is the exact error you get when you try to run the IDE under a non-privileged user? You may need to enable verbose output in the Preferences menu. –  jippie Mar 15 at 6:12
    
Ensure you are connecting to the correct device, by unplugging, then wait for a few seconds, then replug, then check the output of dmesg for the device file that is registered. –  jippie Mar 15 at 6:15
    
Checked that, the device is discovered properly as /dev/ttyACM0: USB ACM device. So, it doesn't seem like problem to me. On the other hand, the logs from compiling and uploading( had to enable them in Preferences), seem promising. I just can't seem to copy them from the arduino program :(. (may be they are writing to a file somewhere?) –  feverDream Mar 15 at 6:37
show 3 more comments

2 Answers 2

The easiest solution is to add yourself to the dialout group.

First make a note of the output from id. Save it in file (not in /tmp as that gets cleaned out on a reboot). If you look at the output, you'll notice that your user is signed up for several groups and those groups represent extra privileges on the system. By default your Arduino is assigned to the group dialout because it registers as a serial interface and in the old days these were often used to ... dial out, using a modem.

To add yourself to the dialout group, issue the following command:

sudo usermod -a -G dialout yourUsername

Don't forget the -a flag (for appending groups rather than replacing) or you will have entirely different problems. This is the reason for making a copy of the id output to a file, so in case you do mess up at least you know what your user was configured like before.

Then log out and log in and it should work from that point.

Optionally you can double check the output for id against the output you saved before.

share|improve this answer
    
thanks @jippie, for the thoughtful answer. I have added myself to the dialout group, but the problem still seems to persist. I have modified my question with the output from the id command. –  feverDream Mar 15 at 6:06
    
My impression from your update is that the exact cause of the problem has shifted to the next issue. You are on your way to solve it. What happens when you cat /dev/ttyACM0? Does it throw an error? –  jippie Mar 15 at 6:11
    
No, the device file seems to empty, when I cat it. –  feverDream Mar 15 at 6:49
    
Empty is OK, as long as you don't get an error message. –  jippie Mar 15 at 6:57
add comment

The oft-repeated advice to "just do sudo usermod -aG dialout <username> never worked for me, and I finally figured out why. On my machine, /dev/ttyUSB0 is of the group serial and not dialout, so adding my username to dialout did nothing.

# ls -l
# crw-rw---- 1 root serial 188, 0 Mar 31 20:52 /dev/ttyUSB0
                    ^^^^^^ (group-name)

Finally: sudo usermod -aG <group-name> <username> fixed it for me.

Embarrassingly, this is also explicitly mentioned here under "SET THE PERMISSION". Sigh.

share|improve this answer
    
Yes, it's worth checking the actual owning group. Also the device file can be either a ttyUSB# or a ttyACM# (or theoretically anything) depending on the board type, kernel driver, and ultimately configuration of udev or whatever creates the nodes. –  Chris Stratton Apr 6 at 0:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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