mrdannael
Posts: 3
Joined: Wed Mar 09, 2016 11:14 am

Raspberry Pi 3 - Bluetooth problem with connecting devices

Wed Mar 09, 2016 11:58 am

Hi there,

i'm trying to connect to raspberry pi 3 bluetooth via smartphone with android and "bluetooth terminal" app.

There's no problem with pairing devices. It's working correctly.
But when it comes to connect via android app i'm getting "unable to connect device".

After running bluetoothctl I saw that connection is established for a while and then connection is lost.


mrdannael
Posts: 3
Joined: Wed Mar 09, 2016 11:14 am

Re: Raspberry Pi 3 - Bluetooth problem with connecting devic

Thu Mar 10, 2016 10:16 am

Works like a charm.

But now i'm trying to write simple python script to receive i send data:

Code: Select all

import serial

btSerial = serial.Serial("/dev/rfcomm0", baudrate=9600, timeout=0.5)

while True:
    rcv = btSerial.read(512)
    if rcv:
        btSerial.write("OK!")
        print(rcv)
Sending data from phone works, but receiving response "OK" not.

It seems that bluetooth terminal app on android has some kind of problem with receiving data, because when i send data using cutecom all buffer of data sended by script showed up on screen.

User avatar
Douglas6
Posts: 4598
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Raspberry Pi 3 - Bluetooth problem with connecting devic

Thu Mar 10, 2016 2:21 pm

Try an end-of-line after your sent data

Code: Select all

btSerial.write("OK!\n")

mrdannael
Posts: 3
Joined: Wed Mar 09, 2016 11:14 am

Re: Raspberry Pi 3 - Bluetooth problem with connecting devic

Fri Mar 11, 2016 10:20 am

It's even possible that when ie. GPS module is connected to RPi UART then bluetooth on rpi won't work?

At the moment I'm facing fact that after booting up rpi3 sometimes I can't even see bluetooth device onboard with hcitool dev or bluetoothctl.

So I'm disconnecting GPS, reboot rpi, and sometimes i can see device sometimes not. Then i'm rebooting again until device is found. But then blueman-applet won't show on task bar so im rebooting rpi until everything is ok.

But it's very uncomfortable.

paolojo
Posts: 111
Joined: Mon Oct 26, 2015 3:32 pm

Re: Raspberry Pi 3 - Bluetooth problem with connecting devic

Thu Apr 14, 2016 9:04 pm

Good evening!
I've ran the script above

Code: Select all

import serial

btSerial = serial.Serial("/dev/rfcomm0", baudrate=9600, timeout=0.5)

while True:
    rcv = btSerial.read(512)
    if rcv:
        btSerial.write("OK!")
        print(rcv)
but I've received the following messages:

Code: Select all

Traceback (most recent call last):
  File "blue.py", line 3, in <module>
    btSerial = serial.Serial("/dev/rfcomm0", baudrate=9600, timeout=0.5)
  File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 261,in __init__
    self.open()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 278 in open
    raise SerialException("could not open port %s: %s" % (self._port, msg)
serial.serialutil.SerialException: could not open port /dev/rfcomm0: [Erro 2] No such file or directory: '/dev/rfcomm0'
Have you an iea to solve the problem?
Thank you very much ;)

User avatar
Douglas6
Posts: 4598
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Raspberry Pi 3 - Bluetooth problem with connecting devic

Thu Apr 14, 2016 9:32 pm

No such file or directory: '/dev/rfcomm0'
Have you run the rfcomm watch command and connected to the Pi? There won't be a /dev/rfcomm0 device until you do.

paolojo
Posts: 111
Joined: Mon Oct 26, 2015 3:32 pm

Re: Raspberry Pi 3 - Bluetooth problem with connecting devic

Sun Apr 17, 2016 10:18 pm

Thank you very much!
Now it works!!! ;)

tokelly
Posts: 1
Joined: Thu Feb 22, 2018 7:12 pm

Re: Raspberry Pi 3 - Bluetooth problem with connecting devices

Thu Feb 22, 2018 7:21 pm

Hi, I am trying to connect to my RPi3 from 'bluetooth terminal' on my android.

I followed all the steps above and I was unable to connect to the Pi using the 'sudo rfcomm watch hci0'

Through trial and error i found that clicking 'make discoverable' on the app allowed me to connect.

Regards,

T

User avatar
Douglas6
Posts: 4598
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Raspberry Pi 3 - Bluetooth problem with connecting devices

Fri Feb 23, 2018 1:06 am

Just trying to keep the Bluetooth information in this forum accurate.

The 'rfcomm watch' command does not establish a connection. It puts the Pi into a state that is ready to accept serial connection requests from another device, such as a phone.

Being 'discoverable' has little to do with making connections. It causes the device to advertise its presence, so that other devices may pair with it. Pairing and connecting are two separate processes. Classic Bluetooth devices must be paired before they can be connected. Once paired, being discoverable is irrelevant.

Return to “Troubleshooting”