For a recent project I try to make a python program that let me connect with the HC06 module. For that I use pybluez. But this wont work at all, so I tried to pair through terminal using bluetoothctl.

When scanning I discover the device:

[NEW] Device 98:D3:31:FD:9A:27 OKEY DOKEY MARIO

but when connecting:

[bluetooth]# connect 98:D3:31:FD:9A:27

Attempting to connect to 98:D3:31:FD:9A:27

Failed to connect: org.bluez.Error.Failed

[bluetooth]# connect OKEY DOKEY MARIO

Device OKEY DOKEY MARIO not available

How can I solve this?

1 Answer 1


What I did above works fine. I just needed an external USB bluetooth dongle. So the bluetooth module on my pc was the problem. Now I can connect and send messages. I used this small program to test the connection, send and then print the time for sending and receiving the message. Code is written in python.

    import bluetooth
    import socket
    import time

    import timeit

    size = 1024
    bd_addr = "98:D3:31:FD:9A:27"
    port = 1

    sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
    sock.connect((bd_addr, port))
    start = timeit.default_timer()
    sock.send("hello!! \r\n")

    while 1:  
       data = sock.recv(size)
       if data:
          end = timeit.default_timer()


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .