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

wrong sensor data sending over ble

Hi,

I´m using nrf52833 on customized board with a sensor on it. I would like to send the data, collected from sensor ober ble to nrf connect app. I print the collected data on uart terminal too.

The data on uart terminal is correct. I send two Bytes, so the value is between 0 -   65535.

But on nrf connect app the data is shown as different characters, for example "�" or "@".

The Code is really simple, so I would like to Show you a sample:

...

...

This shows the correct value of variable result on uart terminal

  printf(" ACCEL_X:  %u", (unsigned int)result);

This shows the incorrect value on nrf connect app. 

      

 uint32_t       err_code2;
       static uint8_t index2 = 16;
       uint16_t length2 = (uint16_t)index2;
                        err_code2 = ble_nus_data_send(&m_nus, (unsigned int)ergebnis , &length2, m_conn_handle);
                        if ((err_code2 != NRF_ERROR_INVALID_STATE) &&
                            (err_code2 != NRF_ERROR_RESOURCES) &&
                            (err_code2 != NRF_ERROR_NOT_FOUND))
                        {
                            APP_ERROR_CHECK(err_code2);
                        }

What I´m doing wrong? The Code for sending ober BLE is from you SDK example "BLE_UART_APP".

Thanks in advance

Simon

Parents
  • Turn on compiler warnings, your code has a mistake in ble_nus_data_send() argument - p_data is no set up correctly.

  • Hi Turbo J,

    thank you for information.

    I would like to send sensor data with "ble_nus_data_send()". So I decided to declare a variable uint16_t, because every sensor value is stored as two byte information. Unfortunaly, "ble_nus_data_send()" needs a uint8_t, that was my fault.

    - Is it possible, to change declaration of "p_data" to uint16_t (or better an array of uint16_t) for making it work? Is nrf connect app able to visualize this?

    - what is recommend in view to current consumption? Send all data in one characteristic as array and just use one call of "ble_nus_data_send()" or use this function call for every sensor value?

    EDIT: Bluetooth connection aborts after a few seconds when changing p_data from uint8_t to uint16_t (made these changes in ble_nus.c/h)

    Thanks in advance

    Simon

Reply
  • Hi Turbo J,

    thank you for information.

    I would like to send sensor data with "ble_nus_data_send()". So I decided to declare a variable uint16_t, because every sensor value is stored as two byte information. Unfortunaly, "ble_nus_data_send()" needs a uint8_t, that was my fault.

    - Is it possible, to change declaration of "p_data" to uint16_t (or better an array of uint16_t) for making it work? Is nrf connect app able to visualize this?

    - what is recommend in view to current consumption? Send all data in one characteristic as array and just use one call of "ble_nus_data_send()" or use this function call for every sensor value?

    EDIT: Bluetooth connection aborts after a few seconds when changing p_data from uint8_t to uint16_t (made these changes in ble_nus.c/h)

    Thanks in advance

    Simon

Children
No Data
Related