About NodeMcu Esp32 Multiple connection?

Hi there

I need to read data from Esp32's serial pins and send data to two android phone with bluetooth serial. But in the code below I can connect 1 phone and read data but 2. phone cant connect or Connect and immediately disconnect.

I tried somethings in "BluetoothSerial.cpp" I able to connect 2 phones but esp32 can only send data to last connected phone. I guess it saves last connected adress in memory I dont know.

Is there any solution or different library for that?

Thank you

#include "BluetoothSerial.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32test"); //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");
}

void loop() {
  if (Serial.available()) {
    SerialBT.write(Serial.read());
  }
  if (SerialBT.available()) {
    
    Serial.write(SerialBT.read());

  }
  delay(20);
  
 
}

The key is, only one device can act as a “sink” for any provided service, which makes sense. Bluetooth is designed to provide the same services you get through wired accessories, minus the wire.

https://www.quora.com/Why-is-it-not-possible-to-connect-2-bluetooth-devices-into-one-device

https://www.sony-mea.com/en/electronics/support/wireless-headphones-bluetooth-headphones/wh-1000xm4/articles/00196698

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.