Cannot connect two ESP'32's over Serial Bluetooth

Sideburn
Posts: 1
Joined: Thu Mar 09, 2023 5:38 pm

Cannot connect two ESP'32's over Serial Bluetooth

Postby Sideburn » Thu Mar 09, 2023 6:21 pm

Hello all,

I am trying to get a high speed connection (1 Mbps or close to) over Serial (Classic) Bluetooth between two ESP32's and have not been able to get them to successfully connect. I HAVE been able to connect to each device individually over a desktop computer so I know the code / devices are working but the two devices never connect.

Does anyone know why this would be or what I could do to resolve it?

Here is the scaled down version of my connection code:

Server / Host:

Code: Select all

#include <BluetoothSerial.h>

BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32_Server");
  Serial.println("ESP32_Server started");
}

void loop() {

  // Wait for a connection
  while (!SerialBT.hasClient()) { //never returns true
    delay(100);
  }

  // Once a client is connected, print a message to the Serial monitor
  Serial.println("##### Client connected #####");

}
client:

Code: Select all

#include <BluetoothSerial.h>

BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32_Client"); // Set the name of the client device
  Serial.println("ESP32_Client started");
}

void loop() {

  // Wait for a connection to the server
  while (!SerialBT.connect("ESP32_Server")) { //never returns true
    delay(1000);
  }

  //we never get here....
  // Once connected, send a message to the server
  String message = "Hello, world!";
  SerialBT.print(message);

  // Disconnect from the server
  SerialBT.disconnect();

  delay(5000);
}

Who is online

Users browsing this forum: Baidu [Spider] and 75 guests