Files
rover-pi/bluetooth.md
T

2.5 KiB

Bluetooth on the Raspberry Pi Zero W (1 or 2)

The Zero W series has Bluetooth capability because of the Wifi chip on the board. Warning: This is a work in progress!!!

Reference

Getting Bluetooth working

  1. Login to the pi via a USB-serial port or monitor-keyboard-mouse. Configuring bluetooth can sometimes kick you off the wifi.
  2. Tell rfkill to unblock bluetooth. Perhaps this is a security thing?
sudo rfkill unblock bluetooth
  1. Restart the bluetooth service and check it's status
sudo systemctl restart bluetooth
sudo systemctl status bluetooth
  1. Figure out the address using hcitool
hcitool dev
  1. If you have a laptop set to be discoverable, you can check if bluetooth is working
hcitool scan
  1. You can then query that device for what services it offers
sdptool browse ADDRESS
  1. Now we want to make the Pi discoverable to our phone, tablet, or laptop
sudo hciconfig hci0 piscan
sudo hciconfig hci name RaspberryPi
  1. A Serial Port Profile(SPP) is needed for our serial port
sudo sdptool add SP
  1. For some reason, we have to put the bluetooth daemon in compatibility mode. (True as of 2016-2026 --foley). Find the line with ExecStart and put --compat at the end
sudo nano /lib/systemd/system/bluetooth.service
  1. Test the SPP is setup
sudo sdptool browse local
  1. Time to pair it with a device
sudo bluetoothctl
discoverable on
agent on
pairable on 
scan on

and once you have paired it

discoverable off
exit
  1. If this works, you can install the bluetooth.services and rfcomm.service files to automate some of this setup.
sudo cp bluetooth.service /etc/systemd/system/bluetooth.target.wants/.
sudo cp rfcomm.service /etc/systemd/system/.
sudo systemctl daemon-reload
sudo systemctl enable rfcomm
sudo reboot

Discussion

Apparently Bluez's sdptool is now depricated and they are telling people to use this new GATT via busctl or dbus-send. linuxvox article on depricated sdptool