0

I have been attempting to read data from a TEMPerHUM USB temperature and humidity device. I can read the device from Linux. I have tried many things, pyusb, wmi, libusb, etc. None seems to work. I get a 'no backend available' error. I can find the device using WMI, but I can not find how to read it.

import wmi

try:
    c = wmi.WMI()
    print("Connected USB Devices:")
    count = 0
    for usb in c.Win32_USBControllerDevice():
        dependent_device = usb.Dependent
        if dependent_device:
            # Extract relevant information from the dependent device object
            # The 'Dependent' property refers to the connected USB device
            print(f"  Device ID: {dependent_device.DeviceID}")
            print(f"  Description: {dependent_device.Description}")
            if '10C4' in  dependent_device.DeviceID:
                print('Found UART Bridge')
            if '3553' in  dependent_device.DeviceID:
                print('Found TEMPerHUM')
            print("-" * 20)
            count += 1
except Exception as e:
    print(f"An error occurred: {e}")

print(dir(usb.Dependent))
print(f'Found {count} devices.')
x = input('Press enter to continue: ')

Does anyone have an example of reading a USB device?

2
  • You can't just read raw USB packets from a port. The B is for Bus - Multiple devices may be attached to the same port, eg through a hub. Communication goes through drivers. If your device has a Serial interface you'll see an extra Serial port in Device Manager. The manufacturer has to provide their own drivers for specialized functionality. The vendor does provide their own software for Windows. That software can't bypass how USB works, so either they add their own driver, or install a Serial driver Commented Aug 11 at 6:57
  • Did you install the latest libusb version binaries? Or the vendor's software? libusb itself isn't a driver, it's a wrapper over specific low-level USB APIs. The How to use libusb on Windows section explains how to use different .... backends. WinUSB is a generic driver provided by Windows itself. Commented Aug 11 at 7:21

1 Answer 1

1

While your Python script using the wmi library can identify the TEMPerHUM device by its device ID, it's not the right tool for reading data from it. The wmi library is for managing and querying Windows system information, not for communicating directly with USB devices to read their data streams. That's why you're able to find the device but not read from it. The "no backend available" error you encountered with other libraries like pyusb and libusb is a common issue on Windows, often caused by a missing or improperly installed backend driver. These libraries need a specific low-level driver (like libusb-win32 or Zadig) to function correctly on Windows.


Solutions

1. Using libusb and pyusb with Zadig 💻

The most reliable way to read data from a USB device on Windows is to use pyusb with a compatible backend driver. The Zadig utility is a popular choice for this. It replaces the default Windows driver for a specific USB device with a generic one (like libusb-win32 or WinUSB) that pyusb can communicate with.

  • Step 1: Download and run Zadig.

  • Step 2: Plug in your TEMPerHUM device.

  • Step 3: In Zadig, go to Options -> List All Devices.

  • Step 4: Select your TEMPerHUM device from the dropdown list. The device's vendor ID (VID) and product ID (PID) will help you identify it. You've already identified them in your script: 10C4 (the UART bridge) and 3553.

  • Step 5: Select a driver to install. libusb-win32 is a good choice for pyusb.

  • Step 6: Click "Replace Driver" or "Install Driver."

After this, pyusb should be able to find and communicate with the device.


2. Using a Specific Library for the UART Chip ⚙️

Your script correctly identified a 10C4 device, which is a common vendor ID for Silicon Labs (SiLabs). This often indicates the presence of a CP210x USB-to-UART bridge chip, which the TEMPerHUM device uses to communicate. Instead of using a generic USB library, you may have more success using a library designed to interact with these specific chips. The pyserial library can be used to communicate with the virtual COM port that the SiLabs driver creates.

  • Step 1: Install the official Silicon Labs CP210x USB to UART Bridge VCP Drivers for Windows. This will create a virtual COM port (e.g., COM3, COM4) that your Python script can access.

  • Step 2: Use the pyserial library to open the COM port and read data from it. You can find the correct COM port in your Windows Device Manager under "Ports (COM & LPT)".

import serial

try:
    # Replace 'COM3' with the actual COM port for your device
    ser = serial.Serial('COM3', 9600, timeout=1) 
    print(f"Connected to {ser.name}")

    while True:
        # Read a line of data from the device
        line = ser.readline().decode('utf-8').strip()
        if line:
            print(f"Received data: {line}")

except serial.SerialException as e:
    print(f"Error: Could not open COM port - {e}")

finally:
    if 'ser' in locals() and ser.is_open:
        ser.close()
        print("COM port closed.")
Sign up to request clarification or add additional context in comments.

2 Comments

Hi, welcome to Stack Overflow, and thank you for trying to help. This looks a lot like AI generated. Not sure it is. But just in case, be aware that generative AI is banned
The code that runs on Linux, using usb.core and usb.util will not work on Windows 11. The shape of the device data structure is different. So much for portability...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.