How to Assign a USB port in Raspberry PLC
Rename your devices in the USB ports of Raspberry PLC for a better organization
20 October, 2021 by
How to Assign a USB port in Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

INTRODUCTION

Many times, we plug several devices in the USB ports of the Raspberry PLC, and it is difficult to identify which one is the one that we want to use, since the names are something like this: /dev/ttyUSB0, dev/ttyUSB1 or /dev/video0, /dev/video1...

In this blog post, we are going to take the ID of each device that we want to identify, and assign it with a specific name so that every time you connect it to the USB port, you see the assigned name.

Latest Posts

REQUIREMENTS

Identify the USB port

In order to assign a name for every device, it is better if you first do it step by step, and only connect one device to the USB ports, in order to identify it without any problem.

1. Run the following command and list the USB devices:

lsusb
Odoo • Image and Text

2. Plug the USB.

Odoo • Image and Text

3. Type again:

lsusb
Odoo • Image and Text

And check that the Raspberry PLC identifies your USB device.


4. In order to identify the USB port, you can run:

  • dmesg | grep ttyUSB
In order to identify the USB if it is a camera:

In case you are using a USB camera. This will show information like the port that is being used: /dev/video0

5. Find the IDs of your device

udevadm info --name=YOUR-PORT-HERE --attribute-walk

In our case:

udevadm info --name=/dev/video0 --attribute-walk
Odoo • Image and Text

6. Create a new file with the USB port name rules

Run:

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


Add the subsystem, idProduct, idVendor and set the name to the symlink attribute like:

SUBSYSTEM=="usb", ATTRS{idProduct}=="62c0", ATTRS{idVendor}=="0c45", SYMLINK+="WebCam"

Odoo • Image and Text

7. Load the device administrator

sudo udevadm trigger

 Test the new USB port name

  • ls -l /dev/ttyUSB*
    ls -l /dev/video0
Odoo • Image and Text

Test it by unplugging and plugging the camera, and check that now, you will identify your by its name!

How to Assign a USB port in Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
20 October, 2021
Share this post
Archive

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>

Do you want more information?

Just fill the form!

Tell me more!