Get power consumption of a USB device

50,162

Solution 1

Take a look at this SuperUser Q&A titled: How do you check how much power a USB port can deliver?, specifically my answer.

lsusb -v

You can get the maximum power using lsusb -v, for example:

$ lsusb -v|egrep "^Bus|MaxPower"
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    MaxPower                0mA
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    MaxPower                0mA
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    MaxPower                0mA
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    MaxPower                0mA
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    MaxPower                0mA
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    MaxPower                0mA
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    MaxPower                0mA
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
    MaxPower              100mA
Bus 003 Device 002: ID 046d:c517 Logitech, Inc. LX710 Cordless Desktop Laser
    MaxPower               98mA
Bus 001 Device 004: ID 04a9:1069 Canon, Inc. S820
    MaxPower                2mA
Bus 001 Device 005: ID 05ac:120a Apple, Inc. iPod Nano
    MaxPower              500mA
    MaxPower              500mA

Solution 2

You could also have a look at usb-devices:

$ usb-devices | grep 'Product=\|MxPwr'
S:  Product=EHCI Host Controller
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
S:  Product=EHCI Host Controller
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
S:  Product=USB Keykoard
C:  #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=98mA
S:  Product=USB Receiver
C:  #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=98mA
S:  Product=DW375 Bluetooth Module
C:  #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=100mA
S:  Product=5880
C:  #Ifs= 2 Cfg#= 0 Atr=c0 MxPwr=100mA

Solution 3

There's a bMaxPower file in the device's sysfs folder. But I do not think it is going to be very useful. You'll be able to find that the device "requested" 500mA just to comply with the standard but not the actual current drain.

Solution 4

$ watch -n1 'lsusb -v|egrep "^Bus|MaxPower"'

And refresh every second

Cada 1,0s: lsusb -v|egrep "^Bus|MaxPower"                               Mecaro: Fri Dec  1 00:15:54 2017

Couldn't open device, some information will be missing
Couldn't open device, some information will be missing
Couldn't open device, some information will be missing
Couldn't open device, some information will be missing
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    MaxPower                0mA
Bus 002 Device 002: ID 046d:c31c Logitech, Inc. Keyboard K120
    MaxPower               90mA
Bus 002 Device 005: ID 04fc:0538 Sunplus Technology Co., Ltd Wireless Optical Mouse 2.4G [Bright]
    MaxPower              100mA
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    MaxPower                0mA

Solution 5

You probably either solved your problem or moved on by now, but this information is available on the manufacturer's web site most of the time. It is also written on every usb device I've used.

The real answer for live measurement is probably that it is not possible to get this information from the OS. My guess is that all of this is negotiated at the wire level and actually controlled by additional voltage regulators / resistors.

Furthermore, the availability of devices specifically designed for this is for me the final hint that no "easy" solution exists.

Share:
50,162

Related videos on Youtube

TheMeaningfulEngineer
Author by

TheMeaningfulEngineer

I like to think of myself as a Hardware/Software guy who will gladly discuss referential transparency during a code review and the next moment take a circular saw to build a casing for a self made power supply. My main interest can be summarized into Linux related software development, low power electronics and general DIY projects.

Updated on September 18, 2022

Comments

  • TheMeaningfulEngineer
    TheMeaningfulEngineer over 1 year

    Is there a way to check how much power a USB device requires?

    Why do I need this?

    I need to connect an LTE USB stick to my Raspberry Pi, and don't know how much power it needs. We got it quite easily on Windows, but haven't found a way to do it on Linux.

  • Huygens
    Huygens almost 9 years
    I don't think that it is a correct answer. My arduino is reported as using 100mA even when I'm putting it to sleep (where other have measured a power consumption of about 56mA then). If I make my Arduino active, it is also reported as 100mA...
  • dr. Sybren
    dr. Sybren almost 8 years
    The "manufacturer's web site" is of little use when you're making your own USB device ;-)
  • Jaeda
    Jaeda almost 7 years
    Can you please suggest the similar command for Windows?
  • Chris
    Chris over 4 years
    @Huygens is correct! This is reporting the amount of current the device is requesting...not the amount it's actually drawing from the system. I haven't discovered a way in the OS to get a report of the actual current being drawn. I don't know if this information is available.