BT and BLE continuous scanning with RAK11200

Hello again.
I am trying to make a continuous connection with a BT device and perform continuous scanning of becons in @beegee’s post on the page ESP32 Bluetooth Serial and BLE server running together – Bernd's development stuff
it mentions that something similar only that I initialize first BLE and then BT however this is applied to server mode. and in my case I can’t get both to work together. am I getting something wrong?

the code of my setup is the following.

void setup() {

Serial.println("\n\n SYSTEM STARTED\n ------------------------------------\n");

SerialBT.begin(“ESP32test”, true);/////////////////

if (!SerialBT.connect(“TEST”))
Serial.println(“Couldn’t connect to TEST scanner”);


Serial.println(“Connected to TEST”);

while(SerialBT.available())//read response
char c =;
Serial.write(c);//print response

pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->setWindow(99); // less or equal setInterval valu
Serial.println(“Init scanning adv…”);


Hello @JorgeFG

Well I wrote this 3 years ago and many things in the ESP32 BSP might have changed.

One thing I see is that the sequence in my example is

Init BLE device => BLEDevice::init(apName);
Init Bluetooth Serial => SerialBT.begin(apName);
Then do the rest of the BLE initialisation like

  • create server
  • add callbacks to server
  • add characteristics
  • start server
  • start advertising

In your code you initialize BTSerial before you initialize the BLE server

SerialBT.begin(“ESP32test”, true);/////////////////

Maybe try the same sequence that worked for me.