nicokaiser / rpi-audio-receiver

Raspberry Pi Audio Receiver with Bluetooth A2DP, AirPlay 2, and Spotify Connect
MIT License
1.4k stars 148 forks source link

Bluetooth connection drops intermittently #173

Open georgar70 opened 4 months ago

georgar70 commented 4 months ago

I have installed Bluetooth software on two PIs, and it works. Unfortunately, the Bluetooth connection drops at irregular intervals (15 - 25 minutes). The distance between the sender and receiver does not change and is not very large. If I deactivate and reactivate Bluetooth on my sender (mobile phone), the connection is reestablished. Do you have any suggestions on what could be causing this? Where can I look?

georgar70 commented 4 months ago

Could it be that power management sometimes turns off the Bluetooth connection? Could the following suggestion (ChatGPT) be a solution:

Step-by-Step Guide to Disable Power Management

  1. Create or Modify the btusb.conf File

    • Create or edit the file /etc/modprobe.d/btusb.conf to disable power management for the Bluetooth adapter.
    sudo nano /etc/modprobe.d/btusb.conf
  2. Add the Following Line

    • Add the following line to the btusb.conf file:
    options btusb enable_autosuspend=0
  3. Save and Close the File

    • Save the changes and exit the editor. In nano, you can do this by pressing Ctrl+X, then Y, and then Enter.
  4. Reboot the Raspberry Pi

    • Reboot your Raspberry Pi for the changes to take effect.
    sudo reboot

Verifying the Changes

After the system reboots, you can verify that the power management settings have been applied correctly:

  1. Check Bluetooth Power Management Status

    • You can check the current power management status by inspecting the Bluetooth adapter details. Use the following command:
    sudo cat /sys/module/btusb/parameters/enable_autosuspend
    • It should return N if the autosuspend is disabled.

Additional Power Management Settings

If you are using Wi-Fi along with Bluetooth and suspect power management issues, you might also want to check the power management settings for the Wi-Fi adapter:

  1. Disable Wi-Fi Power Management

    • Open the configuration file for the wireless interface (typically wlan0).
    sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
  2. Set Wi-Fi Power Management to Off

    • Ensure the file contains the following setting:
    [connection]
    wifi.powersave = 2
  3. Save and Close the File

    • Save the changes and exit the editor.
  4. Restart Network Manager

    • Restart the Network Manager to apply the changes.
    sudo systemctl restart NetworkManager

By following these steps, you should be able to manage and disable power management for the Bluetooth adapter on your Raspberry Pi, which may help resolve the intermittent connection drops.


Does this help or is it not applicable because I am using a USB Bluetooth adapter?

USB Bluetooth Adapter Considerations

The solution can still be helpful if you are using a USB Bluetooth adapter, as the described settings can also be applied to USB Bluetooth adapters. Here are the steps, slightly adjusted for USB Bluetooth adapters:

Step-by-Step Guide to Disable Power Management for USB Bluetooth Adapter

  1. Create or Modify the btusb.conf File

    • Create or edit the file /etc/modprobe.d/btusb.conf to disable power management for the Bluetooth adapter.
    sudo nano /etc/modprobe.d/btusb.conf
  2. Add the Following Line

    • Add the following line to the btusb.conf file:
    options btusb enable_autosuspend=0
  3. Save and Close the File

    • Save the changes and exit the editor. In nano, you can do this by pressing Ctrl+X, then Y, and then Enter.
  4. Reboot the Raspberry Pi

    • Reboot your Raspberry Pi for the changes to take effect.
    sudo reboot

Verifying the Changes

After the system reboots, you can verify that the power management settings have been applied correctly:

  1. Check Bluetooth Power Management Status

    • You can check the current power management status by inspecting the Bluetooth adapter details. Use the following command:
    sudo cat /sys/module/btusb/parameters/enable_autosuspend
    • It should return N if the autosuspend is disabled.

Additional Power Management Settings

If you are using Wi-Fi along with Bluetooth and suspect power management issues, you might also want to check the power management settings for the Wi-Fi adapter:

  1. Disable Wi-Fi Power Management

    • Open the configuration file for the wireless interface (typically wlan0).
    sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
  2. Set Wi-Fi Power Management to Off

    • Ensure the file contains the following setting:
    [connection]
    wifi.powersave = 2
  3. Save and Close the File

    • Save the changes and exit the editor.
  4. Restart Network Manager

    • Restart the Network Manager to apply the changes.
    sudo systemctl restart NetworkManager

By following these steps, you should be able to manage and disable power management for the Bluetooth adapter on your Raspberry Pi, which may help resolve the intermittent connection drops, even if you are using a USB Bluetooth adapter.