-1

Obsolete Instructions for Earlier Raspberry Pi Models (e.g. RPi3)

The information below is what I had originally posted as attempted solutions but failed to playback audio satisfactorily. In other words, they do not work on RPi4.

I followed the pulseaudio install instructions on the linked page below but it could not find the bluetooth controller and the power on command in bluetoothctl resulted in No default controller available error.

https://wiki.archlinux.org/index.php/Bluetooth_headset#Configuration_via_CLI

When I follow the instructions I found on the linked page below, it fails to install because of linux-raspberrypi4 conflict.

https://github.com/RoEdAl/alarm-bluetooth-raspberrypi

  • You might want to split this into a question and answer pair – Journeyman Geek Sep 25 '19 at 9:37
  • When I post a question and it's viewed 50+ times with no response, I continue to experiment until I find a solution. At that point, I have the answer to the question. So, I then have two options: Answer my own question or post the answer. Since SuperUser discourages answering my own question, I went with the solution to post. Somewhere there should be a reason to post solutions without a question when no one answers it. – Frank Gould Sep 25 '19 at 9:42
  • 1
    I don't get why you think we discourage you answering your own question. There's a checkbox, and as a mod - I speak for the site where I say "You need to split this up" – Journeyman Geek Sep 25 '19 at 9:47
  • The question I posted contained a lot of misinformation where I searched and found outdated answers. So I cleaned up my question and found that only a small portion was relevant to the solution. At that point, my answer would be more confusing than just posting the solution. I prefer to communicate clearly without misinformation and nebulous Q&A formats and rules: "If you have more than 15 reputation and already know the answer, click the checkbox that says 'Answer your own question' at the bottom of the Ask Question page." I don't have 15 "reputations." – Frank Gould Sep 25 '19 at 10:10
0

This is a solution I found to auto-connect bluetooth headsets to Raspberry Pi 4B running Arch Linux ARM 4.19.71. These instructions use some source code from Raspbian Buster to setup the RPi4B hardware to work with pulseaudio and bluetoothctl. There were no responses to my question here on SuperUser nor on Raspberry Pi Foundation forums. These files need to be installed (copied) to route the audio through a RPi4B UART serial channel to the headset.

One reason I am posting this is to get any recommendations on how I implemented this software solution. I figured if Buster worked and it is based on the new RPi4B hardware, then the same should work on Arch Linux, and some uart/serial files already exist on Arch.

One last point is that if there are issues with these instructions on a particular RPi4B unit, there have been reports of RPi4B hardware failure with bluetooth and Wi-Fi. I used these instructions below multiple times and hopefully corrected any mistakes. If you have tried these instructions and something fails to work, please leave a comment and I’ll attempt to respond.

Download btuart and hciuart.service files: https://gist.github.com/frankgould/db38ca5e40b3d2368f8d7765e346f8c5

All of these installation/configuration commands are entered in a terminal window.

NOTE: The instructions below can be copied from one raw file using the link at the bottom of this post in the References section. That way, you can copy more lines of commands without the descriptions included in this page. In these descriptions, I have attempted to describe what the next commands are accomplishing.

Any place with angle brackets, or “<” and “>”, are indications where your information should be typed or pasted without the brackets. For instance, /home/<your-folder> should be input as /home/archpi when using a default user name of archpi.

Install pulseaudio and bluetooth:

    sudo pacman -S pulseaudio-alsa pulseaudio-bluetooth bluez-utils libmm-glib modemmanager
    sudo systemctl start ModemManager
    sudo systemctl enable ModemManager
    sudo systemctl start bluetooth
    sudo systemctl enable bluetooth

Test case command below - Should be clean startup, if not, see if there are recommendations in the startup results of the command below or your boot journalctl -b.

    systemctl status ModemManager

Copy btuart script to /usr/bin folder and chmod 777 to execute:

    sudo cp <folder-containing-btuart-file>/btuart /usr/bin/.
    sudo chmod 777 /usr/bin/btuart

