Linux

If you have a graphical Bluetooth manager, you can use that to pair your laptop to the Bluetoothmodule and skip most of these steps. You’ll probably still have to this step though.

Power up

First, your laptop’s Bluetooth transceiver may be OFF. Check its status with hciconfig and turn itON if necessary:

  1. $ hciconfig
  2. hci0: Type: Primary Bus: USB
  3. BD Address: 68:17:29:XX:XX:XX ACL MTU: 310:10 SCO MTU: 64:8
  4. DOWN <--
  5. RX bytes:580 acl:0 sco:0 events:31 errors:0
  6. TX bytes:368 acl:0 sco:0 commands:30 errors:0
  7. $ sudo hciconfig hci0 up
  8. $ hciconfig
  9. hci0: Type: Primary Bus: USB
  10. BD Address: 68:17:29:XX:XX:XX ACL MTU: 310:10 SCO MTU: 64:8
  11. UP RUNNING <--
  12. RX bytes:1190 acl:0 sco:0 events:67 errors:0
  13. TX bytes:1072 acl:0 sco:0 commands:66 errors:0

Then you need to launch the BlueZ (Bluetooth) daemon:

  • On systemd based Linux distributions, use:
  1. $ sudo systemctl start bluetooth
  • On Ubuntu (or upstart based Linux distributions), use:
  1. $ sudo /etc/init.d/bluetooth start

You may also need to unblock your Bluetooth, depending on what rfkill list says:

  1. $ rkfill list
  2. 9: hci0: Bluetooth
  3. Soft blocked: yes # <--
  4. Hard blocked: no
  5. $ sudo rfkill unblock bluetooth
  6. $ rkfill list
  7. 9: hci0: Bluetooth
  8. Soft blocked: no # <--
  9. Hard blocked: no

Scan

  1. $ hcitool scan
  2. Scanning ...
  3. 20:16:05:XX:XX:XX Ferris
  4. $ # ^^^^^^

Pair

  1. $ bluetoothctl
  2. [bluetooth]# scan on
  3. [bluetooth]# agent on
  4. [bluetooth]# pair 20:16:05:XX:XX:XX
  5. Attempting to pair with 20:16:05:XX:XX:XX
  6. [CHG] Device 20:16:05:XX:XX:XX Connected: yes
  7. Request PIN code
  8. [agent] Enter PIN code: 1234

rfcomm device

We’ll create a device file for our Bluetooth module in /dev. Then we’ll be able to use it justlike we used /dev/ttyUSB0.

  1. $ sudo rfcomm bind 0 20:16:05:XX:XX:XX

Because we used 0 as an argument to bind, /dev/rfcomm0 will be the device file assigned to ourBluetooth module.

You can release (destroy) the device file at any time with the following command:

  1. $ # Don't actually run this command right now!
  2. $ sudo rfcomm release 0