How to get Bluetooth working on Raspberry Pi 3
New Pi Tricks
The latest Raspberry Pi (Raspberry Pi 3) now comes with its own built in Wi-Fi and Bluetooth 4.1/Low Energy (LE) support, thanks to the BCM43438 chip.
In order to use them we must ensure that our version of Raspbian (the Linux-based operating system the Raspberry Pi 3 uses) is up to date and use a little terminal magic. Ensuring that your Raspberry Pi 3 is connected to the internet via an Ethernet cable, open a new terminal and type the following:
$ sudo apt-get update
$ sudo apt-get dist-upgrade
This step may take some time depending on the amount of updates required and the speed of your internet connection. Once completed stay in the terminal, we shall now upgrade the software on our Raspberry Pi. In the terminal type:
$ sudo apt-get upgrade
After a few moments the system will be upgraded but we still have a few more lines of commands to enter. Our next line will install the Raspberry Pi Bluetooth software, so in the terminal type:
$ sudo apt-get install pi-bluetooth
With that installed let's now install a graphical tool that will help us to configure Bluetooth. In the terminal type:
$ sudo apt-get install bluetooth bluez blueman
With all of the software now installed, go ahead and reboot your Raspberry Pi 3, as we are in the terminal use:
$ sudo reboot
Once your Raspberry Pi has rebooted you will return to the desktop. Now in the top-right corner you should see the Bluetooth logo. If not then go to the main menu, in the top left of the screen, click on Preferences > Bluetooth Manager. The icon should now appear in the top right of the screen.
Get daily insight, inspiration and deals in your inbox
Sign up for breaking news, reviews, opinion, top tech deals, and more.
Pairing a mobile device to Raspberry Pi 3
To pair a mobile device to our Raspberry Pi 3, we first need to make the Raspberry Pi discoverable. To do this we right-click on the Bluetooth icon and select 'Make Discoverable'.
This will only give us 60 seconds to find the Raspberry Pi 3, so on your smartphone open the Bluetooth settings and search for the Raspberry Pi. Once found opt to 'pair' your device to the Raspberry Pi. This will trigger a new dialog to pop up on the Raspberry Pi. Click on 'Confirm' to activate the pairing and then confirm the action on your mobile device.
FIle transfer
We can now use this Bluetooth connection to send files from our Raspberry Pi 3 to a Bluetooth device and to do that we need to right-click on the Bluetooth icon and select 'Send files to device' and this will launch a new dialog box where you can choose the device that you wish to send the files to.
Once selected, you will then be asked to confirm the file that you wish to send. For our test we had a simple 836KB JPEG image that we wished to send. Select the file and then click 'OK' to start the process. This will trigger your mobile device to ask for permission to receive and store the file. Click to download the file and after a few seconds the file will be on your mobile device.
How to connect a Bluetooth Keyboard or Mouse to the Raspberry Pi 3
Using a Bluetooth keyboard and mouse with the Raspberry Pi 3 means that all four of our USB ports are free for storage devices, and enables us to use the Raspberry Pi behind a screen, eg in a media centre.
To connect a Bluetooth keyboard or mouse, right-click on the Bluetooth icon and select 'Set up New Device'. This will launch a set up assistant process. Click 'Next' to progress to the next screen.
On your keyboard or mouse, press the key combination, as given in the manual, to make your device discoverable. The set up assistant should detect the device and now you must select it from the list. You will now be prompted to create a passkey, this is a pin number that will confirm you are connecting to the correct device.
You can use any number that you wish for a keyboard, but a mouse generally has a predetermined code of 0000, 1111 or 1234. Refer to your manual for more information. Once the passkey is set click 'OK' to progress. You will be asked to enter the passkey on your keyboard to confirm the pairing.
Once paired you can now use your Bluetooth keyboard and mouse just like a typical wired setup. The Raspberry Pi will also remember the configuration each time it's booted with these devices present.
- Enjoyed this article? Expand your knowledge of Linux, get more from your code, and discover the latest open source developments inside Linux Format. Read our sampler today and take advantage of the offer inside.