Set a USB device to always be /dev/ttyUSB1

Hello.
I have 2 USB devices on my Raspberry PI, both Modbus as 1 reads my Solar equipment and the other reads an energy meter. At midnight my Pi reboots, and every so often I have to go into Node Red to change the /dev/ttyUSB1 to /dev/ttyUSB0 for my Solar equipment and then /dev/ttyUSB0 to /dev/ttyUSB1 for my energy meter. Is there a way that I can make /dev/ttyUSB1 to always be the same device please?
Thanks
Paul

Have a look here:
https://www.domoticz.com/wiki/PersistentUSBDevices

A question - Why do you reboot at midnight?

I don't know if this applies.

but if these are serial devices - they will have a static entry in /dev/serial/by-id
so rather then pointing to /dev/ttyUSBX point it to its
corresponding ID. /dev/serial/by-id/xx-xx-xx

These ID's don't change and they are symlinks to /dev/ttyUSBX

2 Likes

That was going to be my recommendation as well. That's how I've set up my two USB serial devices. Much easier and saves you faffing with setup.

1 Like

It does! I had forgotten this! Works fine with me.

1 Like

Thanks all. Will help me out that.
I just have a midnight boot on it as sometimes it becomes really slow to access remotely and found a reboot helps it out

A word of warning on USB devices. Some cheap clone serial donges don't have a serial number (and I think that can't add one either) so they just get added by the Linux sub-system in the order they respond. Real serial dongle have a serial number and each is unique so they can be properly handled by the USB subsystem.

Note: serial number != serial port. :slight_smile: