0

I've been trying to connect my Raspberry Pi 4 to an Android phone via Bluetooth by following these tutorials first tutorial, needs translation, second tutorial, and last tutorial. Since I currently have a Samsung Galaxy S7, which doesn't have the physical option button, so I can't use Blue Term as all three tutorials have said. I've tried Bluetooth Terminal and Serial Bluetooth Terminal to connect to the Raspberry pi and for both apps, it all seems to fail to connect. When I connect my phone to the pi, it gives me a message saying

Device added successfully, but failed to connect

I'm also using a Raspberry pi 4, 4GB. Any suggestions would be greatly appreciated. Thanks in advance.

3
  • 2
    First, mixing several tutorials has a much smaller chance of success than following just one. Second, unless you describe the steps you took, there's no chance for us to point out a mistake you might have made. Check out this discussion. Commented Jul 13, 2020 at 7:16
  • And also please keep the posting to English, some of the URLs was NOT!
    – MatsK
    Commented Jul 13, 2020 at 8:07
  • @MatsK One of the URLs was not in English and I have specified that it needs translation. I also used Google translate for it since I'm not a native speaker. If it's not understandable, then move on, not sure why you have such a strong emotion towards it.
    – user122054
    Commented Jul 13, 2020 at 18:35

1 Answer 1

2

For Bluetooth serial connections I tend to use the RFComm functionality in the Blue Dot python library on the Raspberry Pi and the Serial Bluetooth Terminal app on my phone.

Blue Dot

Is on PyPI: https://pypi.org/project/bluedot/

The Blue Dot library has broader functionality, for this it is just the RFComm piece which is documented at:

https://bluedot.readthedocs.io/en/latest/btcommapi.html

There are some examples in the documentation but I normally use the code below as a test. This assumes you have already paired your phone and Raspberry Pi.

from bluedot.btcomm import BluetoothServer
from signal import pause

def connect_handler():
    print('Client connected...')

def disconnect_handler():
    print('Client disconnected...')

def data_received_handler(data):
    print(data)
    # reverse text and send back to client
    s.send(data.rstrip()[::-1])

s = BluetoothServer(data_received_handler,
        port=1,
        when_client_connects=connect_handler,
        when_client_disconnects=disconnect_handler)

print('Listening...')
pause()

Serial Bluetooth Terminal

I prefer to use this app and it seems to work reliably.

https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal&hl=en_GB

Your Answer

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