Hilo
Posts: 3
Joined: Wed May 27, 2020 4:28 pm

multiple BT connection

Wed May 27, 2020 4:33 pm

I would like to connect to my raspberry multiple BLE devices. using nRF connect I can connect just with one smartphone. I started with the code from this repo https://github.com/Douglas6/cputemp. any suggestion on how to do that?

User avatar
topguy
Posts: 6425
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: multiple BT connection

Wed May 27, 2020 5:22 pm

What is your usecase ?
Are the Pi going to read data from other BLE devices or report data to clients ?

Hilo
Posts: 3
Joined: Wed May 27, 2020 4:28 pm

Re: multiple BT connection

Fri May 29, 2020 9:17 am

what to read data (in this case CPU temperature) with multiple device from the Pi. ATM if I connect with nRF Connect to the PI with a smartphone I can't connect another smartphone without disconnect before the first one

User avatar
topguy
Posts: 6425
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: multiple BT connection

Fri May 29, 2020 9:58 am

It might be a limitation in the GATT server example code you are using..

Maybe send the Author a question on GutHub to see if this is the case.

PiGraham
Posts: 3926
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: multiple BT connection

Fri May 29, 2020 10:17 am

Hilo wrote:
Fri May 29, 2020 9:17 am
what to read data (in this case CPU temperature) with multiple device from the Pi. ATM if I connect with nRF Connect to the PI with a smartphone I can't connect another smartphone without disconnect before the first one
I don't know, but is that a general limitation of Bluetooth devices? I can't connect more than one phone at once to a Bluetooth speaker or headset. Many BT devices are either in connectable state or a connected state.

What BT devices allow multiple clients to connect at once?

Could you use Wi-Fi. That definitely allows multiple connections by design.

Hilo
Posts: 3
Joined: Wed May 27, 2020 4:28 pm

Re: multiple BT connection

Fri May 29, 2020 1:20 pm

PiGraham wrote:
Fri May 29, 2020 10:17 am
Hilo wrote:
Fri May 29, 2020 9:17 am
what to read data (in this case CPU temperature) with multiple device from the Pi. ATM if I connect with nRF Connect to the PI with a smartphone I can't connect another smartphone without disconnect before the first one
I don't know, but is that a general limitation of Bluetooth devices? I can't connect more than one phone at once to a Bluetooth speaker or headset. Many BT devices are either in connectable state or a connected state.

What BT devices allow multiple clients to connect at once?

Could you use Wi-Fi. That definitely allows multiple connections by design.
The limitation for standard BT is 7 device to a master (in BLE it is teorically 65k). you can't connect your phone to multiple speaker not for BT limitation but just cuz in phones is implemented like this (and this is not entirelly true cuz you can connect to the PI and listen music with speaker at the same time). Using a BT server on Raspberry PI teorically speaking it is possible but I don't know how..

PiGraham
Posts: 3926
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: multiple BT connection

Fri May 29, 2020 2:20 pm

Hilo wrote:
Fri May 29, 2020 1:20 pm

The limitation for standard BT is 7 device to a master (in BLE it is teorically 65k). you can't connect your phone to multiple speaker not for BT limitation but just cuz in phones is implemented like this (and this is not entirelly true cuz you can connect to the PI and listen music with speaker at the same time). Using a BT server on Raspberry PI teorically speaking it is possible but I don't know how..
I read your post to be RPi as slave and you want to connect multiple Master devices to it at the same time to read the temp.

Clearly you can connect a phone to multiple BT devices at the same time, and given the right app I suppose you could pipe music to multiple speakers. But can slaves connect to many masters at once?

Or have I misunderstood your objective?

meeriino
Posts: 3
Joined: Mon Apr 06, 2020 12:19 pm

Re: multiple BT connection

Mon Jun 01, 2020 5:10 pm

PiGraham wrote:
Fri May 29, 2020 2:20 pm
Hilo wrote:
Fri May 29, 2020 1:20 pm

The limitation for standard BT is 7 device to a master (in BLE it is teorically 65k). you can't connect your phone to multiple speaker not for BT limitation but just cuz in phones is implemented like this (and this is not entirelly true cuz you can connect to the PI and listen music with speaker at the same time). Using a BT server on Raspberry PI teorically speaking it is possible but I don't know how..
I read your post to be RPi as slave and you want to connect multiple Master devices to it at the same time to read the temp.

Clearly you can connect a phone to multiple BT devices at the same time, and given the right app I suppose you could pipe music to multiple speakers. But can slaves connect to many masters at once?

