How can I check the battery level of a connected bluetooth device? The device shows the battery level on Android so I'm assuming the device supports the GATT-based Battery Service. However, by entering "menu gatt" in bluetoothctl and then listing the GATT attributes of the device with "list-attributes [dev]", nothing shows up.
A similar question was posted to SO but the OP seems to have found a solution that doesn't work for me. When I run "info [dev]" in bluetoothctl I don't see the UUID for Battery Service.
I would prefer a solution that runs on the command line and is distro-agnostic.
Please let me know if this question should be posted on SuperUser instead.
All you need to do is pair and connect a Bluetooth device to your phone. Once you've done that, open the Settings app and go to Connect Devices. Tap Bluetooth (not the switch next to it). You will see a complete list of all connected devices and their battery level with some exceptions.
Using the upower command, we're able to print a detailed output about the battery status using one or two commands. The information can also be accessed using the files in the /sys/class/power_supply/BAT0/ (or BAT1) directory.
To interact with bluetoothd from the terminal, we use the bluetoothctl command. Using bluetoothctl by itself will open the interactive shell. This is called interactive mode and is where we can run commands to configure our Bluetooth settings.
This might be a bit late to the party but for me this Python project has worked fine:
https://github.com/TheWeirdDev/Bluetooth_Headset_Battery_Level
I only had to change the port in line 57 to 3 for my no-name X5 headset. If it hangs or errors with "connection refused" try a different port.
The Python program uses AT commands via RFCOMM and should work while Pulseaudio is using the A2DP sink (mine reconnects). Python 3 is needed as 2 doesn't have BT-Serial sockets. Windows will probably not work as it lacks bluez. It basically does the same thing as the Pulseaudio hack here: https://stackoverflow.com/a/56390625/920122
If you want to look at the commands as they are exchanged, try my debug fork: https://github.com/clst/Bluetooth_Headset_Battery_Level
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With