BT Classic communication between two ESP32

Posts: 1
Joined: Fri May 11, 2018 10:34 am

BT Classic communication between two ESP32

Postby Crisos » Fri May 11, 2018 11:24 am

Hi Everyone,

I have a very simple application where one ESP32 sends a message over BT to another ESP32. I have been playing mostly with Arduinos till now and using that this kind of application was quite easy, but now I want to move to this platform.

Using BluetoothSerial.h library I can happily connect to an Android device and send those messages, but I can't start the connection from another ESP32. This library doesn't have a connect command, so I went and found out what is the control to connect via SPP and I seem to be able to find the other device and connect to it, but also seems like the connection crashes immediately afterwards.

Here the code I am using:

Code: Select all

#include "esp_bt_main.h"
#include "esp_gap_bt_api.h"
#include "esp_spp_api.h"
#include <BluetoothSerial.h>

uint8_t address[6] = {0x30, 0xAE, 0xA4, 0x21, 0xBA, 0xBA};
String MACadd = "30:AE:A4:21:BA:BA";

static const esp_spp_sec_t sec_mask = ESP_SPP_SEC_NONE;
static const esp_spp_role_t role_slave = ESP_SPP_ROLE_MASTER;
esp_err_t connHan;

BluetoothSerial SerialBT;

void setup() {
  Serial.println("The device is ready!");
  SerialBT.begin("Glove ESP");
  Serial.println("Looking for device...");
  if(esp_spp_start_discovery(address) == ESP_OK){
    Serial.println("Device found!");
    Serial.println("Device not found :(");
  connHan = esp_spp_connect(ESP_SPP_SEC_NONE, ESP_SPP_ROLE_MASTER, 3,address);
  if(connHan == ESP_OK){
    Serial.println("Device Connected!");
    Serial.println("Device not connected :(");
  if (SerialBT.hasClient() == true) {
        Serial.print("Client connected");
        //SerialBT.println("some text");
    } else {
        Serial.println("Client disconnected");
        SerialBT.begin("Glove ESP");
void loop() {

I tried with different SCN, but all the time I get this message: (not sure why it is not clear, like wrong baud)

Code: Select all

C'΂⸮⸮Θb⸮⸮`<⸮!⸮The device is ready!
Looking for device...
Device found!
Device Connected!
E (1520) BT: btm_sec_connected

E (1545) BT: l2cu_adjust_out_mps bad packet size: 0  will use MPS: 0
E (1554) BT: process_service_search_attr_rsp

E (1604) BT: port_rfc_closed RFCOMM connection in state 1 closed: Closed (res: 19)
Client disconnected
E (2146) BT: btc_spp_disconnect unable to find RFCOMM slot! disconnect fail!
E (2146) BT: JVenable fails

Anyone can help? I have spent like two days on this and I couldn't imagine it could be so complicated!
Thank you in advance!

Posts: 1
Joined: Sun May 13, 2018 4:00 pm

Re: BT Classic communication between two ESP32

Postby PeterWay » Sun May 13, 2018 4:06 pm


i will add at this topis my question.

I like to use BT classic commninication.
At first im loking for Arduino example for search classic BT equ. near.
Second i like to make pair od them and serial cimmunication over.

Im loking and searcing all google, but i found only examples for BLE.

TNX for help and answer


Posts: 4
Joined: Sat Jun 30, 2018 2:49 pm

Re: BT Classic communication between two ESP32

Postby alwurts » Sat Jun 30, 2018 2:57 pm


Im trying to make a two way bluetooth connection between two ESP32, same as you.
If you managed to make it work please let me know, it would be of great help.


Who is online

Users browsing this forum: Agree007, Bing [Bot] and 1 guest