I am trying to understand the maximum BT SPP transmission speed that can be achieved using ESP32.
What my project requires is to send 2bytes of data every 200us (5kHz) AND additional 15bytes of data every 50ms(20Hz) via BT.
I am trying to achieve that using BT SPP, however, I could not understand the speed of BluetoothSerial::write AND BluetoothSerial::print.
Based on my testing for 5kHz, the BluetoothSerial::write freezes after 2-3 seconds of connection.
BluetoothSerial::println function doesn't seem to freeze, however, the time taken for the function to complete doesn't seem to be constant. Please refer to the code below on how I measure the time taken for the function to complete.
The picture below shows the time in microseconds each time the function (dataFormat()) takes place. If you look through, there are 2 instances where te time is more than average 80us.
I would like to know, ESP32 BT SPP can achieve such a speed or there is another way I could achieve this.
Thank you for your time and assistance in this matter.
[/Codebox]
- void dataFormat(record r){
- serialBtPrint_dur = micros();
- char msg[20];
- sprintf(msg,"%04d%05d%05d%05",r.e, r.r, r.p, r.y);
- SerialBT.println(msg);
- serialBtPrint_dur = micros() - serialBtPrint_dur;
- }
- }
- void loop() {
- char msg[20];
- uint8_t testMsg[20] = "abcdefghijklmnop\n";
- if(!structs.isEmpty()){
- dataset[local_rd_ptr].yawData);
- data::dataFormat(structs.shift());
- Serial.println(serialBtPrint_dur);
- }
- }