- Bluetooth LE Signal Strength Linux
- 8 Answers 8
- No need to connect when using btmgmt
- Low Signal Strength of Bluetooth in Ubuntu 18.04
- How to improve weak Bluetooth signal on a Linux laptop?
- 1 Answer 1
- 2023-03-31 update
- 2023-03-30 update
- 2023-01-06 update
- Side note
- 2022-12-31 update
- 2022-12-29 update
- 2022-03-11 update
- Old answer
Bluetooth LE Signal Strength Linux
Hello is there any way to get the signal strength of near by bluetooth le devises in linux? Or any good libraries for nodejs, php or mono (I do know some c++ or python but would prefer to say away from them) if a tool does not exisst but would be fairly easy to write.
8 Answers 8
On Linux, the way to do this is with the hcitool command. However, you have to be connected to get the rssi of a device. If you want to achieve this from the command line, try:
#hcitool rssi AA:BB:CC:DD:EE:FF
If you want to see the actual C code to achieve this, take a look at the bluez tools/hcitool.c file, under the cmd_rssi function.
static void cmd_rssi(int dev_id, int argc, char **argv)
For Bluetooth Low Energy, I only know one way to do this, and that is using the #btmon command. Run btmon in the background then scan for Bluetooth Low Energy devices:
The results displayed on the monitor should be similar to this:
> HCI Event: LE Meta Event (0x3e) plen 12 LE Advertising Report (0x02) Num reports: 1 Event type: Scan response - SCAN_RSP (0x04) Address type: Public (0x00) Address: AA:BB:CC:DD:EE:FF () Data length: 0 ***RSSI: -34 dBm (0xde)*** AA:BB:CC:DD:EE:FF
Note that when using btmon you do not have to connect to get the rssi of a BLE device.
hcitool rssi Seems to only be for regular bluetooth not bluetooth le, I get «Get connection info failed: No such file or directory» when I try even when connected ( for bluetooth le you connect by hcitool lecc [MAC] not the regular hcitool cc [MAC],
Tagged the question with bluetooth-lowenergy because I missed the le part 🙂 Have you tried #hcidump? I’ve read that you can use it to read rssi value of Low Energy devices but I have no devices with me to test that.
Edited the question to include the Bluetooth Low Energy part. I tried #hcidump and it didn’t work for me, but #btmon worked just fine.
What is the meaning of «plen 12″ in the first line of BLE scan » > HCI Event: LE Meta Event (0x3e) plen 12″ ?
No need to connect when using btmgmt
$ sudo btmgmt find Discovery started hci0 type 7 discovering on hci0 dev_found: 50:8C:FD:99:0A:EC type LE Random rssi -80 flags 0x0000 AD flags 0x06 eir_len 23 …
The relative signal strength indicator is rssi -80 , but the list is much longer containing more information about this and other devices.
To spy on your Bluetooth neighbourhood showing only unique MAC addresses with their strongest RSSI, run the following command:
$ sudo btmgmt find |grep rssi |sort -n |uniq -w 33 hci0 dev_found: 40:43:42:B3:71:11 type LE Random rssi -53 flags 0x0000 hci0 dev_found: 44:DA:5F:EA:C6:CF type LE Random rssi -78 flags 0x0000 hci0 dev_found: 7F:7D:08:6B:E0:37 type LE Random rssi -74 flags 0x0000 hci0 dev_found: A4:58:0F:21:A1:8C type BR/EDR rssi -79 flags 0x0000
Low Signal Strength of Bluetooth in Ubuntu 18.04
I have installed Ubuntu 18.04 LTS in my HP 15 laptop. Initially there were no wifi drivers, so I installed the rtlwifi_new after reading some threads on internet (worked like a charm) but there is a constant issue with my bluetooth. At first I connected my bluetooth earphones, which was working weird. There was sound quality that was pathetic, nothing like the great quality it gave when connected to my mobile. I checked around and installed Blueman and changed the audio profile to A2DP from HSP/HFP. This made the sound quality definitely better but the issue wasnt resolved totally. Now the sound was breaking when I moved away even a bit, and I mean like 2-3 centimeter as well. This issue was there earlier as well, with the HSP profile. And the max distance where there was proper sound like the one on my mobile, was maybe 15cm. I thought this is a problem with my earphones, so I charged them up completely and repeated again, but again the same issue. So I now connected my mobile to the laptop via bluetooth and it turns out, my mobile gets disconnected if the distance increases by more than, 20-30 cm. Where as bluetooth shud be fine with atleast 5-8 meter. I checked the blueman service and found that the signal strength is extremely weak even with the bluetooth device kept right on the laptop keypad. As you can see in the screenshot below. (Picture in link) Extremely Low Signal Strength of bluetooth I have searched a lot on the internet and could not find any relatable answer which solved my issue, maybe I am not very good at searching. But I would be really glad if someone could help me solve this so that I can get started with my lessons online comfortably using my headphones through bluetooth on laptop. Thanks a tonne in advance. EDIT 1: Just found out, if I turn off the WiFi, everything comes back to perfect. My bluetooth earphones play even at 8m far distance. But when i turn back the wifi on, the issue is back. EDIT 2: grep -i bt_coex_active /etc/modprobe.d/* This is what I get:
/etc/modprobe.d/iwlwifi-opt.conf:options iwlwifi bt_coex_active=N
*-network description: Ethernet interface product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:01:00.0 logical name: eno1 version: 15 serial: e4:e7:49:68:b4:3f size: 10Mbit/s capacity: 1Gbit/s width: 64 bits clock: 33MHz capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half firmware=rtl8168h-2_0.0.2 02/26/15 latency=0 link=no multicast=yes port=MII speed=10Mbit/s resources: irq:16 ioport:4000(size=256) memory:b1104000-b1104fff memory:b1100000-b1103fff *-network DISABLED description: Wireless interface product: Realtek Semiconductor Co., Ltd. vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:02:00.0 logical name: wlo1 version: 00 serial: 80:2b:f9:8e:64:1f width: 64 bits clock: 33MHz capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless configuration: broadcast=yes driver=rtl8723de driverversion=4.18.0-17-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11 resources: irq:128 ioport:3000(size=256) memory:b1000000-b100ffff *-network description: Ethernet interface physical id: 3 logical name: enp0s20f0u2 serial: ba:80:46:25:01:86 capabilities: ethernet physical configuration: broadcast=yes driver=rndis_host driverversion=22-Aug-2005 firmware=RNDIS device ip=192.168.42.146 link=yes multicast=yes
How to improve weak Bluetooth signal on a Linux laptop?
Is there any way in Linux to boost the Bluetooth signal strength from software without additional hardware?
Could this be a bug in my configuration? Could this be a bug in BlueZ? Linux kernel?
Also, after observing this for some time, it seems that there is another symptom. Bluetooth signal is fine when the audio is continuous. That is, if I’m far enough from the laptop, then as soon as a song or video end, the Bluetooth headphones are disconnected. Can Pulseaudio affect Bluetooth connections like that?
As a workaround, I wrote a Bash script which checks the connection and reconnects, if needed github.com/rybak/scripts/blob/master/bluetooth/keep-bt.sh
1 Answer 1
2023-03-31 update
After multiple unsuccessful attempts yesterday, I seem to have finally found a «one step» solution: cycle the laptop through sleep.
2023-03-30 update
It’s gotten much worse. Now none of the things that randomly fixed it before work.
I’ve found https://wiki.archlinux.org/title/bluetooth_headset, but none of the suggestions there are relevant. Section «Connecting works, but there are sound glitches all the time» sounds promising, but it is not what I am experiencing. The sound is perfect, but only when I put my head right next to the laptop.
2023-01-06 update
I still don’t understand what’s going on. The issue came back very shortly after New Year’s Eve update. I am very much cargo-culting my way through bluetoothctl , btmon , modprobe , turning Bluetooth on and off in BIOS, etc. to get the software side of the Bluetooth stack to cooperate, but at least after a week of suffering, I can use my headphones normally again. That is, I am trying random things without understanding which of the exact combination of them has helped.
For the record, the list this time is:
- Disable/enable Bluetooth from desktop environment controls (KDE).
- Disconnect/Connect headphones a couple of times.
- Turn headphones on and off.
- Cycle through noise cancelling settings of the headphones just to see if btmon «sees» any effect from different noise cancelling modes.
- Reboot to change BIOS settings – disable Bluetooth in BIOS.
- Reboot to DE, double check that Bluetooth is indeed disabled.
- Reboot to change BIOS settings – enable Bluetooth back in BIOS.
- Reboot, check audio – audio still cuts out.
- Reboot again and cycle headphones on/off again.
- Use bluetoothctl to disconnect and connect instead of DE controls.
- Use the modprobe command that helped me with some WiFi issues in the past:
sudo modprobe -r ath10k_pci sudo modprobe ath10k_pci
This is very disheartening, but at least it’s a relief from the hard-to-describe visceral discomfort from sound cutting out in the most annoying timing possible after, for example, just turning the head.
Side note
On my laptop btmon (for the record, found about it from a random bug report that turned up when typing «linux bluetooth Sony WH-1000MX3» into a search engine) is much better for the purposes of keeping track of Bluetooth signal than hcitool rssi I mentioned in the question above. Basically, when signal is good (from perceived audio quality point of view), I can see big packets (at least it seems to be a packet, I don’t actually know), about 50-55 lines long in the terminal, presumably being sent to the headphones. But when the signal cuts out, btmon output either stops dead, or the packets suddenly become much smaller, 20-25 lines long, as if the laptop is trying a lower bitrate to keep the signal going at all cost.
2022-12-31 update
And suddenly, just two days later, the bluetooth is working fine again! The only thing remotely connected to this is that the laptop went through a sleep-wake cycle.
2022-12-29 update
Yep, the problem is definitely in software. After another sudo apt update && sudo apt upgrade , with no other changes, the bluetooth signal is bad again. When laptop lid is closed, it’s barely 1.5 meters. When lid is open, it’s about 3 meters. And a reboot didn’t help.
2022-03-11 update
Today I remembered about this question. I don’t know what changed, but after some testing I don’t appear to have any signal strength issues anymore, both with open and closed laptop lid. Since May 2021, the laptop got an upgrade (unrelated to Bluetooth), during which its insides were cleaned – only minor dusting, nothing that should interfere with the signal. If it was a software issue, my current combination of Linux kernel and bluez package doesn’t have it:
$ uname -svrpi Linux 5.13.0-28-generic #31~20.04.1-Ubuntu SMP Wed Jan 19 14:08:10 UTC 2022 x86_64 x86_64 $ apt show bluez 2>/dev/null | head -2 Package: bluez Version: 5.53-0ubuntu3.5
Old answer
The solution to my problem is: open the laptop lid. I’m using external monitor, keyboard, and mouse. The laptop lid is almost always closed. However, when the lid is opened, there are no Bluetooth issues which were described in the question.
I guess that when I got Bluetooth to work:
- Software Issue: I know that this is a software issue, because recently after some combination of different invocations of bluetoothctl , rfkill , and sudo systemctl restart bluetooth.service the issue went away. Unfortunately, the issue came back when I rebooted the OS, and I haven’t been able to reproduce this workaround since.
the laptop was opened just by accident.