I am working on a DIY IoT project with my kid (we're building a piano! ) involving connecting our esp32 (WROOM32) over Bluetooth to my Android smartphone and transmitting continuous sensors' readings (hopefully at around 10Hz).
The issue we're facing is that every several seconds (periodically!) the SerialBT messages jam/lag/tear-up on the receiving end for about 3 seconds at a time, and this jumbles my entire application, as we need to parse the sensors' readings in real-time.
On a normal wired Serial connection, there is no issue and the messages flow like a charm, even when lagging in a Serial-Bluetooth connection in parallel.
To debug this issue, we've written a very minimal code - that only connects via SerialBT and sends the same message over & over again, with a 100ms delay (attached below).
We've ruled out the following possible problems:
Disconnected all sensors/cables
Tried 3 different ESP32s to try and rule out defective modules (but still a possibility)
Tried 2 Android phones to rule out phone problem
Using the "Serial Bluetooth Terminal" app on Android to rule out any bugs in our app
Ran it over a battery in an elevator to rule out radio-wave interference
What could cause this issue??
Please help us! The kid (& me lol) are losing interest as we've hit this unsolvable problem that no one on the internet seems to have encountered/solved
Thanks in advance!
Code: Select all
/*##### delay solver #####*/
#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
String packet = "1,2,3,4,5,6,7,8";
void setup() {
Serial.begin(115200);
// BT CONNECT
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
delay(100);
SerialBT.println(packet);
Serial.println(packet);
}