Skip to content

pboon09/FixSerialPort_Ubuntu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Fix Serial Port in Ubuntu

Stop your USB serial device from changing from /dev/ttyACM0 to /dev/ttyACM1 every time you unplug it!

Quick Fix (3 steps)

Step 1: Find Your Device Info

udevadm info -a -n /dev/ttyACM0

Replace ttyACM0 with your actual device

Look for these 3 things in the output:

  • idVendor (example: "0483")
  • idProduct (example: "374e")
  • serial (example: "0053002F3432511330343838")

Step 2: Create the Rule

sudo nano /etc/udev/rules.d/99-usb-serial.rules

Copy this template and change the values:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", ATTRS{serial}=="0053002F3432511330343838", SYMLINK+="my_device"

Change these:

  • 0483 → your idVendor
  • 374e → your idProduct
  • 0053002F3432511330343838 → your serial
  • my_device → whatever name you want

Step 3: Apply Changes

sudo udevadm control --reload
sudo udevadm trigger

Test It

ls -la /dev/my_device

You should see your device! Now use /dev/my_device instead of /dev/ttyACM0

Examples

Arduino:

SUBSYSTEM=="tty", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", SYMLINK+="arduino"

ESP32:

SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="esp32"

STM32:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", SYMLINK+="stm32"

Multiple Same Devices?

Use the serial number to tell them apart:

# Device 1
SUBSYSTEM=="tty", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", ATTRS{serial}=="123456", SYMLINK+="device1"

# Device 2
SUBSYSTEM=="tty", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", ATTRS{serial}=="789012", SYMLINK+="device2"

No Serial Number?

Just use vendor/product ID:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", SYMLINK+="my_device"

Troubleshooting

Device not found?

lsusb  # See if device is connected
ls /dev/tty*  # See available ports

Rule not working?

  • Check for typos (spaces around == will break it)
  • Unplug and replug device
  • Check: journalctl -f then replug device

Permission issues?

sudo usermod -a -G dialout $USER

Then log out and back in.

That's it! Your device will always be /dev/my_device now.

About

Stop your USB serial device from changing from /dev/ttyACM0 to /dev/ttyACM1 every time you unplug it!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors