Skip to content

Bluetooth Devices

project-owner edited this page Jun 6, 2020 · 21 revisions

It's possible to connect Bluetooth devices to the Raspberry Pi starting from the models 3 and Zero W. There are many different Bluetooth devices on the market. The following portable Bluetooth speakers were tested with Peppy player:

bt

  1. RAVEtone 20W Wireless HD Stereo Speaker
  2. Bluetooth Speaker Pink Flower Print Ashley Mary

You can use any other Bluetooth device which you have in your disposal. The configuration procedure is the same for all types of Bluetooth devices.

Since Hogarth Edition it's possible to connect Bluetooth devices using just player's UI: https://github.com/project-owner/Peppy.doc/wiki/Network#connecting-bluetooth-device

The manual process is still valid and can be used if you will face any issue during automatic connection from UI.

This manual installation/configuration guide was inspired by the work which was done in this area by Klaus (Munich). His very detailed guide is available on German Raspberry Pi forum.

The configuration property bluetooth in the file config.txt should be set to True in order to activate the Bluetooth functionality in the player. The property was introduced in the Turner Edition.

Before starting Bluetooth configuration procedure bluealsa library should be installed on Raspberry Pi. The library allows to use Bluetooth devices as ALSA devices. This library will be included to the Peppy Player Disk Images starting from Rubens Edition. Therefore there is no need to install it if either the Rubens or later Edition Disk Image is in use. Also bluealsa library is available on Raspbian Desktop OS. Only Raspbian Lite OS versions need bluealsa installation.

Install bluealsa library using the following command:

sudo apt-get install bluealsa

Bluetooth device connection procedure includes the following steps:

  • Find a MAC Address of your Bluetooth device. This address serves as unique identifier for network devices.
  • Pair and connect your device manually using the MAC Address found in the previous step for pairing and connecting your Bluetooth device to Peppy player.
  • Configure Bluetooth speaker as ALSA device.
  • Configure automatic connection of the Bluetooth device to the Peppy player during startup.

Find a MAC Address

Start Bluetooth control utility:

sudo bluetoothctl

Start scanning for Bluetooth devices:

scan on

Switch your Bluetooth device on and wait until you see it appears in the list of discovered devices. Here is example of output for RAVEtone speaker:

[CHG] Controller B8:27:EB:E3:B5:16 Discovering: yes
...
[NEW] Device 30:22:00:00:2C:B7 RAVEtone BTa2

Write down the MAC address of your device. For example the address of RAVEtone device in the example above is 30:22:00:00:2C:B7 Every device has its own unique address.

Pair and connect

Start Bluetooth pairing process (please use your address here):

pair 30:22:00:00:2C:B7

Wait until you see the message:

Pairing successful

Start trust process (use your address):

trust 30:22:00:00:2C:B7

In the end of this process you should see the message:

Changing 30:22:00:00:2C:B7 trust succeeded

Connect to the Bluetooth device (use your address):

connect 30:22:00:00:2C:B7

The following message should be displayed when connection finished:

Connection successful

Configure Bluetooth speaker as ALSA device

Create file .asoundrc if it doesn't exist:

nano /home/pi/.asoundrc

with the following content:

pcm.my-bluealsa-device {
    type plug
    slave.pcm {
        type bluealsa
        device "30:22:00:00:2C:B7"
        profile "a2dp"
        delay -20000
    }
}

You need to specify MAC address of your Bluetooth device in device parameter.

Define this ALSA device as output device for Peppy media players in file /home/pi/Peppy/players.txt. Here is example for vlc player:

[vlc.linux]
server.start.command = --aout=alsa --alsa-audio-device=my-bluealsa-device --verbose=-1

Configure automatic connection

In order to connect Bluetooth device to Peppy player automatically during startup process the script should be created:

nano /home/pi/connect-bluetooth.sh

with the following content (use MAC address of your Bluetooth device):

#!/bin/bash
bluetoothctl connect 30:22:00:00:2C:B7
quit

Make script executable:

chmod +x /home/pi/connect-bluetooth.sh

Add the script to the file /etc/rc.local:

sudo nano /etc/rc.local

After the line where Peppy player starts add the following line:

sudo /home/pi/connect-bluetooth.sh

After rebooting and switching on your Bluetooth device it should be automatically connected to the Peppy player.

Configuration for Bluetooth and Equalizer.

If Bluetooth device and Equalizer are in use at the same time then the configuration file .asoundrc should look like this:

pcm.!default {
  type plug
  slave.pcm plugequal;
}
ctl.!default {
  type hw card 0
}
ctl.equal {
  type equal;
}
pcm.plugequal {
  type equal;
  slave.pcm "my-bluealsa-device";
}
pcm.equal {
  type plug;
  slave.pcm plugequal;
}
pcm.my-bluealsa-device {
    type plug
    slave.pcm {
        type bluealsa
        device "30:22:00:00:2C:B7"
        profile "a2dp"
        delay -20000
    }
}

<<Previous | Next>>

Clone this wiki locally