Raspberry PI and several Arduinos (USB)

Hello guys,

There was a similar topic but that is for i2c connected Arduinos.

My project is one raspberry pi and 2 USB connected Arduino Pro Micros.

These ones shown up as:

crw-rw---- 1 root dialout 166, 0 Feb 24 10:42 /dev/ttyACM0
crw-rw---- 1 root dialout 166, 1 Feb 24 10:40 /dev/ttyACM1

lsusb | grep -i spar
Bus 001 Device 002: ID 1b4f:9206 SparkFun SparkFun Pro Micro
Bus 003 Device 002: ID 1b4f:9206 SparkFun SparkFun Pro Micro

Now the problem is sometimes rebooting the raspberry the serial ports gets swapped ttyACM0 becomes 1 and vice versa. Is there any way to make this static?

As you see it even makes it more difficult that the two are exactly identical so even the device id is the same :slight_smile:

I found a similar discussion here: tty - Assign static /dev/ttyACM[0-9] static - Unix & Linux Stack Exchange

Not really helpful. For example for me: /dev/serial/by-id/long-garbage

ls -al /dev/serial/by-id/            
total 0
drwxr-xr-x 2 root root 60 Feb 24 10:21 .
drwxr-xr-x 4 root root 80 Feb 24 10:21 ..
lrwxrwxrwx 1 root root 13 Feb 24 10:21 usb-SparkFun_SparkFun_Pro_Micro-if00 -> ../../ttyACM0

Only one is showing up here while both works just fine :confused:

I find the simplest way on both Windows and Linux when serial ports swop around is for the target microcontrollers to identify themselves, e.g. the host RPi transmits a ? and the micros respond with a unique identifier (possibly set by a DIP switch)

I'm not sure that would be so easy to implement in my case.

One I use to push commands to through ser2net so ser2net already need to know which is the "right one".

The other I address directly with redirects from shell scripts as that is command only arduino, I don't read back anything.

Don't allow ser2net to start as a daemon. Run it interactively after you have figured out which device is which.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.