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

NRF51822 Data Logging - Buffering ADC measurements

I have been looking at the NRF51822 for data logging sensor measurements from the ADC. Currently, I have run into some limitations with iOS and can only get approximately 12 samples per second transmitted reliably from the NRF51822 (real-time). Unfortunately, I would like to get 1000 samples per second or better. My understanding is that I will have to buffer the samples, then transmit the buffered data to the iOS device. It doesn't have to be real-time. I would just like to sample for 1 or 2 seconds; store that data; then transmit to iOS device. Do you have sample code? I appreciate any advice.

Parents
  • The most important parameter to set data throughput is the connection interval. By the Bluetooth specification, the connection interval in BLE is limited to be between 7.5 ms and 4 s. Apple further limits the usable connection intervals in their Bluetooth Accessory Design Guidelines to be at least between 20 and 40 ms.

    With iOS you should be able to send up to 6 packets of 20 bytes each connection interval, and given an interval of 30 ms, this will give ~4 kbps. In practice you'll most likely see some less, since 6 packets won't be transferred every interval.

    We don't really have any sample code explicitly showing how to buffer and transmit data, but there isn't really any precautions needed to make this work. Just create a custom service and then send data with regular notifications, calling sd_ble_gatts_hvx() untill you get NO_TX_BUFFERS back. When you then get the BLE_EVT_TX_COMPLETE, you know there is more buffer space available, and you can send further data.

    For further explanation on connection parameters, take a look at this question.

Reply
  • The most important parameter to set data throughput is the connection interval. By the Bluetooth specification, the connection interval in BLE is limited to be between 7.5 ms and 4 s. Apple further limits the usable connection intervals in their Bluetooth Accessory Design Guidelines to be at least between 20 and 40 ms.

    With iOS you should be able to send up to 6 packets of 20 bytes each connection interval, and given an interval of 30 ms, this will give ~4 kbps. In practice you'll most likely see some less, since 6 packets won't be transferred every interval.

    We don't really have any sample code explicitly showing how to buffer and transmit data, but there isn't really any precautions needed to make this work. Just create a custom service and then send data with regular notifications, calling sd_ble_gatts_hvx() untill you get NO_TX_BUFFERS back. When you then get the BLE_EVT_TX_COMPLETE, you know there is more buffer space available, and you can send further data.

    For further explanation on connection parameters, take a look at this question.

Children
No Data
Related