ESP-32 Bluetooth read delay
Posted: Tue Dec 26, 2023 8:16 am
Hey Folks,
I've been searching the web and this forum for an answer, but didn't find one.
So the problem is that i have always a delay of about 1000ms when I send a message to the ESP-32 before showing up in the serial monitor. For me, it seems some sort of read timeout, but couldn't figure it out. Does anyone know why there could be such a delay?
I'm using the SerialToSerialBT example. https://github.com/espressif/arduino-es ... rialBT.ino
I'm using PlatformIO and the Arduino Framework. I'm sending the data from an Android 13 Device with Serial Bluetooth Terminal. https://play.google.com/store/apps/deta ... l=de&gl=US.
I've also tested another older Android device. Same problem here.
When I use
the weird delay shows up. Seems to be always 1000ms + general Bluetooth delay (~20 - 100ms). What I'm doing wrong?
Thank you in advance and best regards. Cheers.
I've been searching the web and this forum for an answer, but didn't find one.
So the problem is that i have always a delay of about 1000ms when I send a message to the ESP-32 before showing up in the serial monitor. For me, it seems some sort of read timeout, but couldn't figure it out. Does anyone know why there could be such a delay?
I'm using the SerialToSerialBT example. https://github.com/espressif/arduino-es ... rialBT.ino
I'm using PlatformIO and the Arduino Framework. I'm sending the data from an Android 13 Device with Serial Bluetooth Terminal. https://play.google.com/store/apps/deta ... l=de&gl=US.
I've also tested another older Android device. Same problem here.
Code: Select all
platform = espressif32
board = az-delivery-devkit-v4
board_build.mcu = esp32
framework = arduino
Code: Select all
if (SerialBT.available()) {
Serial.println(SerialBT.readString());
}
Code: Select all
#include "BluetoothSerial.h"
String device_name = "ESP32-BT-Slave";
// Check if Bluetooth is available
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
// Check Serial Port Profile
#if !defined(CONFIG_BT_SPP_ENABLED)
#error Serial Port Profile for Bluetooth is not available or not enabled. It is only available for the ESP32 chip.
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin(device_name); //Bluetooth device name
//SerialBT.deleteAllBondedDevices(); // Uncomment this to delete paired devices; Must be called after begin
Serial.printf("The device with name \"%s\" is started.\nNow you can pair it with Bluetooth!\n", device_name.c_str());
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.println(SerialBT.readString());
}
}