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

Sending SAADC over BLE?

I am trying to combine both the SAADC and BLE libraries to be able to read a value from my sensor on the analog pin and then send it over Bluetooth LE to a central dongle.

I have experimented with the /examples/peripheral/saadc example as well as the /examples/ble_peripheral/ble_app_uart. It seems that both of these examples do what I need but separately. However, when I try to combine them I experience a lot of issues.

Firstly, copying the saadc code verbatim over to the ble_app_uart code results in the LED flashing very rapidly and the output over serial to be garbage. I have narrowed down this problem being due to the fact that the APP_TIMER and Timer0 are going at the same time.

Next, I looked at the example code in this very helpful thread: devzone.nordicsemi.com/.../

And for testing purposes added the following code to the on_ble_evt handler for the condition BLE_GAP_EVT_CONNECTED:

printf("\n\rSAADC HAL simple example.\r\n");
nrf_saadc_task_trigger(NRF_SAADC_TASK_START  );
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE );
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE );
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE );
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE );
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE );
nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP  );

This code resulted in UART showing me the values being captured from SAADC, but all of these values are 0.

I am at a loss here after trying to figure this out for several days now. Could anybody steer me into the right direction for accomplishing this task that seems should be very simple?

TL;DR I am trying to connect a peripheral to a central device with BLE. The peripheral will be using SAADC to read the analog input 0 and will send these values to the central device so that the central device can print it out over UART. I cannot seem to figure out how to combine the two examples given.

Related