Toshibass
Posts: 18
Joined: Fri Jan 03, 2014 3:10 pm

Re: Raspberry Pi 3 Bluetooth Setup

Sun Feb 26, 2017 2:36 pm

I appear you be having the same same problem I have a miflora bluetooth sensor i pair and trust the sensor but I get the following repeatedly, getting data from the sensor is a bit hit and miss but it does work.

[CHG] Device C4:7C:8D:61:9D:0C Connected: yes
[CHG] Device C4:7C:8D:61:9D:0C Connected: no
[CHG] Device C4:7C:8D:61:9D:0C Connected: yes
[CHG] Device C4:7C:8D:61:9D:0C Connected: no
[CHG] Device C4:7C:8D:61:9D:0C Connected: yes
[CHG] Device C4:7C:8D:61:9D:0C Connected: no

in the syslog I get :
Feb 26 13:26:20 raspberrypi3 bluetoothd[1578]: g_attrib_unregister: invalid id
Feb 26 13:26:33 raspberrypi3 bluetoothd[1578]: g_attrib_unregister: invalid id
Feb 26 13:26:47 raspberrypi3 bluetoothd[1578]: g_attrib_unregister: invalid id
Feb 26 13:27:01 raspberrypi3 bluetoothd[1578]: g_attrib_unregister: invalid id

Any one any idea whats wrong and how to fix ?

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

Re: Raspberry Pi 3 Bluetooth Setup

Sun Feb 26, 2017 2:55 pm

Probably not the same issue at all; in fact almost every post on this thread refers to a separate issue.

The Mi Flora sensor is a BLE device. Use gatttool to communicate.

WRustyLane
Posts: 5
Joined: Fri Feb 03, 2017 4:43 am

Re: Raspberry Pi 3 Bluetooth Setup

Sun Feb 26, 2017 11:55 pm

Well, since I posted this problem with bluetooth, I´ve since solved my problem. It seems that when I entered the code for the setup procedure, I didn´t push the enter key. After trying the setup procedure several times, I finally entered the 6 digit code and pressed ¨enter¨ key and the keyboard paired immediately. Problem solved. As a matter of fact, I´m typing this message on my newly installed blue tooth keyboard. It´s funny how you can simply overlook a simple step as the ¨enter¨ key.

Rusty

Toshibass
Posts: 18
Joined: Fri Jan 03, 2014 3:10 pm

Re: Raspberry Pi 3 Bluetooth Setup

Mon Feb 27, 2017 11:23 am

Since I posted I also resolved my problem .. incidentally I was using a python script which used gatttoll to get the data https://github.com/open-homeautomation/miflora , however that was not the problem .. my mistake was I paired the miflora device on the Raspberry pi desktop app (I think it may be called Blueman) when I disconnected this, the problem was resolved .. it appears that pairing on Blueman results in continually trying to get data from the miflora device like connect .. disconnect .. connect .. disconnect etc, were as the python script limits this process to say once every hour (programmable) connect .get data. disconnect.

User avatar
KevinA
Posts: 64
Joined: Tue Oct 27, 2015 3:50 pm
Location: Park Valley, Utah

Re: Raspberry Pi 3 Bluetooth Setup

Thu Mar 23, 2017 9:08 pm

Say you're running a non-gui how do you get a 'sticky' bluetooth setup for a keyboard? As it stands you need to have two keyboards to get the unit setup every time you boot or ssh to the system and set it up after each boot.

juliank
Posts: 2
Joined: Wed Apr 12, 2017 2:16 pm

Re: Raspberry Pi 3 Bluetooth Setup

Wed Apr 12, 2017 3:20 pm

Hi guys.

I've read the entire thread and did some things mentioned here, but so far no luck.

My new raspi 3B just arrived, I installed Raspbian and I'm trying to set up Bluetooth on it. The usual problem:

Code: Select all

$ hcitool scan
Device is not available: No such device
The device is up to date (newest rpi-update from github, also did apt-get update upgrade etc.):

Code: Select all

$ sudo rpi-update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Your firmware is already up to date
Overlay is not enabled:

