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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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
Method 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
Method 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.
Method 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
Method 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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0