1

I have multiple Arduinos that I want to control using Python. My problem is that when I plug my Arduinos into the computer, they get assigned the port /dev/ttyUSBx where x increments with each one I connect.

Is there any way to reserve a certain number for a certain Arduino so that I can hard code that into the Python script? If not, can I scan the port to figure out which Arduino it is?

Greenonline
3,1527 gold badges36 silver badges48 bronze badges
asked Apr 28, 2016 at 0:54
10
  • Do they have unique serial numbers? Commented Apr 28, 2016 at 1:00
  • @IgnacioVazquez-Abrams What do you mean by serial number? Do you mean the baud rate? Commented Apr 28, 2016 at 1:02
  • No. The serial number of the USB device. Commented Apr 28, 2016 at 1:02
  • @IgnacioVazquez-Abrams You mean the x in /dev/ttyUSBx? Commented Apr 28, 2016 at 1:03
  • No. I mean the serial number when you run lsusb -v. Commented Apr 28, 2016 at 1:03

1 Answer 1

4

Yes. You need to create new unique names for them using udev rules.

By using the unique serial number, along with the VID and PID of the board you can use udev to create a symbolic link to a device name of your choice. Best to keep it to something that the Arduino IDE recognises if you want to access the link from within there for programming (otherwise you can choose what you like).

Rules are stored in /etc/udev/rules.d and take the form of .rules files with various instructions in. One example, that should do what you want, is:

SUBSYSTEMS=="usb", ATTRS{product}=="Arduino Uno", ATTRS{serial}=="6493832323135111C0A1", KERNEL=="ttyACM*", SYMLINK+="ttyACM50", MODE="0666", GROUP="plugdev"

Of course, tweak it to your personal requirements.

Once you have crafted your rules be sure to restart udev:

sudo systemctl restart udev

or

sudo /etc/init.d/udev restart

and plug your board in.

Genuine Arduino devices usually use /dev/ttyACM* not /dev/ttyUSB*. If you have /dev/ttyUSB* then you are either on a very old device (with an FT232 chip) or a cheap Chinese clone.

If the latter then your mileage may vary somewhat.

answered Apr 28, 2016 at 1:04
2
  • Stepping on standard namespaces is probably not the best idea though. Naming the symlink something like "arduinoNN" might be a better idea. Commented Apr 28, 2016 at 1:09
  • Then the IDE won't see it. You notice I chose a name way up in the numbers - one not likely to be used under normal circumstances. Commented Apr 28, 2016 at 1:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.