1. Overview

Bluetooth technology has become an integral part of our daily lives, connecting various devices such as headphones, keyboards, mice, and smartphones. Monitoring the battery level of these devices ensures they remain operational and avoid unexpected disconnections. In Linux, checking the battery level of a connected Bluetooth device might not be as straightforward as in some other operating systems. Still, with the right tools and commands, it’s quite manageable.

In this tutorial, we’ll explore how to check the battery level of a connected Bluetooth device in Linux.

2. Why Check Bluetooth Device Battery Levels?

Keeping an eye on the battery levels of Bluetooth devices is crucial for several reasons:

  • prevent interruptions: knowing the battery status helps avoid sudden disconnections during important tasks
  • prolong device life: regular monitoring can help maintain the health and longevity of our devices by preventing deep discharges
  • user convenience: ensures us that the device has enough power for different activities, whether it’s listening to music, working, or exercising

Regular monitoring of battery levels is essential to ensure that Bluetooth devices remain reliable and operational when needed.

3. Checking the Status of the Bluetooth Service

Before diving into checking the battery level of a Bluetooth device, let’s first open the terminal and check the status of Bluetooth on our Linux system using systemctl:

$ systemctl status bluetooth.service 
● bluetooth.service - Bluetooth service
     Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; preset: disabled)
     Active: active (running) since Fri 2024-07-19 06:50:00 +0545; 37min ago
       Docs: man:bluetoothd(8)
   Main PID: 1020 (bluetoothd)
     Status: "Running"
      Tasks: 1 (limit: 9185)
...

The command output shows that the Bluetooth service is active and running. If the Bluetooth service is inactive, we can start it using systemctl:

$ sudo systemctl start bluetooth.service

Confirming the Bluetooth service is active is a critical step before checking the battery level of any connected devices.

4. Checking Bluetooth Device Battery Level – GUI Method

Using a Graphical User Interface (GUI) to check the battery level of a Bluetooth device can be more intuitive and user-friendly, especially for those who prefer not to use the command line. One popular GUI tool for managing Bluetooth devices on Linux is blueman.

4.1. Using blueman

blueman is a user-friendly graphical Bluetooth manager that integrates with the GNOME desktop environment. It includes a plugin for displaying the battery level of connected devices.

If blueman isn’t installed, we can install it using apt-get:

$ sudo apt-get install blueman

Now, let’s launch blueman from our applications menu or by executing the blueman-manager command in the terminal:

$ blueman-manager

Then, we must search nearby Bluetooth devices and select the device to connect as indicated by the red rectangular box:

Connect Bluetooth Device using blueman-manager

After connecting the Bluetooth device, we can check its battery level by just pointing the cursor at the battery icon:

Check Battery level off connected Bluetooth Device using blueman-manager

The picture indicates the Battery level of the Bluetooth headset is 100%.

5. Checking Bluetooth Device Battery Level – CLI Method

Linux provides various command-line tools for checking the battery level of a connected Bluetooth device, with upower and bluetoothctl being two common options.

5.1. Using upower

upower is a command-line utility that provides information about power devices attached to the system, including the battery status of connected Bluetooth devices.

Let’s begin with the installation of upower using apt-get:

$ sudo apt-get install upower

After we complete the installation, let’s list all power devices using upower along with the -e (enumerate) option:

$ upower -e
/org/freedesktop/UPower/devices/line_power_AC
/org/freedesktop/UPower/devices/battery_BAT0
/org/freedesktop/UPower/devices/headset_dev_F4_8E_FA_E2_A1_C0
/org/freedesktop/UPower/devices/DisplayDevice

The command output provides paths to the UPower-managed power devices, indicating different types of power sources and battery-powered components. Here’s a brief explanation of each device in the output:

  • …/line_power_AC: represents the AC power adapter
  • …/battery_BAT0: represents the primary battery of the device (e.g., laptop battery)
  • …/headset_dev_F4_8E_FA_E2_A1_C0: represents a connected Bluetooth or wireless headset
  • …/DisplayDevice: represents the system’s primary power source (e.g., battery or AC power).

We can use the upower command along with the -i option, followed by the device path (in this case, the connected Bluetooth device path is /org/freedesktop/UPower/devices/headset_dev_F4_8E_FA_E2_A1_C0), to get detailed information about a currently connected Bluetooth headset:

$ upower -i /org/freedesktop/UPower/devices/headset_dev_F4_8E_FA_E2_A1_C0
  native-path:          /org/bluez/hci0/dev_F4_8E_FA_E2_A1_C0
  model:                Soundcool09
  serial:               F4:8E:FA:E2:A1:C0
  power supply:         no
  updated:              Tue 16 Jul 2024 04:08:50 PM +0545 (1793 seconds ago)
  has history:          yes
  has statistics:       no
  headset
    warning-level:       none
    percentage:          100%
 ...

The command output shows that the Bluetooth headset (model: Soundcool09, serial: F4:8E:FA:E2:A1:C0) has a battery level of 100%.

5.2. Using bluetoothctl

bluetoothctl is a command-line utility provided by BlueZ, the official Linux Bluetooth protocol stack that allows users to control the Bluetooth device and manage connections.

Let’s launch bluetoothctl in the terminal:

$ bluetoothctl

Firstly, we’ll execute the power on command to turn on the Bluetooth adapter, then use the scan on command to initiate a scan to discover nearby Bluetooth devices:

$ bluetoothctl        
Waiting to connect to bluetoothd...
[bluetooth]# Agent registered
[bluetooth]# power on
[bluetooth]# Changing power on succeeded

[bluetooth]# scan on
[bluetooth]# SetDiscoveryFilter success
[bluetooth]# Discovery started
[bluetooth]# [CHG] Controller 36:E1:2D:F4:A1:EB Discovering: yes
[bluetooth]# [NEW] Device F4:8E:FA:E2:A1:C0 Soundcool09

Once we find out the MAC Address of the Bluetooth device, we’ll use the connect command along with its MAC address to establish a connection:

[bluetooth]# connect F4:8E:FA:E2:A1:C0
Attempting to connect to F4:8E:FA:E2:A1:C0
[CHG] Device F4:8E:FA:E2:A1:C0 Connected: yes
[Soundcool09]# [CHG] Device F4:8E:FA:E2:A1:C0 Paired: yes
...

Once the Bluetooth device gets connected, let’s check its battery level using the info command and the MAC Address:

[Soundcool09]# info F4:8E:FA:E2:A1:C0
Device F4:8E:FA:E2:A1:C0 (public)
        Name: Soundcool09
        Alias: Soundcool09

The output of the info command for the device with MAC address F4:8E:FA:E2:A1:C0 (Soundcool09) shows it as an audio headset that is paired, bonded, and connected. The Battery Percentage: 0*64 (100) indicates the battery is fully charged. Further, to terminate the interactive session, we’ll use the exit command.

6. Conclusion

In this article, we explored both the CLI and GUI methods for checking the battery level of a connected Bluetooth device in Linux.

Whether we prefer command-line tools like bluetoothctl and upower, or graphical interfaces like blueman, Linux offers several ways to monitor a Bluetooth device’s battery level. By keeping an eye on our device’s battery level, we can ensure uninterrupted usage and avoid any inconvenient surprises.