Learn how to measure power and voltage with the USBHUB3+ using HubTool or the Brainstem API

2023 October 12

Power Measurement and Voltage Monitoring with USBHUB3+

Among other properties, using the USBHub3+ we can view:

  • Per-port Voltage

  • Per-port Current

  • Input Voltage

  • Input Current

Measuring voltage and current with HubTool

If you haven't already, install HubTool, which is part of the Brainstem Dev Kit.
Power on the hub and connect one of the host ports to your computer

All of the VBus LEDs on the front panel should be on. Launch HubTool (located in "bin")

You should see a mostly blank window with the serial number of the connected hub(s) in the lower right.  Click on the hub to connect.
There will be an overview of the hub connections.  Connect a device to a port.

Here, we have an iPhone plugged into port 0 via lightning cable, so the yellow LED is on to indicate a High Speed data connection.  The port's voltage is 4.903 V, Current is 1.431 A, so the phone is charging at 7W.  In the upper left, we see that the input is at 12.2 V, 0.9 A (11W).  

Power measurements with Python

We'll be working in an interactive python console to be able to work line-by-line.  The hub and a device are connected as in the hubTool example above.

If you haven’t already, install the brainstem package (See the Quickstart Guide for more detail)


>>> !pip install brainstem --upgrade

Then import the brainstem library


>>> import brainstem

Create an instance of the USBHub3p called "hub"


>>> hub = brainstem.stem.USBHub3p()

Discover and connect to the hub


>>> hub.discoverAndConnect(brainstem.link.Spec.USB)
0

A return value of 0 means no error.  

We can view the port voltage in microvolts and current in microamps:


>>> hub.usb.getPortVoltage(0).value
4991400
>>> hub.usb.getPortCurrent(0).value
1156413

In this case, the device on port 0 is charging at 5 V, 1.16 A.
The hub's input voltage (µV) and current (µA) are also viewable:


>>> hub.system.getInputVoltage().value
12224000
>>> hub.system.getInputCurrent().value
495014

So the hub input is 12.2 V, 4.95 A

Using the USBHub3+ and its accompanying HubTool and BrainStem API, users can easily measure and monitor voltages and currents of each port and of the hub overall. The straightforward GUI and Python commands allow for effective power monitoring for connected devices. Whether you're debugging a prototype, performing in-line tests in a factory, or just charging a device, USBHub3+ lets you track power metrics in detail.

Shop Now

 

What else could you do with USBHub3+?

 

Add New Comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA