Showing results for 
Search instead for 
Did you mean: 

Need an Help to to read the Laptops/TAB's VID and PID using STM32F103 Series MCU Via Type C usb


Hi Team, 

     We are using the STM32F103RDT6 microcontroller in one of our projects. The end-user application of our project is a laptop vending machine. Simply put, students can acquire laptops/tablets by using their IDs. However, we are facing difficulties in verifying whether the laptops/tablets returned by the students are the same devices they took. All of the devices are Type-C only.

Therefore, we are planning to automatically read the Vendor ID (VID) and Product ID (PID) of the devices (laptops/tablets) using the STM32 microcontroller. Can you suggest or help us with the procedure to make this happen? Is it possible to read the Product ID using STM32?


It sounds like, you have a misunderstanding about USB VID and PID:
as Andrew Neil has pointed out: the VID and PID are provided by a USB Device:

If you connect a laptop with an USB Device - this USB device (your STM32 MCU) will send the VID and PID:

  • but these VID and PID are usually associated with a driver which the laptop has to activate (in order to talk to the STM32 MCU): the laptop needs to get the USB Enumeration from the device, e.g. if is it a Mass Storage Device (USB memory stick), a VCP UART, a HID device (mouse and keyboard) or something else.
  • and "hijacking" an USB VID is not "legal":
    every vendor of USB Devices (e.g. Memory Sticks) has a VID: this is registered, and these companies might pay for the database entry. You cannot simply "fake" or "hijack" a vendor ID (it is not legal; it belongs to a company "following the rules" for USB product registration)

So, I assume this use case:

  • all the laptops are connected on an STM32 MCU which should "assign" a unique ID to every laptop (before rented or taken away)
  • if a student grabs a laptop - you want to verify later, when they return the laptop, if is the "same" one.

What you could do:

  • all the laptops are connected to an STM32 MCU (via USB)
  • but the laptop "talks" to the STM32 MCU (e.g. via VCP UART)
  • and every laptop receives a Unique ID from STM32 MCU - check out what UUID is!
  • Such a UUID can be a combination of time, data, a random number...
  • store this UUID, assigned by a STM32 MCU somewhere on the laptop (e.g. in registry): you need a special application running on laptop, the users have to start, e.g. a "RentMeApp"
  • this stores such an UUID, generated by a STM32 MCU (when connected via USB to it)
  • Later, when returning the laptops: you start a SW App again, on laptop, which looks for the stored UUID
    and displays it (e.g. an App "ReturnMeApp": it will display (and maybe decode) the UUID assigned and stored - now you can check which laptop was returned
  • You need SW on your laptop: STM32 with USB cannot "solve" your issue.
    (all laptops would connect to the same STM32 MCU with the same VID and PID - you need other means to realize which laptop is which, e.g. via UUID, generated by the STM32 MCU)

@tjaekel wrote:
  • You need SW on your laptop: STM32 with USB cannot "solve" your issue [alone].

^^^ This! ^^^

Some other things often used for creating a "Unique ID" for a computer include:

  • Hard driver serial number
  • Ethernet / WiFi / BT MAC(s),What%20are%20Different%20Ways%20to%20Generate%20a%20Device%20ID%3F,-Manual%20assignment%3A%20One 

I guess, on a modern PC, the TPM could be used?