Set up Bluetooth on Raspberry Pi

I have a Raspberry Pi and a USB Bluetooth dongle.

Adding Bluetooth feature to the Raspberry Pi is a really easy way of communicating with Raspberry Pi. We can use Bluetooth technology to connect keyboard and mouse, and allowing connection from phone and computer.

First thing first, simply plugs the Bluetooth dongle into a spare USB port.

Run lsusb to list all USB devices.

$ sudo lsusb
Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The Raspbian Jessie has pi-bluetooth pre-loaded and working ‘out of the box’.
Run sudo service bluetooth status, and it should show ‘active (running)‘;

$ sudo service bluetooth status
bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Active: active (running) since Sun 2016-12-11 11:59:45; 27min ago
Docs: man:bluetoothd(8)
Main PID: 702 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
??702 /usr/lib/bluetooth/bluetoothd

Use sudo hcitool dev to list the Bluetooth address

Devices:
hci0 00:11:B1:0A:62:72

Use sudo hcitool scan to scan for surrounding Bluetooth devices. Refer to sudo hcitool –help for more help.

Alternatively, use sudo bluetoothctl to manages Bluetooth devices.

[bluetooth]# help
Available commands:
list List available controllers
show [ctrl] Controller information
select Select default controller
devices List available devices
paired-devices List paired devices
power Set controller power
pairable
Set controller pairable mode
discoverable
Set controller discoverable mode
agent
Enable/disable agent with given capability
default-agent Set agent as the default one
scan
Scan for devices
info Device information
pair
Pair with device
trust
Trust device
untrust
Untrust device
block
Block device
unblock
Unblock device
remove
Remove device
connect
Connect device
disconnect
Disconnect device
version Display version
quit Quit program

Posted in Linux Tagged with:

Leave a Reply