Jakeler / ble-serial

"RFCOMM for BLE" a UART over Bluetooth low energy (4+) bridge for Linux, Mac and Windows
https://blog.ja-ke.tech/tags/#bluetooth
MIT License
274 stars 38 forks source link

Only reads at 9600 baud rate #58

Closed elmerescandon closed 2 years ago

elmerescandon commented 2 years ago

I have an issue regarding the baud rate of my bluetooth module and the connection with my Windows 10 computer. I am reading IMU measurements using an ATMEGA328p and a HM-10 (v4.0-BLE) bluetooth module, and to read data from the BT module I am using the ble-serial library and RealTerm to check whether my data is accurate; however, I require higher communication speed for my application, at least 38400 baud rate.

Currently, I have an issue when reading the baud rate at 38400 from my bluetooth module with ble-serial, since I am losing data characters (at least 10 of the 50 char array could be more), also I've been using the RealTerm to configure the baud rate of the ble-serial, I'm not sure if this is the right way to do it though.

Is there any information I am not taking into consideration? How do I configure the baud rate when it comes to my Laptop's blueooth module? Using RealTerm with ble-serial is the right way to read data with this library?

Thanks for your contribution!!

Jakeler commented 2 years ago

Yes, you can use Realterm. Note that the baud rate setting there does not matter, I briefly mentioned this in the readme, the virtual port ignores the parameters and runs always with maximum speed. ble-serial has no baud rate configuration, just make sure the BLE module has the correct baud for the hardware.

I also did performance tests with the HM-10: https://blog.ja-ke.tech/2021/04/22/ble-serial-2.html#performance Interesting for your usecase are the UART -> BLE results, the maximum throughput I achieved was 17k - if you constantly push 38.4k then about 50% loss would be expected. These tests were done on Linux, which uses a completely different serial and bluetooth implementation, so I don't think the bottleneck is the computer with ble-serial. Instead I suspect the HM-10 has some limitations, I did not investigate this further but would expect for example an ESP32 to perform better. Also with direct programming of the integrated BLE interface it provides more options, larger packets could reduce the overhead and loss significantly.

So there is no easy config solution, hopefully the infos bring you further anyway. Please publish the results if you have a chance to try it with a different BLE modules.