loading

Introduction

This instructable is based on my experience installing Bluetooth in a notebook and Raspberry Pi.

Target Readers

This instructable will mostly benefit Linux users, especially Debian and its deriviatives like Raspberry Pi running Raspbian OS.

System Environment

A notebook PC with the following specification:

  • Intel® Core™2 Duo Processor
  • Debian 7.4
  • Bluetooth Radio Built-in

Raspberry Pi with the following specification:

  • Model B
  • Debian 7.6
  • Bluetooth Radio USB Adaptor
  • Mains-Powered USB Hub

Credits

The bluetooth protocol picture is copied from this website.

Step 1: Install Bluetooth Radio in the Linux System

On Raspberry Pi

Open terminal emulator

Type:

sudo tail -f /var/log/syslog<br>

Plugin Bluetooth Radio USB Adaptor into the USB hub connected to the Raspberry Pi.

The Linux system automatically detects and loads suitable kernel modules to interface with the Bluetooth Radio. It will output the following messages to /var/log./syslog in the terminal emulator window:

Jul 19 21:21:43 rpipro2 kernel: [348888.110797] usb 1-1.3.3: new full-speed USB device number 13 using dwc_otg
Jul 19 21:21:43 rpipro2 kernel: [348888.222799] usb 1-1.3.3: New USB device found, idVendor=0a12, idProduct=0001
Jul 19 21:21:43 rpipro2 kernel: [348888.222824] usb 1-1.3.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jul 19 21:21:43 rpipro2 kernel: [348888.297758] Bluetooth: Core ver 2.19
Jul 19 21:21:43 rpipro2 kernel: [348888.297884] NET: Registered protocol family 31
Jul 19 21:21:43 rpipro2 kernel: [348888.297896] Bluetooth: HCI device and connection manager initialized
Jul 19 21:21:43 rpipro2 kernel: [348888.297928] Bluetooth: HCI socket layer initialized
Jul 19 21:21:43 rpipro2 kernel: [348888.297945] Bluetooth: L2CAP socket layer initialized
Jul 19 21:21:43 rpipro2 kernel: [348888.297990] Bluetooth: SCO socket layer initialized
Jul 19 21:21:43 rpipro2 kernel: [348888.304784] usbcore: registered new interface driver btusb

Step 2: Check That the Bluetooth Radio Is Successfully Installed

Open a terminal emulator program like LXTerminal

List Bluetooth devices that the system has detected:

sudo lsusb -v | grep -i bluetooth

Output from Notebook:

Bus 007 Device 011: ID 044e:300d Alps Electric Co., Ltd Bluetooth Controller (ALPS/UGPZ6)

bDeviceProtocol 1 Bluetooth

idProduct 0x300d Bluetooth Controller (ALPS/UGPZ6)

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

Output from Raspberry Pi:

Bus 001 Device 006: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

bDeviceProtocol 1 Bluetooth

idProduct 0x0001 Bluetooth Dongle (HCI mode)

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

bInterfaceProtocol 1 Bluetooth

Step 3: Install Bluetooth Middleware

Although the Linux system has detected and loaded the kernel modules (device drivers) to interface with the Bluetooth Radio, the Linux system is still unable to speak Bluetooth because there are no Bluetooth applications. In order to speak Bluetooth, the Linux system requires the Bluetooth protocol stack and applications.

Open terminal emulator like LXTerminal

sudo apt-get update
sudo apt-get install bluez
sudo apt-cache show bluez

Output of PC

Package: bluez

Version: 4.99-2

Installed-Size: 2473

Maintainer: Debian Bluetooth Maintainers

Architecture: amd64

Replaces: bluez-audio (<= 3.36-3), bluez-input, bluez-network, bluez-serial, bluez-utils (<= 3.36-3), udev (<< 170-1)

Depends: libc6 (>= 2.9), libcap-ng0, libdbus-1-3 (>= 1.1.1), libglib2.0-0 (>= 2.28.0), libreadline6 (>= 6.0), libudev0 (>= 0.140), libusb-0.1-4 (>= 2:0.1.12), kmod, udev (>= 170-1), lsb-base, dbus, python-gi, python-dbus

Conflicts: bluez-audio (<= 3.36-3), bluez-utils (<= 3.36-3)

