How to monitor voltage and power with the GUI or Python
Among other properties, 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
What else could you do with USBHub3+?
- Independently control VBus and data for each port
- Turn on and off VBus
- Enable and disable data connections:
- Power Measurements
- Measure current and voltage on each port
- Monitor input power and system power
- Switch ports between Charging Downstream Port (CDP) and Standard Downstream Port (SDP) (up to 500 mA)
- View the enumeration speed of a connected device
- Switch upstream hosts
- Automatically
- Programatically
- Add more ports by daisy chaining hubs
Add New Comment