Raspberry Pi 3 – Connect Bluetooth
The Raspberry Pi 3 comes with WLAN and Bluetooth. The integrated Bluetooth module saves the purchase of an additional Bluetooth USB stick. In the following I explain the individual steps how to establish a Bluetooth connection on the console.
Difficulty level:
Setting up the Bluetooth connection
To use the integrated Bluetooth module of Raspberry Pi 3, either the latest Raspbian image is required or an upgrade should be performed first:
$ sudo apt-get update $ sudo apt-get dist-upgrade $ reboot
Pairing
In order to bind two devices together, they must first be made known to each other. For newly configured Bluetooth devices, the pairing button (e.g. for keyboard / mouse / etc.) must be pressed. This means that the device is ready to establish a connection and often signals this state with a flashing LED.
Pairing with other Bluetooth devices is done with the command bluetoothctl. After the start we enter the command mode:
$ sudo bluetoothctl
First, we activate a Bluetooth agent that takes care of the authorization of new devices. With the command scan on all Bluetooth devices within range can now be displayed:
[bluetooth]# agent on [bluetooth]# default-agent [bluetooth]# scan on
With the command pair, followed by the MAC address of the device, the connection can now be initiated. At the device to be connected we are now asked to enter the displayed PIN code:
[bluetooth]# pair xx:xx:xx:xx:xx:xx
Trust the device
After successful pairing, we should still mark the device as trustworthy. This means that the connection does not have to be made manually each time (e.g. after a restart). Then we can leave the Bluetooth tool:
[bluetooth]# trust xx:xx:xx:xx:xx:xx [bluetooth]# exit