This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52832 Maximize Data Throughput

I'm trying to understand the best way in which I can maximize the data throughput on an nRF52832.

I am using a custom circuit board which is running an early version of the nRF52 SDK (version 12, I think) in order to maintain compatibility with the Arduino IDE and the BLEPeripheral Arduino library. 

I am sending simple sensor data (packet sizes are 18 bytes) from the nRF52832 to a smartphone but what I'm finding is that after every transmission, I need to delay before the next, otherwise all data is not received by the smartphone. Typically, the delay is about 20 milliseconds to guarantee that the data is received however there is a lot of data to be transferred and 20ms delay between packets is causing havoc!

In order for my system to transmit real-time sensor data, I need a data rate of approximately 36kbps which seems ludicrously slow when compared to the actual quoted data rate.

Is anyone familiar enough with the V12 SDK or the Arduino libraries, who may be able to point me in the direction of what could be going wrong?

Thanks.

Parents
  • Hi Kevin

    What kind of smartphone are you using to receive the data, and which OS version is it running?

    Have you checked if the send function returns any errors when you try to send data more quickly?
    Normally you have to push packets until the buffers fill up, at which point you should get some kind of warning or error code from the BLE API. 
    Then you would have to retry sending the same packet until the function accepts it (adding a small delay for each retransmit). 

    Best regards
    Torbjørn

  • Hi,

    I'm using an iPhone and also a Samsung Galaxy S tablet running Android.

    I don't believe the BLE stack is returning an error.

    I have, however, done some digging around the BLEPeripheral library and it would seem that the initial min and max connection intervals are set to be quite long periods:


    gap_conn_params.min_conn_interval = 40; // in 1.25ms units
    gap_conn_params.max_conn_interval = 80; // in 1.25ms unit
    gap_conn_params.slave_latency = 0;
    gap_conn_params.conn_sup_timeout = 4000 / 10; // in 10ms unit

    So the minimum is 50ms and max is 100ms, which never get changed. I can look to certainly reduce this.

    I'll try to set the minimum to 7.5ms first and see if this improves things.

  • Hi Kevin

    If you look at the implementation of the send function you should be able to tell if it returns any of the errors that the stack might return, such as the one that occurs when the stack buffers are full. 

    Changing the connection interval is a good idea, and should give you improved data rate if the phone supports it. You probably won't be able to go as low as 7.5ms (at least not on the iPhone), but 15ms or less should be possible. 

    If the Arduino libraries support the data length extension feature you can also increase the size of the payload, and send multiple 18 byte packets in a single update, but this assumes you are able to buffer your sensor updates before sending them rather than sending them immediately. 

    Best regards
    Torbjørn

  • Hi Torbjørn,

    I made the a change to reduce the "connection interval" and this has improved things massively. I'm now getting very low latency between packet transmissions. I've actually had the minimum interval set to 7.5ms working with my Samsung Galaxy S Tablet but I've not yet tried on an iPhone. I think like you suggest, 15ms is a good compromise.

    I'm not sure if the Arduino library supports the DLE feature nor do I believe it buffers packets for a single transmission. Adding a buffered transmission option would be a worthy addition/upgrade to the library I think.

  • Hi Kevin

    It's good to hear that the connection interval change made a difference. 

    Depending on which SoftDevice version is used by the Arduino library this could also affect the number of features available (such as DLE). 

    In general I would suggest using the official Nordic libraries for optimal performance and improved support, but if you get the performance you need from the Arduino libraries then you might as well stick to what you know ;)

    Best regards
    Torbjørn

  • Hi Torbjørn,

    It's far from the ideal scenario but time constraints mean that for now, it is acceptable.

    I certainly would like to either move across to the official Nordic libraries (and latest SDK) or at least put some time in and bring the Arduino libs up to the later versions.

    I'm certain that there are massive performance gains to be had by doing this - together with a later SoftDevice too.

  • Hi Kevin

    If you want to contribute I am sure it will be appreciated ;) 

    You could also open an issue on the Github page and see if there are some existing initiatives to update the nRF52 support, but it doesn't seem like Sandeep Mistry is very active at the moment:
    https://github.com/sandeepmistry/arduino-BLEPeripheral/issues

    Best regards
    Torbjørn

Reply Children
No Data
Related