Bluetooth connection to HC-05 paired but not connected

9,226

Solution 1

The suggestion from ubfan1 is complete and uses rfcomm to establish a connection with a bluetooth device. If it doesn't work you should try what follows:

I am using rfcomm and minicom to exchange data between a bluetooth device Hc-06 connected to an Arduino and Ubuntu.

Scan for bluetooth devices:

hcitool scan
Scanning ...
    20:15:12:08:62:95   HC-06

Bind using rfcomm

sudo rfcomm bind 0 20:15:12:08:62:95 1

NB: bind 0 refers to device number 0 (rfcomm0) and 1 is the channel. The red led should now stop blinking.

Then use minicom with sudo and save a configuration in which you specify the baudrate and the port. You can find more informations on this tutorial.

Hope it helps!

Solution 2

Here's my (working) example of using the rfcomm for hooking up a bluetooth gps -- a bit of a pain I must say! Hope this helps, I used it with viking and openstreetmaps.

#!/bin/bash
# Manually start a gps receiver outputting on bluetooth
# Then determine if the gps daemon is already running
xxx=`ps auxww |grep [g]psd`
if [ -n "$xxx" ]; then 
  set `echo $xxx`
  pidgpsd=$2
fi

# the /etc/bluetooth/rfcomm.conf must have the gps MAC
MYGPS=`grep "^[^#].*device.*;" /etc/bluetooth/rfcomm.conf |cut -f2 -d" "|cut -f1 -d";"`

#Determine if the rfcomm0 device has been created
if [ ! -e /dev/rfcomm0 ]; then
  # kill the old gpsd
  if [ -n "$pidgpsd" ]; then
    echo "Killing the old gpsd"
    # for icon invocation, use gksudo
    gksudo kill $pidgpsd
    unset pidgpsd
  fi
  sdptool add --channel=1 OPUSH
  #gksudo rfcomm bind /dev/rfcomm0 00:0A:3A:2C:BC:44
  gksudo rfcomm bind /dev/rfcomm0 $MYGPS
  sleep 5
fi

# Start the new gpsd if necessary
if [ ! -n "$pidgpsd" ]; then
  #sudo gpsd -n -N -D2 /dev/rfcomm0
  gksudo -- gpsd -n -D2 /dev/rfcomm0
  echo "gpsd started"
  sleep 5
fi

# Create a ttyUSB0 link for broken viking
if [ ! -e /dev/ttyUSB0 ]; then
  sudo ln -s /dev/rfcomm0 /dev/ttyUSB0
  # ensure viking (you) can read the device ????
  sudo chmod 666 /dev/rfcomm0
fi
Share:
9,226

Related videos on Youtube

martin_0004
Author by

martin_0004

Updated on September 18, 2022

Comments

  • martin_0004
    martin_0004 over 1 year

    I have an Arduino Uno connected to an HC-05 Bluetooth sender/receiver chip. I am trying to create a Bluetooth connection between my Acer laptop running under Ubuntu 14.04 LTS and the HC-05 chip.

    Ubuntu detects the HC-05 chip, as can be seen below.

    phodor@ubuntu: hcitool scan
    Scanning ...
        11:22:33:44:55:66   HC-05
    

    I am able to create a pair between my laptop Bluetooth device and the HC-05 chip. However, I am unable to create a connection with that pair from the Ubuntu interface. The "Connection" button cannot be clicked on, as you can see on the figure below.

    I tried creating a connection using the terminal, but after that the terminal still did not detect any connection.

    phodor@ubuntu: sudo hcitool cc 11:22:33:44:55:66
    [sudo] password for phodor: 
    phodor@ubuntu: hcitool con
    Connections:
    

    I also checked that my computer Bluetooth device was working.

    phodor@ubuntu: hcitool dev
    Devices:
        hci0    AA:BB:CC:DD:EE:FF
    

    Any idea why the connection cannot be created ? Any idea on how to do it using the Ubuntu interface or the terminal ?

    enter image description here

    • ubfan1
      ubfan1 over 8 years
      Did you try a later Ubuntu release with bluez 5 (ver 5.36)? Does your device address show up in /var/lib/bluetooth/names, /var/lib/bluetooth/trusts, and /var/lib/bluetooth/linkkeys?
    • martin_0004
      martin_0004 over 8 years
      @ubfan1: The device address shows up in /var/lib/bluetooth/11:22:33:44:55:66/names and /var/lib/bluetooth/11:22:33:44:55:66/linkkeys. It does not appear in /var/lib/bluetooth/11:22:33:44:55:66/trusts. I did not try the bluez utility yet. I am investigating the rfcomm utilily.