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

 

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

  1. JavascriptMike Coder

    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?

    1. Knut Odman

      6 years ago

      sudo systemctl stop bluetooth
      if you want to disable bluetooth from auto start at bootup:
      sudo systemctl disable bluetooth

  2. ben

    7 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!

    1. Adam

      7 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…

    2. Twaha Kabika

      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

    3. SG

      3 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.
      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 Select default controller
      devices List available devices
      paired-devices List paired devices
      system-alias Set controller alias
      reset-alias Reset controller alias
      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
      advertise Enable/disable advertising with given type
      set-alias Set device alias
      scan Scan for devices
      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 Remove device
      connect
      Connect device
      disconnect [dev] Disconnect device
      menu Select submenu
      version Display version
      quit Quit program
      exit Quit program
      help Display help about this program
      export Print evironment variables

Comments

Your email address will not be published. Required fields are marked *