Or have I misunderstood your objective?
hey, I'm interesting in something similar. I wanna play music from my RPi 4B to multiple slave speakers...

What about that? Have anybody any idea?

fanoush
Posts: 536
Joined: Mon Feb 27, 2012 2:37 pm

Re: multiple BT connection

Mon Jun 01, 2020 6:15 pm

Hilo wrote:
Fri May 29, 2020 9:17 am
what to read data (in this case CPU temperature) with multiple device from the Pi. ATM if I connect with nRF Connect to the PI with a smartphone I can't connect another smartphone without disconnect before the first one
You don't need connection for that, you can put temperature and more information directly to advertising packet or to scan response packet.

PiGraham
Posts: 3926
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: multiple BT connection

Mon Jun 01, 2020 6:32 pm

fanoush wrote:
Mon Jun 01, 2020 6:15 pm
Hilo wrote:
Fri May 29, 2020 9:17 am
what to read data (in this case CPU temperature) with multiple device from the Pi. ATM if I connect with nRF Connect to the PI with a smartphone I can't connect another smartphone without disconnect before the first one
You don't need connection for that, you can put temperature and more information directly to advertising packet or to scan response packet.
Good idea! Do you have any pointers on how do that?

PiGraham
Posts: 3926
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: multiple BT connection

Mon Jun 01, 2020 6:35 pm


deepo
Posts: 572
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: multiple BT connection

Mon Jun 01, 2020 6:41 pm

PiGraham wrote:
Mon Jun 01, 2020 6:32 pm
fanoush wrote:
Mon Jun 01, 2020 6:15 pm
Hilo wrote:
Fri May 29, 2020 9:17 am
what to read data (in this case CPU temperature) with multiple device from the Pi. ATM if I connect with nRF Connect to the PI with a smartphone I can't connect another smartphone without disconnect before the first one
You don't need connection for that, you can put temperature and more information directly to advertising packet or to scan response packet.
Good idea! Do you have any pointers on how do that?
The Eddystone beacon specification describes that.
https://github.com/google/eddystone

Specifically the TLM (telemetry, unencrypted) specification allows you to put a temperature in an advertisement message. There are probably other specifications that does that too, but here it is.
https://github.com/google/eddystone/blo ... m-plain.md

This guide tells you how to have a Raspberry Pi sending those advertisements:
https://pimylifeup.com/raspberry-pi-eddystone-beacon/

/Mogens

fanoush
Posts: 536
Joined: Mon Feb 27, 2012 2:37 pm

Re: multiple BT connection

Tue Jun 02, 2020 8:26 am

You can put almost anything into advertising packet just be aware of size limitation - 31 bytes. There are some assigned ids here https://www.bluetooth.com/specification ... s-profile/ e.g. name is 0x09, structure is sequence of length,type,value,.. Good is to use nrfconnect on your phone, pick device from list and click "RAW" and you will see advertising packet structure.

Advertising packet is broadcast to anyone, scan response is for those who ask back and scan your device (still without connection). Also it is possible to keep some part of packet fixed (e.g. name if you want any) and vary the rest (e.g. manufacturer data) if one needs to send more data. Then the receiving device must collect more packets over time.

I am not sure how exactly this can be done on the PI, this is generic BLE knowledge. Personally I use it with Espruino on nrf52 smartwatches - the api description https://www.espruino.com/Reference#l_NRF_setAdvertising explains a lot of possibilities or there are examples e.g. here https://www.espruino.com/BLE%20Advertising or here http://forum.espruino.com/conversations/306687/ to get more info what should be possible on the Pi too.

BTW if you are into BLE, current best choice for hackable BLE smartwatch that can run your Arduino or Espruino code without taking it apart is probably the P8 for ~US$18 or F07 fitness tracker for $14-$16 see e.g. https://hackaday.com/2020/05/02/cheap-s ... -own-code/ or Espruino for P8 here , for F07 here

Also the Pinetime watch is very similar/same to P8 (same manufacturer, mostly same hardware inside) but P8 is better choice IMO.

deepo
Posts: 572
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: multiple BT connection

Tue Jun 02, 2020 5:17 pm

If one were to follow a standard, the GATT Specifications for Health Thermometer Profile and Health Thermometer Service could be a way to send a temperature. But I don't know enough about Bluetooth to implement such a thing. Maybe others with more Bluetooth knowledge could comment?
https://www.bluetooth.com/specifications/gatt/

/Mogens

Return to “Advanced users”