0
votes

I use arduino uno clone. My OS is linux mint. During uploading code, I take an error like this: Arduino:1.8.15 (Linux), Kart:"Arduino Uno"

An error occurred while uploading the draft avrdude: ser_open(): can't open device "/dev/ttyUSB0": Permission denied

1

1 Answers

0
votes

You have /dev/ttyS0 in your title. This is a device name for more traditional serial port. Like, if you have a 9-pin serial port on your machine, this would be the the sort of name it would have. This is not for your UNO clone. The /dev/ttyUSB0 in your error listing is more reasonable for an UNO clone.


The typical way you deal with this is to add yourself to the group owner of the /dev/ttyUSB0 (or whatever) device.

stat -c '%G' /dev/ttyUSB0 # shows the group owner for /dev/ttyUSB0

For Mint (like Debian and Ubuntu) this is probably the dialout user; I'm going to assume that. If not, you can change it accordingly.

If you run groups, at a shell prompt you will probably see that you're part of cdrom and input and a bunch others, but not dialout or whatever stat yielded. You will also find you are not listed in the output of getent group dialout. You can add yourself to dialout with:

sudo usermod -a -G dialout "${USER}"

When you do this you should see that getent group dialout now lists your user account, but groups does not list dialout. The former is telling you that you've successfully added yourself to the group. The latter tells you that you have not seen the effect of this change because you have not since gone through a login process, which is what reads the configuration that you've changed. In other words, adding yourself to dialout is necessary but not sufficient.

If you relogin (or to radically simplify: if you reboot), you should then see dialout in the output of the groups command and your permission denied error should now be gone and replaced with either success or some other type of failure.