Breaks: udev (<< 170-1)

Description-en: Bluetooth tools and daemons

This package contains tools and system daemons for using Bluetooth devices.

.

BlueZ is the official Linux Bluetooth protocol stack. It is an Open Source

project distributed under GNU General Public License (GPL).

Output of Raspberry Pi

Package: bluez

Version: 4.99-2

Architecture: armhf

Maintainer: Debian Bluetooth Maintainers

Installed-Size: 2026

Depends: libc6 (>= 2.13-28), libcap-ng0, libdbus-1-3 (>= 1.1.1), libglib2.0-0 (>= 2.30.0), libreadline6 (>= 6.0), libudev0 (>= 0.140), libusb-0.1-4 (>= 2:0.1.12), kmod, udev (>= 170-1), lsb-base, dbus, python-gi, python-dbus

Conflicts: bluez-audio (<= 3.36-3), bluez-utils (<= 3.36-3)

Breaks: udev (<< 170-1)

Replaces: bluez-audio (<= 3.36-3), bluez-input, bluez-network, bluez-serial, bluez-utils (<= 3.36-3), udev (<< 170-1)

Multi-Arch: foreign

Homepage: http://www.bluez.org

Priority: optional

Section: admin

Filename: pool/main/b/bluez/bluez_4.99-2_armhf.deb

Size: 895456

SHA256: b96e78b7e18cfdf51f82e0bf9e67a08c627b21becbf19b6f79376841210e916c

SHA1: ebf58db06d1c0d82ce47ddd2d0d4fcfba82b2b1f

MD5sum: 414616015104fdf722f1bd14fdefa5f5

Description: Bluetooth tools and daemons

This package contains tools and system daemons for using Bluetooth devices.

.

BlueZ is the official Linux Bluetooth protocol stack. It is an Open Source

project distributed under GNU General Public License (GPL).

Step 4: Start Bluetooth Middleware Service

For Raspberry Pi running Raspbian based on Wheezy:

Open terminal emulator

sudo service bluetooth start
sudo service bluetooth status

Output of PC

[ ok ] bluetooth is running.

Output of Raspberry Pi

[ ok ] bluetooth is running.

If the above command did not work, try rebooting the RPi.

For Raspberry Pi running Raspbian based on Jessie:

Open terminal emulator

cd /etc/systemd/system/bluetooth.target.wants

Make backup

sudo cp bluetooth.service /home/$user/bluetooth.service.pristine

Change bluetooth.service setting:

sudo vi bluetooth.service

Refer to screenshot

sudo systemctl start bluetooth

Status

The notebook computer and Raspberry Pi is now a Bluetooth device

Step 5: Discover Name of Bluetooth Device Installed in the System

For Bluetooth device, Linux does not create a file in /dev directory. However, the bluetooth device is identified by some other means.

Use hciconfig software to find the identity of the bluetooth device.

Open terminal emulator

sudo hciconfig -a hci0

hci0: Type: BR/EDR Bus: USB
BD Address: 00:15:83:CE:77:03 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN RX bytes:3890 acl:0 sco:0 events:92 errors:0 TX bytes:1315 acl:0 sco:0 commands:81 errors:0 Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'rpipro2-0' Class: 0x420100 Service Classes: Networking, Telephony Device Class: Computer, Uncategorized HCI Version: 4.0 (0x6) Revision: 0x1d86 LMP Version: 4.0 (0x6) Subversion: 0x1d86 Manufacturer: Cambridge Silicon Radio (10)

The bluetooth device name is hci0.

UP RUNNING means it is ready to interface with other bluetooth device.

<p>i have a problem in recieving files in raspberry-pi</p>
<p>Had to do below to make it 'UP RUNNING' because mine was 'DOWN'</p><p>sudo hciconfig -a hci0 up</p>
<p>Nice work!</p>

About This Instructable

11,537views

23favorites

Bio: Systems Administrator and Software Programmer.
More by mirza irwan osman:Install Modem USB Device in Raspberry Pi Make the Volume Knob of Sound Blaster X-Fi Surround 5.1 Pro Sound Card Work in Raspberry Pi Create a Volume Control for USB Sound Card in Raspberry Pi 
Add instructable to: