In these notes "xx:xx:xx:xx:xx:xx" means the MAC address of the remote bluetooth device
Reset Bluetooth Adaptor
sudo hciconfig hci0 reset
Restart Bluetooth Service
sudo invoke-rc.d bluetooth restart
List Bluetooth Adaptors
hciconfig
Scan for Bluetooth devices
hcitool scan
To then connect to one of the found devices you can use this:
sudo bluez-simple-agent hci0 xx:xx:xx:xx:xx:xx
Make The Raspberry Pi Discoverable
sudo hciconfig hci0 piscan
You will now be able to search and find the RPi from other devices such as windows "Add A Device" (development tip – if you've previously connected you'll need to remove it from Windows Devices for it to be able to found it again by Add A Device)
To allow the connection to complete you need to also do the following step to allow a remote device to actually connect:
sudo bluetooth-agent 1234
1234 is the pairing code for it to use, but this will can be automatically overridden by a randomly selected code displayed on both devices
Discover Bluetooth Devices
hcitool scan
List Previously Paired Devices
bluez-test-device list
(This will appear to do nothing if there are no devices).
Remove Previously Paired Device
You will need to get the devices MAC address by using the List command
If you need to disconnect it first:
bluez-test-device disconnect xx:xx:xx:xx:xx:xx
Then
bluez-test-device remove xx:xx:xx:xx:xx:xx
Ping Device
sudo l2ping -c 1 xx:xx:xx:xx:xx:xx
7 years ago
How do you simply disable or shut off the bluetooth functionality in your Pi? Lets say you want to turn off your integrated bluetooth. What command shuts down the bluetooth software on the Pi?
7 years ago
sudo systemctl stop bluetooth
if you want to disable bluetooth from auto start at bootup:
sudo systemctl disable bluetooth
8 years ago
Not sure on the date of this, but I am not certain if this is correct for the newer versions of Raspbian – what I mean is that these commands look like they would be suitable for a Pi 2 with a Bluetooth USB chip, the format for the Built In bluetooth seems different. I haven’t had a good look hence the reason I am here, I hoped to fins a full list of commands to interact with bluetooth –
I have a bluetooth device(phone) that allows filesharing and full access, and I want to play around with the Pi, to pull audio files wirelessly to the Pi and maybe vice versa. I can get a connection and pair up with the device but from there I have very limited access from the terminal
The basic commands for the built in Pi 3 (latest Raspbian that allows bluetooth interaction) are:
>>> sudo bluetoothctl (enter bluetooth commandline)
>>> agent on
>>> scan on (display address and info of nearby devices)
>>> pair
From there I am completely limited – eg after pairing i can’t do anythin-else worthwhile from the terminal. other than the basic things regarding connection to the device and showing limited info. This dissapointed me a little bit, when I upgraded the Pi and had built in bluetooth I hoped to actually be able to use it with my other bluetooth devices and use it to share my media across devices wirelessly – even stream audio from another device…no such luck as yet!
8 years ago
Hi Ben, its possible this has become out of date with Raspbian / the Bluetooth implementation if they’ve gone and changed it – its a while since we’ve tried to do anything Bluetooth on the RPi. When we did we had all sorts of problems trying to get it to do even simple things and eventually gave up at the time due to project time constraints…
7 years ago
Hello friend i am facing the same problem .. after i pair my device with RPi i cant do anything more … did you find anything on how to proceed ? making more fun stuff like sending and receiving data from other connected device ? Thanks
4 years ago
Thanks! This helped a lot. On my rpi4 I found after entering bluetoothctl you can type help and get a list of all commands that’ll solve the problems/options the OP went over. Select default controller Set controller alias Set controller power Set controller pairable mode Set controller discoverable mode Enable/disable agent with given capability Enable/disable advertising with given type Set device alias Scan for devices Remove device Connect device Select submenu
Bluetooth 3.0 Keyboard]# help
Menu main:
Available commands:
——————-
advertise Advertise Options Submenu
scan Scan Options Submenu
gatt Generic Attribute Submenu
list List available controllers
show [ctrl] Controller information
select
devices List available devices
paired-devices List paired devices
system-alias
reset-alias Reset controller alias
power
pairable
discoverable
agent
default-agent Set agent as the default one
advertise
set-alias
scan
info [dev] Device information
pair [dev] Pair with device
trust [dev] Trust device
untrust [dev] Untrust device
block [dev] Block device
unblock [dev] Unblock device
remove
connect
disconnect [dev] Disconnect device
menu
version Display version
quit Quit program
exit Quit program
help Display help about this program
export Print evironment variables