I want each of my Raspberry Pi headless servers to scan for Bluetooth Low Energy (BLE) iBeacons. I’ve included iBeacon advertising in my DiyHasMobile smartphone app. The goal is to track the location of my iPhone in my house.

Build Bluez From Source

I read a “learn” blog on Adafruit which recommends building bluez from source. This is standard build process but it will take some time. Create directory to contain source, etc.

mkdir bluetooth
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.48.tar.xz
tar xvf bluez-5.48.tar.xz
cd bluez-5.48

Ok now start the build process

sudo apt-get update
sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev 
sudo apt-get install -y libudev-dev libical-dev libreadline-dev

This is optional but I like to sync after major steps.

sudo sync

This will take a little time to complete ( 10 minutes maybe )

./configure
make
sudo sync
sudo make install

Add BLE Support

Modify the bluetooth.service to support BLE services. Use the –experimental option

systemctl status bluetooth
sudo systemctl enable bluetooth
sudo vi /lib/systemd/system/bluetooth.service

This is a single line edit.

ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental

Update the daemon and reload

sudo systemctl daemon-reload
sudo systemctl restart bluetooth
systemctl status bluetooth

If all good then reboot and plan your next steps like installing python support for bluez

sudo reboot