ESP32 SerialBT sending data rate is not stable

Thread Starter

Mr. Pepper

Joined Apr 2, 2020
Hi all,

I'm using ESP32 model: ESP8266 with a built in BT module.
I'm trying to open a BT connection between the board and an phone app with sending data rate of ~1-3kHz.
I'm using Aruino IDE as a code environment and implementing the connection using #include "BluetoothSerial.h" library.

Trying to test the stability if the data rate, I've opened the connection for 10 seconds using a while loop with an exit condition as follows:
startTime = micros();
while (micros() - startTime <= 10000000) {
readNumber = analogRead(ANALOG_PIN_0) * 3.3 / 4095;

if (counter % 25 == 0) {
SerialBT.print(readNumber, 2);

where X was tested with values of 1,5,10, and 50.
The log suggest different and unstable counter values no matter what X value was.
I'm down sampling it every 25 reads and even though the phone (Samsung 10+) the data sometimes is corrupted and I'm facing lagging.
And since the data is supposed to present live, any lagging or instability are crucial.
My goal is to reach 2.5-3 kHz (at least) and the data sheet suggest the HW support this.

Any suggestion what I'm doing wrong?
Thanks ahead,
Last edited: