Wifi BLE coexistence using Arduino IDE
Posted: Thu Jul 30, 2020 11:27 am
Hello Everyone,
I am new to Esp32 and currently using ESP32 NodeMCU-ESP32 with arduino IDE. Please forgive me if I have posted it in incorrect forum.
I am working on application which requires co-existence of BLE and Wifi.
Here's the data flow;
ESP32 act as Master -> connects to BLE device which provides data -> Data received by ESP32 from mobile via BLE -> ESP process the data -> Sends the data to server using wifi -> receive another data from server -> send to external device via BLE.
So ESP act as bridge between two device.
There are two parts:
a. Getting data from device via BLE
b. Posting data to server or reading data from server
I have tested both part individually and they worked perfectly fine. When I tried to merge that, its not working. In this merged code, the BLE device connects fine, also receiving data works, but it is unable to post the data to server. However, if I disable the BLE here, same code can post data properly. So I am slightly confident that it has something to do with radio sharing between BLE and Wifi.
As per this FAQ document: https://www.espressif.com/sites/default ... Qs__EN.pdf
5.3.2. How do ESP32 Bluetooth states " Please note that if Option “Software controls WiFi/Bluetooth coexistence” is enabled, the BLE scan interval shall not exceed 0x100 slots (about 160 ms)."
I am using above method to set the intervals as suggested by Document. Is this correct or am I missing something?
I also tried to disable BLE when wifi operation is happening using WiFi.mode (WIFI_OFF); btStart(); btStop(); by referring to wifiBluetoothSwitch Example from arduino
Complete code here : https://drive.google.com/file/d/1AINLN4 ... sp=sharing
As per datasheet, they both can coexist, can someone please guide me?
I am new to Esp32 and currently using ESP32 NodeMCU-ESP32 with arduino IDE. Please forgive me if I have posted it in incorrect forum.
I am working on application which requires co-existence of BLE and Wifi.
Here's the data flow;
ESP32 act as Master -> connects to BLE device which provides data -> Data received by ESP32 from mobile via BLE -> ESP process the data -> Sends the data to server using wifi -> receive another data from server -> send to external device via BLE.
So ESP act as bridge between two device.
There are two parts:
a. Getting data from device via BLE
b. Posting data to server or reading data from server
I have tested both part individually and they worked perfectly fine. When I tried to merge that, its not working. In this merged code, the BLE device connects fine, also receiving data works, but it is unable to post the data to server. However, if I disable the BLE here, same code can post data properly. So I am slightly confident that it has something to do with radio sharing between BLE and Wifi.
As per this FAQ document: https://www.espressif.com/sites/default ... Qs__EN.pdf
5.3.2. How do ESP32 Bluetooth states " Please note that if Option “Software controls WiFi/Bluetooth coexistence” is enabled, the BLE scan interval shall not exceed 0x100 slots (about 160 ms)."
Code: Select all
[Codebox=cpp file=Untitled.cpp]Pseudo code:
#define CONFIG_SW_COEXIST_ENABLE 1
int scanTime = 5; //duration The duration in seconds for which to scan In seconds int scanWindow = 50; //In msec int scanInterval =100; // in Msec
void scanForDevices(){
Serial.println("Scanning for Bluetooth devices...");
// Retrieve a Scanner and set the callback we want to use to be informed when we
// have detected a new device. Specify that we want active scanning and start the
// scan to run for 30 seconds.
BLEScan* pBLEScan = BLEDevice::getScan();
pBLEScan->setAdvertisedDeviceCallbacks(new AdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true);
pBLEScan->setInterval(scanInterval); //in Msec
pBLEScan->setWindow(scanWindow); // in mSec
pBLEScan->start(scanTime); // in seconds
}[/Codebox]
I also tried to disable BLE when wifi operation is happening using WiFi.mode (WIFI_OFF); btStart(); btStop(); by referring to wifiBluetoothSwitch Example from arduino
Complete code here : https://drive.google.com/file/d/1AINLN4 ... sp=sharing
As per datasheet, they both can coexist, can someone please guide me?