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

1kHz or more ADC sampling rate over BLE

Problem:

I am trying send samples from SAADC to the NRFconnect app at 1kHz. I have built my application on the ble_app_uart__saadc_timer_driven__scan_mode example. I have managed to achieve 420Hz but anything more than that results in a timeout error:

Error 8(0x8): GATT CONN TIMEOUT

Changes in default example:

  1. Samples in buffer increased from 4 to 24
  2. MIN_CONN_INTERVAL is 7.5ms
  3. MAX_CONN_INTERVAL is 15
  4. Bluetooth timeout and disconnect responses modified to make sure Bluetooth is visible and connectable even after a disconnect
  5. Only 1 ADC channel used instead of 4
  6. Sending data twice in one SAADC callback function, as follows

ret_code_t err_code;
uint16_t value[SAADC_SAMPLES_IN_BUFFER];
uint16_t bytes_to_send;

err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAADC_SAMPLES_IN_BUFFER);
APP_ERROR_CHECK(err_code);

for (int i = 0; i < SAADC_SAMPLES_IN_BUFFER; i++)
{
    if (p_event->data.done.p_buffer[i] <= 0)
    {
        value[i] = 0;
    }
    else
    {
        value[i] = p_event->data.done.p_buffer[i];
    }
}

uint8_t nus_string[50];

bytes_to_send = sprintf(nus_string, "%d %d %d %d %d %d %d %d %d %d", value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8], value[9]);
err_code = ble_nus_data_send(&m_nus, nus_string, &bytes_to_send, m_conn_handle);

bytes_to_send = sprintf(nus_string, "%d %d %d %d %d %d %d %d %d %d", value[10], value[11], value[12], value[13], value[14], value[15], value[16], value[17], value[18], value[19]);
err_code = ble_nus_data_send(&m_nus, nus_string, &bytes_to_send, m_conn_handle);

I cannot figure out how to increase the data rate anymore. I tried putting more values in one bytes_to_send string, but it shows the same error after 1 or 2 seconds. I tried sending more values by using the bytes_to_send block thrice instead of twice, all in no vein. I am using SoftDevice 132.

 Any help with this would be greatly appreciated. 

Thanks in advance,

Usman

Parents Reply Children
No Data
Related