6. May 2021

How to find COM port of connected IoT device on Windows

When you need to talk to an IoT device over RS232 connected to the computer via USB cable, the first thing that you need to know is the name of the port. Windows assigns port numbers like COM3, COM7, COM21 to connected devices. How to find the number?
The quick way is to type the following command:

The quick way is to type following command:


The output:

COM10 = \Device\VCP1
COM9 = \Device\VCP0

For older versions of Windows you can use:


The output:

Status for device COM9:
    Baud:            1200
    Parity:          None
    Data Bits:       7
    Stop Bits:       1
    Timeout:         OFF
    XON/XOFF:        OFF
    CTS handshaking: OFF
    DSR handshaking: OFF
    DSR sensitivity: OFF
    DTR circuit:     ON
    RTS circuit:     ON

You can find all these hints also on SuperUser.

But what to do when the device is connected and the list of COM ports is empty?

The most common reason is that Windows is missing one of the following drivers:

Steps to resolve the problem:

The system should pick the installed driver and assign it to the device.

You can use also idf-env tool to install the drivers by following PowerShell commands:

Invoke-WebRequest 'https://dl.espressif.com/dl/idf-env/idf-env.exe' -OutFile .\idf-env.exe
.\idf-env.exe driver install --ftdi --silabs

Footnote: following PowerShell command might NOT list all connected IoT COM devices, but you can find it on many forums on the internet. Often it displays just COM3 and COM4 which are not associated with IoT device.

Get-WMIObject Win32_SerialPort | Select-Object Name,DeviceID,Description

3. May 2021

How to add/remove device driver from command-line on Windows

Windows operating system contains a tool that allows manipulation with system drivers stored in .INF and .CAT files. The operation requires Administrator privileges.

Command to install the driver:

pnputil /add-driver my-driver.inf /install

The correct installation display the following result:

Microsoft PnP Utility

Adding driver package:  my-driver.inf
Driver package added successfully.
Published Name:         oem3.inf

Total driver packages:  1
Added driver packages:  1

To verify the result you can plug the device and it should pick the correct driver. The system copied content from my-driver.inf to C:\Windows\INF\oem3.inf. The number in file name might be different.

The remove the driver from the system and perform uninstallation of the driver from devices type following command:

pnputil /remove-driver my-driver.inf /uninstall

Expected result:

Microsoft PnP Utility

Driver package deleted successfully.