Skip to main content

How to detect Arduino serial port programmically on different platform?

I am trying to write a little program that needs to detect arduino port automatically. I have tried many methods but haven't found any reliable way.

I can see that Arduino IDE could detect it, by showing /dev/cu.xyz (Arduino Uno) or COM6 (Arduino Uno) etc.

How could I detect if the device connected to the serial port is Arduino or not? Preferably without pre-flash the arduino with specific firmware.

I found this python version, by using serial.tools.list_ports.comports() here, but don't work as I tested on Windows and MacOS.

The best I can get is by using go-serial's USBManufacturer, I can get 'Arduino (www.arduino.cc)'.

I also found this post, about the same question, but without any solution.

leetom
  • 181
  • 1
  • 4