USB and serial on Linux: where /dev/ttyUSB0 comes from
Atlasbot · 20/8/2026 · 10 min read
Plug a LiDAR or Arduino into a computer running Linux, the ROS2 driver always needs to know exactly where that device is located — usually in the form /dev/ttyUSB0 or /dev/ttyACM0. Understanding why Linux is named the way it is, and how to check yourself when a device "disappears" or changes its name, saves a lot of time debugging hardware.
Why does the USB serial device appear as a file
According to the Linux philosophy of "everything is a file" (mentioned in the basic Linux article), when plugging in a USB serial communication device, the kernel does not display a window or notification like Windows — it creates a device file in /dev, and every program (including the ROS2 driver) reads/writes data by reading/writing that file, exactly like working with a regular text file.
What is the difference between ttyUSB and ttyACM?
The two most common name types, differing in the chip/kernel driver used to communicate:
| Device name | When did it appear? | Practical example |
|---|---|---|
/dev/ttyUSBx | Devices using separate USB-to-Serial conversion chips (CP2102, CH340, FTDI) | LiDAR YDLIDAR/RPLiDAR via conversion board, USB-to-TTL module |
/dev/ttyACMx | The device has a built-in USB controller, using the CDC-ACM standard | Arduino Uno/Mega (type with separate USB chip, not via separate converter) |
There is no hard rule "which device type is always ttyUSB or ttyACM" — it depends on the specific chip on the board, so the surest way is always to check directly with the command, not guessing by the device name.
In short:
/dev/ttyUSBx//dev/ttyACMxis a file representing the serial port via USB — the serial number (0,1...) is assigned by the kernel in the order of plugging in, is not fixed, easy to change when plugging in multiple devices or re-plugging in order other.
Test the device using the command line
# Lists all available serial devices
$ ls /dev/tty*
/dev/ttyUSB0 /dev/ttyS0 /dev/ttyS1 ...
# View the kernel log to see how the newly plugged-in device is identified
$ dmesg | tail -20
[12045.234] usb 1-1.2: new full-speed USB device number 7 using xhci_hcd
[12045.367] usb 1-1.2: Product: CP2102 USB to UART Bridge Controller
[12045.368] cp210x 1-1.2:1.0: cp210x converter now attached to ttyUSB0
# View details of currently plugged USB device (vendor/product ID, name)
$ lsusb
Bus 001 Device 007: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
dmesg is the most important diagnostic tool when a device is not working as expected — running dmesg | tail immediately after plugging in the device shows exactly whether the kernel recognizes it or not, and what name to assign.
Read raw data from the serial port
Before suspecting a problem with the ROS2 driver, you should confirm that device has output data at the lowest layer using a simple terminal serial tool:
$ sudo apt install screen
$ screen /dev/ttyUSB0 115200 # 115200 = baud rate, must match device
# Seeing data (possibly jumbled characters if the baud rate is wrong) means the device is sending
# Exit with Ctrl+A then key k, confirm y
If screen does not show anything — the problem is in the hardware/baud rate, not in the ROS2 code, so checking this step before debugging the driver will save a lot of time.
Technical details
Formulas
Each USB device has a pair of identifiers Vendor ID : Product ID (VID:PID), written as 2 4-digit hex numbers separated by : — which is the ID column that appears in output lsusb in the example above (10c4:ea60):
VID:PID = 4 hex digit (manufacturer): 4 hex digit (product code)
VD: 10c4:ea60
10c4 = Silicon Labs (CP2102 chip manufacturer)
ea60 = specific product code of CP210x UART Bridge chip
This VID:PID pair is the exact thing used to write the rule udev (next article) to correctly identify a specific device, regardless of which USB port it is plugged into or what number ttyUSBx is assigned by the kernel.
Parameters
Default/commonly used baud rate of some common types of serial devices when assembling robots:
| Equipment | Typical baud rate |
|---|---|
| Module GPS | 9600 |
Arduino (default Serial.begin()) | 9600 (can be configured higher) |
| LiDAR 2D (RPLiDAR, YDLiDAR) | 115200 – 256000 depending on model |
Practical applications
A difficult error to diagnose on mobile robots is that the LiDAR/USB sensor suddenly loses connection and then reconnects after a few seconds — usually not due to a loose cable, but due to Linux's USB autosuspend feature that automatically "sleeps" inactive USB ports to save power, causing immediate interruption to the device that is continuously transmitting data. Turning off autosuspend for the correct device (via the configuration file in /sys/bus/usb/devices/.../power/control, set on instead of auto) is an important diagnostic/fixing step when encountering the "accidentally disconnected sensor" situation on battery-powered robots, where USB power saving can be automatically enabled by default.
Common mistakes
Permission deniedwhen opening/dev/ttyUSB0— user is not in groupdialout, see how to fix it in the basic Linux article.- Device does not appear in
ls /dev/tty*even though plugged in — checkdmesgto see if the kernel detects the USB; Iflsusbalso doesn't see the device, there's a high possibility that the USB cable only supports charging, no data wire — an extremely common error and easy to ignore, especially with the cable that comes with the phone charger. - Device name changes from
ttyUSB0tottyUSB1after replugging or adding another device — this is default kernel behavior, not a bug. If you need a fixed name (eg: the robot has both LiDAR and Arduino plugged into the USB), see article udev rules next in the category to assign a unique name that does not change. - The read data is full of strange characters (garbage) — wrong baud rate between the device and the reading program, review the baud rate parameters in the device documentation.
Conclusion
/dev/ttyUSBx//dev/ttyACMx is just a file created by the kernel when recognizing a serial device via USB — the serial number can be changed at any time depending on the order of insertion. For robots with only 1 serial device, this is less of a problem; But when there are multiple sensors/boards plugged into USB, a fixed name is needed — that's the topic of the next article: udev rules.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.