Copy hciuart.service to /etc/systemd/system folder to auto-start uart services at boot:

    sudo cp <folder-containing-hciuart.service-file>/hciuart.service /etc/systemd/system/.

Add permanent link for serial1to ttyAMA0 as udev rule for serial audio channel:

    sudo nano /etc/udev/rules.d/99_ttyAMA0.rules 
    KERNEL=="ttyAMA0", SYMLINK+="serial1"

Save the file above and reboot to setup the permanent link.

    reboot

Login as your user, then

    cd /home/<your-folder>
    git clone https://aur.archlinux.org/hciattach-rpi3.git
    cd hciattach-rpi3/
    makepkg -Asri

Note: You may need to install any new dependencies since this post was published. For instance, patch may not be installed. To fix that, run sudo pacman -S patch and try the makepkg command above again.

Test with command below and results should show help text indicating operational install.

    hciattach-rpi3

Create a copy of hciattach without -rpi3 to work with btuart script and startup bluetooth and hciuart services:

    sudo cp /usr/bin/hciattach-rpi3 /usr/bin/hciattach
    sudo systemctl start hciuart
    sudo systemctl enable hciuart

Scan for Bluetooth Headset and Connect

This following section is well documented on many sites and are consistent. In these instructions below, after starting the bluetoothctl app, each command needs to be entered, followed by the return/enter key.

After entering the scan on instruction, any bluetooth devices in your nearby area should appear as a MAC address (i.e. ##:##:##:##:##:## or example 01:23:45:67:89:AB) along with your headset name. You will need to type or copy/paste the MAC address following each pair, connect, and trust command.

If you have problems with the power on command, it’s most likely some step was missed above, my instructions are incorrect, or there is a possible hardware failure. Make sure your headset is turned on.

In the instructions below, the bluetoothctl app will differ based on your headset and the what app inserts between the square brackets, where your-headset-brand appears as the prompt. It’s best to try these instructions while running the bluetoothctl app.

    bluetoothctl
    [bluetooth]power on
    [bluetooth]scan on
    (Multiple bluetooth devices in your area should appear per line with its MAC address)
    [bluetooth]pair <your-headset-address-as: ##:##:##:##:##:##>
    [your-headset-brand]connect <##:##:##:##:##:##>
    [your-headset-brand]trust <##:##:##:##:##:##>

Enable the Auto-Connect Feature of Bluetooth

This is the final install phase that will automate the connect to your bluetooth headset. These instructions should enable your RPi4B to recognize when your bluetooth headset turns on and set it as the audio output device.

    sudo nano /etc/pulse/default.pa

ADD the two lines below somewhere near the top of lists:

    # Automatically switch to newly-connected devices
    load-module module-switch-on-connect

Save the file above. Uncomment and set AutoEnable=true in [Policy] section of the file:

    sudo nano /etc/bluetooth/main.conf

Save the file above and reboot to enable the auto-connect feature.

    reboot

Turn off your headset and wait for your RPi4B to boot windows desktop then turn the headset back on. It should automatically connect as indicated by beeps in the headset. These instructions were based on the headset model below and no income was generated by this reference. It is only meant to be a reference device that worked for testing the above instructions.

iJoy Rechargeable Wireless Bluetooth Over-Ear Foldable Headset

Once your headset connects, you should be able to play audio files through your favorite audio playback app, like vlc. If you have problems with audio, try running the pulseaudio app located in the main menu under Sounds & Video as PulseAudio Volume Control.

References and Sources

https://wiki.archlinux.org/index.php/Bluetooth_headset

https://wiki.archlinux.org/index.php/Bluetooth

Source code of instructions above as `raw script` at the bottom of page:
https://gist.github.com/frankgould/db38ca5e40b3d2368f8d7765e346f8c5#file-raw-script

Exton RaspArch Rpi4 Arch Linux ARM 4.19 Build 190809: http://raspex.exton.se/?p=1214
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.