Very often, we’re looking to charge our devices via USB ports on our Linux systems. Usually, we might not be aware of the power requirement for our devices or the capabilities of our ports. Still, several issues can occur when gadgets aren’t charged at their optimal level.
First, the device won’t charge the way its manufacturer intended. This isn’t good for the battery’s long-term health. Secondly, it won’t charge as quickly as it could. Thirdly, we need to connect several USB devices to our laptops occasionally. This can lead to more power consumption. By figuring out the power requirement, we can unplug unnecessary devices to save some power.
In this tutorial, we’ll see how to check the power requirements of USB devices connected to a Linux system. Specifically, we’re using an Ubuntu 22.04 system. Most of the tools and commands should work on any Linux system.
2. Using lsusb Command
The lsusb command lists all the USB devices connected to our system. Moreover, it displays information about them, including the manufacturer and product ID, as well as the amount of power they’re drawing:
$ sudo lsusb -v Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 3.00 ...
The -v option makes the output verbose. Also, by using sudo privileges, lsusb gives more in-depth information. From the output, we can look for the target device using its name.
The MaxPower attribute shows the maximum power requirement of the device. Furthermore, we can use the watch command to continuously check the power draw capability of a given device:
$ sudo watch -n1 'lsusb -v | egrep "^Bus|MaxPower"' Every 1.0s: lsusb -v|egrep "^Bus|MaxPower" juveriya: Thu May 4 16:55:44 2023 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub MaxPower 0mA Bus 001 Device 006: ID 0bda:b009 Realtek Semiconductor Corp. Realtek Bluetooth 4 .2 Adapter MaxPower 500mA Bus 001 Device 005: ID 04ca:7092 Lite-On Technology Corp. ... ...
The egrep command filters the output of lsusb to show only the lines starting with the text Bus or containing the text MaxPower. The watch command then executes the whole command every second using the -n option.
3. Using lshw Command
lshw also shows the system hardware information on the command line. Let’s use the lshw command to check the USB power requirements:
$ sudo lshw | grep usb capabilities: pci upgradeint10video acpi usb biosbootspecific... *-usb *-usbhost:0 bus info: usb@1 logical name: usb1 ...
The sudo keyword gives lshw more privileges to perform the hardware scanning. Notably, from the output, we can see no description of the USB device name. So, a workaround for finding the real device name is to re-run the lshw command using different options.
For example, if our USB hardware is an input device, we can list all the input devices via the -class option and the input category:
$ sudo lshw -class input *-usb:1 description: Keyboard product: Logitech USB Keyboard System Control vendor: Logitech physical id: 2 ...
Now, let’s suppose our target USB device is *-usb:1. We can again run a combination of grep and lshw to get only the required result:
$ sudo lshw | grep '*-usb:1' -A19 | grep -v 'logical*' *-usb:1 description: Keyboard product: Logitech USB Keyboard System Control vendor: Logitech version: 64.02 capabilities: usb-1.10 usb configuration: driver=usbhid maxpower=90mA speed=2Mbit/s
First, the lshw shows the details of all the hardware components. Then, the first grep command picks the first 19 lines corresponding to the *-usb:1 device using the -A option. The second grep command filters out the entries containing the text logical. This further simplifies the output.
As can be seen from the output, the maxpower attribute shows the maximum power requirement for the device *-usb:1.
4. Using HardInfo Utility
HardInfo is a graphical utility that shows system hardware information. Let’s start HardInfo with sudo privileges to obtain in-depth system hardware information. After starting HardInfo, we can follow several steps to check the power usage of a device:
- Click Devices category
- Click USB Devices subcategory
- Select a device from the list on the right-side pane
In the above picture, we can see that the power requirement for one USB storage device is 224mA.
5. Using USBView Utility
We can also use the USBView tool to check USB power requirements. USBView is another simple graphical utility that displays detailed information about USB devices connected to our system. On Ubuntu, we can install it with the usual apt command:
$ sudo apt install usbview
Once onboard, we can launch it from the terminal with the sudo privileges:
$ sudo usbview
This launches a USBViewer window showing all the USB devices. To see the details for a specific device, we can click on its name in the tree view. The right-hand pane shows various data about the device.
Under the Config Number label, we can look for the line that contains the attribute MaxPower Needed:
In the above image, the maximum power requirement for the USB Keyboard is 90mA.
In this article, we’ve discussed various ways to check the maximum power needed by a USB device.
Overall, checking USB power requirements can be essential for ensuring that our devices receive the correct amount of power. Furthermore, this can help prevent damage to our hardware. Whether we choose to use command-line tools or graphical utilities like Hardinfo or USBView, the process is usually straightforward.