ESP32 Bluetooth SPP with bidirectional communication (send and receive)

suriyaelango
Posts: 2
Joined: Mon Mar 11, 2019 2:07 pm

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby suriyaelango » Mon Mar 11, 2019 2:12 pm

Hi,
Can someone please tell me if Bluetooth SPP supports multiple clients in case of bi-directional communication? If yes, implementation code, please.

User avatar
gunar.kroeger
Posts: 69
Joined: Fri Jul 27, 2018 6:48 pm

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby gunar.kroeger » Tue Mar 12, 2019 4:20 pm

suriyaelango wrote: Hi,
Can someone please tell me if Bluetooth SPP supports multiple clients in case of bi-directional communication? If yes, implementation code, please.
It does. You will have to save the connection handle from incoming clients and direct the messages with esp_spp_write to the correct handle
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

suriyaelango
Posts: 2
Joined: Mon Mar 11, 2019 2:07 pm

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby suriyaelango » Mon Mar 18, 2019 7:57 am

The esp_spp_write function is an IDF function. Any chance it works with the Arduino framework for ESP32?

User avatar
ESP_Me-no-dev
Posts: 64
Joined: Mon Jan 04, 2016 6:30 pm

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby ESP_Me-no-dev » Tue Mar 19, 2019 4:01 pm

We already have a library and example in Arduino for SPP use: https://github.com/espressif/arduino-es ... rialBT.ino

SpartaYigit
Posts: 3
Joined: Wed Mar 20, 2019 7:20 pm

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby SpartaYigit » Wed Mar 20, 2019 7:29 pm

ESP_Me-no-dev wrote:
Tue Mar 19, 2019 4:01 pm
We already have a library and example in Arduino for SPP use: https://github.com/espressif/arduino-es ... rialBT.ino
The BluetoothSerial library does not allow to connect directly to other devices (when a UUID is given) using SPP. Is this correct? If not, is there an example to do this in Arduino?

(I want to connect the ESP32 to the Neurosky Mindwave Mobile which uses Serial Port Profile (classic bluetooth). I have looked into the SPP_initiator example and it allows me to connect to the device but couldn't receive any data from it.)

User avatar
JWardell
Posts: 2
Joined: Wed Apr 24, 2019 3:30 am

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby JWardell » Wed Apr 24, 2019 3:33 am

SpartaYigit wrote:
Wed Mar 20, 2019 7:29 pm
The BluetoothSerial library does not allow to connect directly to other devices (when a UUID is given) using SPP. Is this correct? If not, is there an example to do this in Arduino?

(I want to connect the ESP32 to the Neurosky Mindwave Mobile which uses Serial Port Profile (classic bluetooth). I have looked into the SPP_initiator example and it allows me to connect to the device but couldn't receive any data from it.)
I'm trying to do the same thing, to connect to an existing bluetooth serial device. Have you figured out a way to do with with Arduino?
Thanks.

SpartaYigit
Posts: 3
Joined: Wed Mar 20, 2019 7:20 pm

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby SpartaYigit » Wed Apr 24, 2019 12:37 pm

JWardell wrote:
Wed Apr 24, 2019 3:33 am
SpartaYigit wrote:
Wed Mar 20, 2019 7:29 pm
The BluetoothSerial library does not allow to connect directly to other devices (when a UUID is given) using SPP. Is this correct? If not, is there an example to do this in Arduino?

(I want to connect the ESP32 to the Neurosky Mindwave Mobile which uses Serial Port Profile (classic bluetooth). I have looked into the SPP_initiator example and it allows me to connect to the device but couldn't receive any data from it.)
I'm trying to do the same thing, to connect to an existing bluetooth serial device. Have you figured out a way to do with with Arduino?
Thanks.
Yeah, currently it is working with arduino. I have changed the bluetooth serial library to allow connecting to the Mindwave headset. The only problem left is the data that i am receiving. I can only see the raw data that the headset sends over (every 2 ms). I cannot seem to get the eSense values out of it which is sent every 1 second. Maybe we can help eachother out.

User avatar
JWardell
Posts: 2
Joined: Wed Apr 24, 2019 3:30 am

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby JWardell » Thu Apr 25, 2019 2:39 am

SpartaYigit wrote:
Wed Apr 24, 2019 12:37 pm
Yeah, currently it is working with arduino. I have changed the bluetooth serial library to allow connecting to the Mindwave headset. The only problem left is the data that i am receiving. I can only see the raw data that the headset sends over (every 2 ms). I cannot seem to get the eSense values out of it which is sent every 1 second. Maybe we can help eachother out.
So you had to modify the bluetooth serial library to allow pairing etc, or did you change to a different library? How difficult is it? Is there a way to get a list of discoverable devices?

Trying to find what you are trying to interface with, some kind of EEG?

SpartaYigit
Posts: 3
Joined: Wed Mar 20, 2019 7:20 pm

Re: ESP32 Bluetooth SPP with bidirectional communication (send and receive)

Postby SpartaYigit » Sun Apr 28, 2019 8:24 am

JWardell wrote:
Thu Apr 25, 2019 2:39 am
SpartaYigit wrote:
Wed Apr 24, 2019 12:37 pm
Yeah, currently it is working with arduino. I have changed the bluetooth serial library to allow connecting to the Mindwave headset. The only problem left is the data that i am receiving. I can only see the raw data that the headset sends over (every 2 ms). I cannot seem to get the eSense values out of it which is sent every 1 second. Maybe we can help eachother out.
So you had to modify the bluetooth serial library to allow pairing etc, or did you change to a different library? How difficult is it? Is there a way to get a list of discoverable devices?

Trying to find what you are trying to interface with, some kind of EEG?
Correct, I was trying to get the brainwave values from a Neurosky MindWave headset through the bluetooth conection.

I modified the Bluetooth Serial library with the SPP_initiator example from ESP32-IDF to have the buffer functionality of the library when data is being received. It was a lot of work in the beginning to understand the code but now it finally works. There is code available on Qita https://qiita.com/ajtajta_j/items/297c6191635b47c945cb from which i started to directly connect to a device when the UUID is known (but has no buffer). There is a bt_discovery example on GitHub to see a list of discoverable devices.

Feel free to ask if something is not clear.

Who is online

Users browsing this forum: vinots and 22 guests