6

I am trying to connect a HC-05 Bluetooth Module (connected to Arduino Uno) to my Raspberry Pi 3 in the hopes of achieving bluetooth communication between the two to send data from the Uno to the Pi.

Trying to use Bluetoothctl to pair, connect and trust the HC-05 device seems to fail for me.

[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# scan on
[CHG] Device 98:D3:31:FB:6F:F1 LegacyPairing: yes
[CHG] Device 98:D3:31:FB:6F:F1 RSSI: -43

[bluetooth]# pair 98:D3:31:FB:6F:F1
Attempting to pair with 98:D3:31:FB:6F:F1
[CHG] Device 98:D3:31:FB:6F:F1 Connected: yes
Request PIN code
[agent] Enter PIN code: 1234
[CHG] Device 98:D3:31:FB:6F:F1 Paired: yes
Pairing successful
[CHG] Device 98:D3:31:FB:6F:F1 Connected: no

[bluetooth]# connect 98:D3:31:FB:6F:F1
Attempting to connect to 98:D3:31:FB:6F:F1
[CHG] Device 98:D3:31:FB:6F:F1 Connected: yes
Failed to connect: org.bluez.Error.NotAvailable
[CHG] Device 98:D3:31:FB:6F:F1 Connected: no

[bluetooth]# trust 98:D3:31:FB:6F:F1
[CHG] Device 98:D3:31:FB:6F:F1 Trusted: yes
Changing 98:D3:31:FB:6F:F1 trust succeeded

Here is the info prompt.

[bluetooth]# info 98:D3:31:FB:6F:F1
Device 98:D3:31:FB:6F:F1
        Name: HC-05
        Alias: HC-05
        Class: 0x001f00
        Paired: yes
        Trusted: yes
        Blocked: no
        Connected: no
        LegacyPairing: yes
        UUID: Serial Port               (00001101-0000-1000-8000-00805f9b34fb)

Specifically the error I am getting is "Failed to connect: org.bluez.Error.NotAvailable"

I am not sure how to get pass this error and I am unable to complete my project without confirming a linked bluetooth signal between the two microprocessors.

Thanks, Aditya

2 Answers 2

7

You do not need to connect with Bluetoothctl. With Bluetoothctl, use exactly most commands as you show; then after pair, leave this window but not close. Open new terminal and use

rfcomm bind rfcomm0 98:D3:31:FB:6F:F1

But note: there is still no connection at this stage. To make real connection, use something to connect to your new serial port, like

screen /dev/rfcomm0 9600,cs8,-parenb,-cstopb,-hupcl  #  use ^a, k to exit.

Try send some chars with keyboard. After 2-3 seconds, you find your HC-05 connected by its LED. And look at your first window where Bluetoothctl runs. It will show that your HC-05 is connected. Thanks.

1
  • 2
    Thank you, this is exactly what I needed! Note for others, you can quickly check if you are getting data (assuming your bt device is just always streaming) with cat: cat /dev/rfcomm0 . If you see data there you should be able to communicate with the device using a library like pyserial.
    – jminardi
    Commented Oct 7, 2020 at 23:42
3

Try to install the blueman pack using sudo apt-get install blueman, or, if you have it installed, try

sudo apt remove blueman
sudo apt update
sudo apt upgrade
sudo apt-get install blueman

After one of this processes, run blueman or go to the Menu > Preferences > Bluetooth Mananger, then, search HC-05, add it to the Trust List, insert the password (normally 1234 or 0000) and connect it by clicking Configure.

If the problem persists, the problem is with the HC-05 module, try to connect it to an Android, if it doesn't connect, you will need to buy a new one.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.