bleak icon indicating copy to clipboard operation
bleak copied to clipboard

Low data rate

Open billskar23 opened this issue 4 years ago • 2 comments

I have successfully connected my BLE device (ESP32 board + IMU) to my windows pc using Bleak library and I can receive data from the IMU.. However, I receive the data with a sampling frequency <25 Hz. Using the same code on my ESP32 board I can receive data on my phone with a rate of 180 Hz.

Why does this happen? Do I have to modify the library?

Thank you

billskar23 avatar Sep 23 '21 15:09 billskar23

Python is an interpreted language, so it can be a bit slow to start with, plus the bridge between Python and the WinRT API is probably not the most efficient. I would suggest starting with some profiling to see where the bottleneck is.

dlech avatar Sep 23 '21 17:09 dlech

FWIW, I'm receiving 5khz @ 16bit data via notifications with bleak, so it's not python per se. However, it's absolutely critical that you batch these up into "bigger" notifications. trying to send a notification for every single 16bit value will absolutely fail for instance. You might have a shorter connection interval on the phone?

karlp avatar May 09 '22 11:05 karlp

Closing due to insufficient feedback (logs).

dlech avatar Oct 03 '22 23:10 dlech

To clarify for anyone finding this, by "batch them up into bigger notifications" I mean, you absolutely can not send 2 byte (16bit) notifications at 5kHz. but sending 240byte notifications with multiple samples per packet lets me send my entire 16bit@5kHz sampled data without loss.

karlp avatar Oct 04 '22 09:10 karlp