Code: Select all

$ grep pi3-disable-bt /boot/*.txt
Rfkill reports:

Code: Select all

$ rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
dmesg reports:

Code: Select all

$ dmesg | grep -i blue
[   12.348119] Bluetooth: Core ver 2.22
[   12.348179] Bluetooth: HCI device and connection manager initialized
[   12.348348] Bluetooth: HCI socket layer initialized
[   12.348358] Bluetooth: L2CAP socket layer initialized
[   12.348399] Bluetooth: SCO socket layer initialized
[   12.366287] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   12.366296] Bluetooth: BNEP filters: protocol multicast
[   12.366311] Bluetooth: BNEP socket layer initialized
bluetoothd is running:

Code: Select all

$ ps aux | grep blue
root      1722  0.0  0.2   4812  2560 ?        S    14:06   0:00 /usr/sbin/bluetoothd
bluetoothctl doesn't see the controller:

Code: Select all

$ bluetoothctl
[bluetooth]# list
[bluetooth]#
Packages are installed (except blueman, but it shouldn't be needed at this stage and I don't want to depend on xorg anyway):

Code: Select all

$ dpkg -s pi-bluetooth bluez bluez-firmware|grep Version
Version: 0.1.3
Version: 5.23-2+rpi2
Version: 1.2-3+rpi1
btbcm module is loaded:

Code: Select all

$ lsmod | grep btbcm
btbcm                   7916  0
bluetooth             365511  6 bnep,btbcm
/sys/kernel/debug/bluetooth contains:

Code: Select all

$ sudo mount -t debugfs none /sys/kernel/debug
$ sudo ls -l /sys/kernel/debug/bluetooth
total 0
-r--r--r-- 1 root root 0 kwi 12 14:06 l2cap
-rw-r--r-- 1 root root 0 kwi 12 14:06 l2cap_le_default_mps
-rw-r--r-- 1 root root 0 kwi 12 14:06 l2cap_le_max_credits
-r--r--r-- 1 root root 0 kwi 12 14:06 sco
What else can I try?

Thanks.

juliank
Posts: 2
Joined: Wed Apr 12, 2017 2:16 pm

Re: Raspberry Pi 3 Bluetooth Setup

Wed Apr 12, 2017 8:30 pm

Problem solved.

The problem is that I passionately hate systemd with all my heart, so the first thing I did after installation was removing it and installing a normal init system (sysvinit).

It looks like pi-bluetooth package is broken and provides only /lib/systemd/system/hciuart.service, but doesn't provide normal init scripts in /etc/init.d (+ symlinks).

Code: Select all

$ dpkg -L pi-bluetooth
/.
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/hciuart.service
/usr
/usr/bin
/usr/bin/btuart
/usr/share
/usr/share/doc
/usr/share/doc/pi-bluetooth
/usr/share/doc/pi-bluetooth/changelog.gz
/usr/share/doc/pi-bluetooth/copyright
This will explain everything:

Code: Select all

$ btuart
bcm43xx_init
Flash firmware /lib/firmware/BCM43430A1.hcd
Set Controller UART speed to 921600 bit/s
Device setup complete
$ hcitool scan
Scanning ...
        00:12:xx:xx:xx:xx       Jornada 720
I added a call to btuart to /etc/rc.local (it should be a proper init file in init.d with a symlink in rc2.d, but calling it after bluetoothd starts works too) and it solved the problem.

antirasp
Posts: 2
Joined: Mon May 22, 2017 10:06 pm

Re: Raspberry Pi 3 Bluetooth Setup

Mon May 22, 2017 10:10 pm

I am trying to make bluetooth work between raspberry pi 3b and a smart phone and I get the same errors observed in this post. I try to understand how to solve the problem according to the last post titled "solved" but I can not understand the way. Thank you in advance for any help to solve this problem.

profhuster
Posts: 1
Joined: Wed Jun 07, 2017 2:15 am

Re: Raspberry Pi 3 Bluetooth Setup

Wed Jun 07, 2017 2:23 am

@phiv:

I had no luck with bluetoothctl until I found a post (lost the link) with this:

Code: Select all

$ sudo bluetoothctl
[bluetooth]#  power on
[bluetooth]#  agent on
[bluetooth]#  scan on
Discovery started
[CHG] Controller B8:27:EB:6C:FE:83 Discovering: yes
[NEW] Device E7:8E:FB:3B:2A:69 Charge 2
[bluetooth]#  connect 58:71:33:C0:18:19
Attempting to connect to 58:71:33:C0:18:19
[CHG] Device 58:71:33:C0:18:19 Connected: yes
Connection successful
Note that the default-agent, pair, and trust commands are not used.

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

Re: Raspberry Pi 3 Bluetooth Setup

Wed Jun 07, 2017 3:42 am

The 'power on' command is not needed, the hci0 device is powered on at boot in Raspbian. Since you are connecting to a BLE device, there's no need for pairing (therefore the 'agent on' is not needed either.)

When pairing with a classic Bluetooth device, you will need to start the agent, pair, and trust the remote device. 'Default-agent' has indeed been deprecated. Sudo is also not needed in recent versions of Raspbian.

MikePelton
Posts: 1
Joined: Wed Jun 07, 2017 4:29 pm

Re: Raspberry Pi 3 Bluetooth Setup

Wed Jun 07, 2017 4:39 pm

I was tearing hair out trying to get both a PI 3 B and a Zero W to play nicely with Bluetooth on Jessie, until I stumbled on http://raspberrypi.stackexchange.com/qu ... ith-tablet item which advocates setting a compatibility flag in /etc/systemd/system/dbus-org.bluez.service.

Yes, it is a CAPITAL C for the -C option, but unlike what's written in the comment (if you also want to be able to communicate serially) you should do "add sp", NOT "SP" as it's written.

After performing these steps, a different BT icon appeared in Pixel and everything worked as you'd hope.

Hope this helps someone else avoid wasting the hours it cost me!

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

Re: Raspberry Pi 3 Bluetooth Setup

Wed Jun 07, 2017 5:06 pm

Yes, that information has been repeatedly expressed on this forum. 'sudo sdptool add SP' (with caps) is perfectly acceptable.

The 'different BT icon' is not the result of either the compatibility flag nor adding the SPP. I suspect you have installed blueman in addition to the Bluetooth GUI panel included with Raspbian Pixel (not recommended).

Noleh
Posts: 1
Joined: Thu Aug 17, 2017 1:47 pm

Re: Raspberry Pi 3 Bluetooth Setup

Thu Aug 17, 2017 2:48 pm

Good Morning,
Please be patient with me because I am new to Raspberry Pi, Linux and forums. :?

I'm trying a serial connection via bluetooth between the Raspberry Pi 3 and the Arduino HC-5 bluetooth. So I wanted to know the differences between connecting a device via serial bluetooth on Raspberry and setting up the Pi for other devices such as bluetooth mouse and keyboard, which I saw in this topic.

Sorry for my English, I'm Brazilian and I do not know much English, so you can blame the Google translator.

Thank you in advance.

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

Re: Raspberry Pi 3 Bluetooth Setup

Thu Aug 17, 2017 4:25 pm

One major difference is that the Serial Port Profile is not included on the Pi by default. See this post for configuring the SPP: viewtopic.php?p=947185#p947185

strangealx
Posts: 4
Joined: Mon Aug 28, 2017 4:40 am

Re: Raspberry Pi 3 Bluetooth Setup

Mon Aug 28, 2017 4:50 am

Hi, guys.
I've installed raspbian stretch and have succesfully connected my phone, laptop with pi by bluetooth. Also i've translated sound from this devices to pi by using the

Code: Select all

bluealsa-aplay xx:xx:xx... &
And all is working fine, but i have to run aplay on every connect/disconnect. And here goes the thing. Is there any simple way to run aplay by default on connect of certain devices.

jason_a69
Posts: 5
Joined: Sat Sep 23, 2017 11:01 am

Re: Raspberry Pi 3 Bluetooth Setup

Sat Sep 23, 2017 11:03 am

strangealx wrote:
Mon Aug 28, 2017 4:50 am
Hi, guys.
I've installed raspbian stretch and have succesfully connected my phone, laptop with pi by bluetooth. Also i've translated sound from this devices to pi by using the

Code: Select all

bluealsa-aplay xx:xx:xx... &
And all is working fine, but i have to run aplay on every connect/disconnect. And here goes the thing. Is there any simple way to run aplay by default on connect of certain devices.
Thanks for this command, it's something that took me a while to find. How is your audio quality? Mine is stuttering all over the place from my phone to the Pi

jason_a69
Posts: 5
Joined: Sat Sep 23, 2017 11:01 am

Re: Raspberry Pi 3 Bluetooth Setup

Sun Sep 24, 2017 7:28 am

jason_a69 wrote:
Sat Sep 23, 2017 11:03 am
strangealx wrote:
Mon Aug 28, 2017 4:50 am
Hi, guys.
I've installed raspbian stretch and have succesfully connected my phone, laptop with pi by bluetooth. Also i've translated sound from this devices to pi by using the

Code: Select all

bluealsa-aplay xx:xx:xx... &
And all is working fine, but i have to run aplay on every connect/disconnect. And here goes the thing. Is there any simple way to run aplay by default on connect of certain devices.
Thanks for this command, it's something that took me a while to find. How is your audio quality? Mine is stuttering all over the place from my phone to the Pi
I did some more testing, it works fine if you are playing music from a PC to the Pi but it is unlistenable if you are using an Android phone, I am using an S8+.

The issue has been logged here
https://github.com/Arkq/bluez-alsa/issues/60

As far as I can see, it has not been resolved yet...

So it's back to pulseaudio and Jessie for me. I am using Stretch lite, I am not sure if the desktop version works or not.

strangealx
Posts: 4
Joined: Mon Aug 28, 2017 4:40 am

Re: Raspberry Pi 3 Bluetooth Setup

Tue Sep 26, 2017 4:25 am


but it is unlistenable if you are using an Android phone
I`m using desktop and it`s all fine with playing music from my android phone, no difference from pc - oxygen 4.1

jason_a69
Posts: 5
Joined: Sat Sep 23, 2017 11:01 am

Re: Raspberry Pi 3 Bluetooth Setup

Tue Sep 26, 2017 4:28 am

strangealx wrote:
Tue Sep 26, 2017 4:25 am

but it is unlistenable if you are using an Android phone
I`m using desktop and it`s all fine with playing music from my android phone, no difference from pc - oxygen 4.1
Just to clarify - what's your PI setup? Are you using a Bluetooth USB device or an onboard one?

strangealx
Posts: 4
Joined: Mon Aug 28, 2017 4:40 am

Re: Raspberry Pi 3 Bluetooth Setup

Tue Sep 26, 2017 5:49 am

jason_a69 wrote:
Tue Sep 26, 2017 4:28 am
strangealx wrote:
Tue Sep 26, 2017 4:25 am

but it is unlistenable if you are using an Android phone
I`m using desktop and it`s all fine with playing music from my android phone, no difference from pc - oxygen 4.1
Just to clarify - what's your PI setup? Are you using a Bluetooth USB device or an onboard one?
Pi 3 model B, onboard bluetooth, stretch desktop. No additional devices, except usb hard drive

jason_a69
Posts: 5
Joined: Sat Sep 23, 2017 11:01 am

Re: Raspberry Pi 3 Bluetooth Setup

Wed Sep 27, 2017 8:14 am

strangealx wrote:
Tue Sep 26, 2017 5:49 am
jason_a69 wrote:
Tue Sep 26, 2017 4:28 am
strangealx wrote:
Tue Sep 26, 2017 4:25 am

I`m using desktop and it`s all fine with playing music from my android phone, no difference from pc - oxygen 4.1
Just to clarify - what's your PI setup? Are you using a Bluetooth USB device or an onboard one?
Pi 3 model B, onboard bluetooth, stretch desktop. No additional devices, except usb hard drive
Ok thank you

I am using stretch-lite.

Phone to onboard pi 3 bluetooth -> audio stutters
Phone to usb bluetooth -> audio fine (you can disable onboard bluetooth with this line in config.txt)

Code: Select all

dtoverlay=pi3-disable-bt
Last edited by jason_a69 on Sat Mar 03, 2018 2:24 pm, edited 1 time in total.

strangealx
Posts: 4
Joined: Mon Aug 28, 2017 4:40 am

Re: Raspberry Pi 3 Bluetooth Setup

Mon Oct 09, 2017 3:09 am

There is a node.js wrapper for bluetoothctl - https://www.npmjs.com/package/bluetoothctl
So if you are using node.js on your pi, you can do some magic with it and run what you want on bluetooth device connect.

GAZ082
Posts: 14
Joined: Tue Jun 09, 2015 1:34 pm

Re: Raspberry Pi 3 Bluetooth Setup

Sat Dec 02, 2017 12:02 am

Hi guys. I'm having the

Code: Select all

[email protected]:~ $ sudo bluetoothctl
[bluetooth]# agent on bluetoothd...
Agent registered
[bluetooth]# scan on
[b]No default controller available[/b]
[bluetooth]# :(
error.

Code: Select all

[email protected]:~ $ sudo dmesg | grep Blue
[  108.571587] Bluetooth: Core ver 2.22
[  108.571669] Bluetooth: HCI device and connection manager initialized
[  108.571686] Bluetooth: HCI socket layer initialized
[  108.571696] Bluetooth: L2CAP socket layer initialized
[  108.571720] Bluetooth: SCO socket layer initialized
[  108.593426] Bluetooth: RFCOMM TTY layer initialized
[  108.593451] Bluetooth: RFCOMM socket layer initialized
[  108.593466] Bluetooth: RFCOMM ver 1.11
[  273.400628] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[  273.400645] Bluetooth: BNEP filters: protocol multicast
[  273.400678] Bluetooth: BNEP socket layer initialized

Code: Select all

[email protected]:~ $ sudo systemctl status bluetooth
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-12-01 20:49:39 -03; 7min ago
     Docs: man:bluetoothd(8)
 Main PID: 1672 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─1672 /usr/lib/bluetooth/bluetoothd

Dec 01 20:49:38 kraken systemd[1]: Starting Bluetooth service...
Dec 01 20:49:39 kraken bluetoothd[1672]: Bluetooth daemon 5.43
Dec 01 20:49:39 kraken systemd[1]: Started Bluetooth service.
Dec 01 20:49:39 kraken bluetoothd[1672]: Starting SDP server
Dec 01 20:49:39 kraken bluetoothd[1672]: Bluetooth management interface 1.14 initialized
What i DO notice is that even though i have it enabled, the bluetooth service must be manually started every time i reboot.

What can i do? Pi3 with latest raspbian.

Thanks!

jpnoobie
Posts: 1
Joined: Tue Dec 19, 2017 5:25 am

Re: Raspberry Pi 3 Bluetooth Setup

Tue Dec 19, 2017 7:05 am

I'm running a code on Arduino and using Bluefruit EZ-link to pass data from Arduino to Raspberry Pi3B. The Arduino code is working as well as its setup with the EZ Link as we've already got the whole thing running on Windows.

I've already successfully paired and bind serial port named /dev/rfcomm0. Now when I run a simple read code:

import serial
ser = serial.Serial('/dev/rfcmm0', 9600)

while True:
res = ser.read()
print res

I'm seeing that the EZ Link LED is blinking fast, an indicator that it is connected via bluetooth to the Pi. However, I'm not seeing anything printed.

Hope someone point out what am I missing. I've been stuck with this the whole day.

POPEYE
Posts: 24
Joined: Fri Jul 27, 2012 2:31 pm

Re: Raspberry Pi 3 Bluetooth Setup

Sat Mar 03, 2018 2:19 pm

I am using Raspbian Jessie (RetriPie). How to make bluetooth powered off by default (so, that I could power it on using bluetoothctl) or, at least, make bluetoothctl to remember "power" parameter state after reboot?

Return to “Troubleshooting”