8

Has anyone been able to successfully install Bluez 5.44 onto Raspbian? I'd like to use this on both a Raspi 3 and a Raspi Zero W.

I've followed numerous different guides but they all install Bluez versions earlier than 5.44. I'm not able to follow any of these guides and end up with a functioning Bluez 5.44 installation.

Anyone that has done this, please share your steps.

9

A bit late here, but I recently suffered the headache of following a variety of different guides, none of which worked for me. So here is another guide...that probably won't work for you ;)

I downloaded the most recent version from the official page: bluez.org/download. If that page is dead, use this one instead.

For example, at the time of writing it was 5.47, so I used (on my raspberry):

wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.47.tar.xz 

Then I extracted it and built it:

tar -xf bluez-5.47.tar.xz
cd bluez-5.47

Read the README! It lists the dependencies and the configure switches:

Install the dependencies first: (glib, dbus, libdbus, udev, etc.) Most of them are already installed and if not they should be easy to install, all provided by package manager. Once you've done that:

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var 

I also added --enable-experimental because I believe the GattCharacteristics object is part of the experimental features. Then do:

make
sudo make install

It takes maybe 10 minutes to compile. After installing, you should find bluetoothd in /usr/libexec/bluetooth. You should also see bluetoothd in /usr/lib/bluetooth.

Go to each of these directories and type

./bluetoothd --version

You'll note that the one in libexec is new and the one in lib is old.

BlueZ creates these d-bus objects and interface to expose the bluetooth devices to you in nice ways.

In order to make sure that d-bus is talking to you new BlueZ 5.47 and not your old BlueZ 5.23, you need to tell systemd to use the new bluetooth daemon:

    sudo vim /lib/systemd/system/bluetooth.service

Make sure the exec.start line points to your new daemon in /usr/libexec/bluetooth.

For me, that wasn't enough. No matter what, upon restart I always got bluetoothd 5.23... So I just created a symlink from the old one to the new.

First rename the old file:

sudo mv /usr/lib/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd-543.orig

Create the symlink:

ln -s /usr/libexec/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd
sudo systemctl daemon-reload

That should do it.

Now, I have to say this, even though it's not relevant to the question:

If you want to develop an application for your pi, read the blueZ docs folder. It introduces you to something called d-bus, which is really worth learning about, and allows you to develop your application in python, node.js, or c (and more). Watch this video on bluez dev.

There are a lot of red herrings out there: wrappers that attempt to give you "easy" functionality. Even resources that say there is a lack of documentation on how to develop bluetooth. However, as soon as you want to do anything beyond simply connecting to the device and viewing it's characteristics, you're going to realize the wrapper will fail you.

Do yourself a favor. Take a few hours to learn how BlueZ works (the video I linked is solid gold). It uses something called d-bus. Read a bit about d-bus. If you like Python, look at the code in the test folder. Read the python dbus tutorial once or twice. It will pay off so nicely. I wasted a few days trying to find something easy, but this turned out to be the best way.

Good luck!

3

I installed it on my Raspberry Pi 3 with Raspbian GNU/Linux 8 (jessie) OS. It was a bit tricky but these steps worked for me. I installed it after reading your post.

sudo apt-get update
sudo apt-get upgrade -y 
sudo apt-get install bluez
sudo apt-get install blueman

After this I had no adapter found. The next thing I did was

sudo service bluetooth start
sudo service bluetooth status

Still no adapter. This is due to the firmware so I had to do this next

sudo apt-get dist-upgrade -y 
sudo apt-get install pi-bluetooth 
sudo apt-get install bluez bluez-firmware

Finally type:

sudo usermod -G bluetooth -a pi

Then check to see if it worked by typing:

cat /etc/group | grep bluetooth

If it worked you should see this in your terminal

$ cat /etc/group | grep bluetooth
bluetooth:x:113:pi

Last command

sudo reboot

Hope this works for you.

Thanks to this site for help https://www.pi-supply.com/make/fix-raspberry-pi-3-bluetooth-issues/

1

@Hunter Akins ' answer saved me from so much frustration when he said (paraphrased): seriously, get to know BlueZ. Get to know D-BUS. Get to know the bluetoothctl, systemctl, and bluetoothd commands.

The problem is, since Sept 2016’s release of Bluez5.42, many packages that online guides use were deprecated (https://wiki.archlinux.org/index.php/Bluetooth#Troubleshooting). Oh, and the Bluez package is severely lacking in official documentation.

Here are the commands I used to get Bluetooth running on the Raspberry Pi Zero W, from a fresh install:

$#Fresh install the latest version of Raspbian thru the latest version of NOOBS
$#Instructions for fresh install of at https://www.raspberrypi.org/help/noobs-setup/2/
$sudo apt-get update
$sudo apt-get upgrade #ensures you have latest linux kernel
$sudo init 6 #more robust than sudo reboot
$sudo apt-get -s install bluez #-s simulates the install, showing you
$#that the apt-get version is too old
$sudo apt-get --purge remove bluez #removes the bluez on your machine

Ripped from the above answer and comments:

$sudo apt-get -s install bluez #-s simulates the install, showing you
$#that an outdated version of bluez is on your machine
$sudo apt-get --purge remove bluez
$cd ~
$wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.49.tar.xz # find the latest bluez kernel at
$#http://www.kernel.org/pub/linux/bluetooth and install that, changing the version number of upcoming steps 
$tar xvf bluez-5.49.tar.xz
$sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
$cd bluez-5.49
$./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var
$make
$sudo make install
$cd ~
$cd /usr/libexec/bluetooth
$./bluetoothd --version
$cd ~
$cd usr/lib/bluetooth
$./bluetoothd --version #identify what the newer version is. 
#Mine was in libexec. If yours is not, reverse the paths in the following steps
$cd ~
$sudo nano /lib/systemd/system/bluetooth.service
#Go to the Exec Start line. Point it to /usr/libexec/bluetooth/bluetoothd
$sudo mv /usr/lib/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd-543.orig
$sudo ln -s /usr/libexec/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd 
$sudo systemctl daemon-reload 

Extra bug I found:

$sudo apt-get install -y bluez-obexd 
$# see https://forums.fedoraforum.org/showthread.php?315160-Cannot-get-bluetooth-devices-to-work
$sudo init 6 #more robust sudo reboot

I assume you want to use the bluez package you just installed. I use the following steps to connect to a BLE device right after a system reboot (given too long after a reboot, it fails). I have not experimented enough to figure out a consistent connection. The lines prefaced with "pi@raspberrypi:~ $ " and "[bluetooth]#" were my input; the rest were responses.

pi@raspberrypi:~ $ bluetoothctl
Agent registered
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:DD:65:21 Discovering: yes      (The raspberry pi, I believe)
[CHG] Device 34:15:13:87:98:37 RSSI: -45     (device I want)
[bluetooth]# trust 34:15:13:87:98:37
Changing 34:15:13:87:98:37 trust succeeded
[bluetooth]# connect 34:15:13:87:98:37
Attempting to connect to 34:15:13:87:98:37    (this will take a few seconds)
[CHG] Device 34:15:13:87:98:37 Connected: yes
Connection successful
...(Specifications of your device)...
[CHG] Device 34:15:13:87:98:37 ServicesResolved: yes

I am connecting to a BLE device. The pair command will not work, as it is intended for Bluetooth Classic:

[bluetooth]# pair 34:15:13:87:98:37
Attempting to pair with 34:15:13:87:98:37
[CHG] Device 34:15:13:87:98:37 Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device 34:15:13:87:98:37 Connected: no

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.