I have been having a problem using Bluetooth code examples on the “Bluetooth Usage on Seeed Studio XIAO ESP32C3” in the Seeed Wiki (Bluetooth Usage on Seeed Studio XIAO ESP32C3 - Seeed Wiki). I have been unable to pick up an advertisement from the Bluetooth server example using the Bluetooth client example.
Here is the problem.
I acquired a pair of Seeed Xiao ESP32C3 modules. I used the Arduino IDE to upload the examples from the Seeed Xiao Wiki to the two devices. I uploaded the Bluetooth scanner example code to Xiao #1, and I uploaded ran the Bluetooth server example to Xiao #2. I made no changes to the example code.
Using the two independently, I could run the Bluetooth scanner example on Xiao #1, and the output in the Serial Monitor showed Bluetooth advertisements from both my desktop PC and my iPhone. But Xiao #1 would not show advertisements from Xiao #2. However, both Bluetooth and other devices section in the Windows Control Panel on my desktop PC and the Light Blue app on my iPhone would show that they could detect advertisements from Xiao #2.
What am I doing wrong? Why can’t Xiao #1 detect the Bluetooth server running on Xiao #2.
BLEDevice::init("");
pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
pBLEScan->setInterval(100);
pBLEScan->setWindow(99); // less or equal setInterval value
}
void loop() {
// put your main code here, to run repeatedly:
BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
Serial.print("Devices found: ");
Serial.println(foundDevices.getCount());
Serial.println(“Scan done!”);
pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
}
Hi rjz,
I tried the wiki sketches.
Once connected to the PC or iPhone and reading “Hello World”, the XIAO#1 will not be able to detect it.
Turn off BLE on the PC or iPhone. Reset XIAO#2. Then XIAO#2 will be visible.
You should see on the XIAO#2 serial monitor “Advertised Device: Name: MyESP32, Address: xx:xx:xx:xx:xx:xx:xx, txPower: 9”.
To be sure, add a delay after Serial.begin(), like delay(5000), and bring up the serial monitor during this time.