I am trying to pair my HC-05 arduino bluetooth module with my Ubuntu machine for the past couple of hours but with no success.
I ran the following commands:
sdptool add --channel=1 SP
hcitool scan
sudo rfcomm bind rfcomm0 <MAC address of the HCO5 module>
But then if I try to connect issuing the following command:
sudo rfcomm connect 0
I get the error:
Can't connect RFCOMM socket: Connection refused
I have also edited the /etc/bluetooth/rfcomm.conf
file to this:
#
# RFCOMM configuration file.
#
rfcomm0 {
# # Automatically bind the device at startup
bind yes;
#
# # Bluetooth address of the device
device 20:14:02:17:17:38;
#
# # RFCOMM channel for the connection
channel 1;
#
# # Description of the connection
comment "Arduino Bluetooth module";
}
But I always keep getting the Connection refused
error. I also tried pairing with the module from the bluetooth manager applet. The default pin is 1234
and I have successfully connected with my bluetooth module through my android phone. But here, i see the HC-05 module listed as Unknown
and therefore when I try to connect with the default pin, the bluetooth manager generates a random pin and asks me to enter that pin on the other device to complete the pairing request which I can not do obviously.
When I try rfcomm connect
I am not presented with a pairing request window where I can just punch in the pin like I did in my android phone.
I read the blogs and the bluetooth module can be connected to linux machines so I am sure I am missing something simple. Any help is appreciated.
Best Answer
I had the same problem as you described, where the Bluetooth applet would generate a random pin for me to enter on the HC-05 and then just say connection failed. This tutorial worked for me though:
Bluetooth Serial Communication with HC-05
it's for the raspberry pi, but works on my ubuntu instance just as well. it basically tells you to add the 1234 pin to
where xx:xx:xx:xx:xx:xx is the MAC address of your Bluetooth Dongle (not the HC-5). I think the
/var/lib/bluetooth/xx:xx:xx:xx:xx:xx
directory is created for you automatically when you plug in the dongle, so probably you only have one directory under/var/lib/bluetooth/
which is the right one.