Wednesday, 10 February 2016

Bluetooth Dongle


Bluetooth Dongle for pi


Introduction
Bluetooth is a useful tool for getting devices communicating wirelessly. If you want your Raspberry Pi interacting with anything, from a printer, to a mobile phone, to setting up media streaming, bluetooth is the way to go! The nano dongle available from ModMyPi is the perfect low cost solution, and this guide will show you how to install it.
This guide is completed on Raspian, so the first step is to make sure you have the latest Raspbian Operating System (OS) installed on your Raspberry Pi. You can download the latest version here: http://www.raspberrypi.org/downloads
Step 1. Update and Install
A.
There's a few updates we need to run to make sure that our Raspberry Pi's software packages are all spiffy before we can proceed to installing the software we need for the bluetooth dongle. Skip this step if you're happy that your Pi's packages are already OK! Make sure you have a decent internet connection on your Pi before proceeding! 
We'll need to make sure we've got the latest firmware drivers by running the following commands:
sudo apt-get update
(This updates the list of available packages and their versions, but it does not install or upgrade any packages.)
sudo apt-get upgrade
(This actually installs newer versions of the packages you have. After updating the lists, the package manager knows about available updates for the software you have installed.)
sudo apt-get autoremove
(This will then remove all of the reduntant packages after the latest upgrade)
B.
We're now ready to install the software we need to interact with the bluetooth dongle!
sudo apt-get install bluetooth bluez blueman
Easy :)
I usually turn off my Pi before proceeding with any hardware changes. So switch your Pi off, plug the nano dongle in, and switch the Pi back on.
Step 2. Plug and Play Command Line Access
This part is for people who feel like having a play from the command line, so ignore it if you're happy with access via the GUI - which to be honest will allow for the majority of connections!
A.
You can run a quick check on the command line to see if the bluetooth device has been successfully registered:
lsusb
(This will list the currently connected USB devices)
This should yield the following connected device:
Bus 001 Device 005: 1D 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HC1 mode)
B.
You can also check to see whether the bluetooth is live by running the following command:
/etc/init.d/bluetooth status
(This command will give you basic functionality, by replacing 'status' with the following - 'start', 'stop', 'restart', 'force-reload')
Running 'status' should yield the following status message:
[ ok ] bluetooth is running
C.
Next we need to scan for devices:
hcitool scan
This will show any devices in range of the dongle, for example my mobile phone.
68:69:7C:31:9A:75 JAKE-IPHONE
D.
If you want, you can then ping your devices and make sure they're communicating OK! Please note the l2ping command this is the letter L2ping NOT 12ping (twelveping) - I went around in circles with this one for a while :D
sudo l2ping -c 1 68:69:7C:31:9A:75
Make sure you put in your MAC address - don't just copy the one above :) This pings the device via bluetooth and will yield the following if successful:
Ping 68:69:7C:31:9A:75 from 00:1B:10:00:ZA:EC (data size 44) . . .
44 bytes from 
68:69:7C:31:9A:75 id 0 time 26.88ms
1 sent, 1 recieved, 0% loss
That's probably enough playing for now on the command line, so we'll pick this up via the GUI.
Step 3. GUI Access
A.
Boot to the GUI
startx
Then all you need to navigate to 'start >> preferences >> bluetooth manager' which will bring up the bluetooth device manager.

First we need to ensure that our Raspberry Pi is discoverable. So, hit Adapter >> Preferences:

Then make sure that your Pi is set to "Always visible". You can also change the name of your Pi device is you wish. Once finished, just click close.

You can then search for nearby devices using the "Search" button. Make sure that your devices are on and discoverable!

Select the device you want to Pair to, and click the little key item to begin the pairing process.

If you're using a phone to pair to, a message will appear on the phone asking you to pair - DO NOT PRESS OK/CONFIRM ON THE DEVICE YET!
First, check in the top right corner of your Pi's desktop for a notification message like so:

Due to a little grahical anomoly in the latest iteration of Jessie (Jan '16) the confirm/deny message is very easy to miss. To pair the device, you need to hit confirm on this message. Then go back to your device, and click confirm/pair.
If you miss this message, you can bring it up again using the notification email tab.
Your devices should then be paired!
You can send and receive files using the send file button.

That's it! From here on you can search for and pair with devices, send files, and generally access bits and pieces via bluetooth!

No comments:

Post a Comment