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
  • But on nrf connect app the data is shown as different characters, for example "�" or "@".

     If you are sending the value 64 / 0x40, then this will be displayed as @.  See this link http://www.asciitable.com/

  • If you are sending the value 64 / 0x40, then this will be displayed as @.

    hmm, unfortunaly not. I get "[".

    I´ve done the following:

    uint8_t test = 64;
    
                            uint32_t       err_code2; 
                            uint16_t length = (uint16_t)1;
                            err_code2 = ble_nus_data_send(&m_nus, test, length, 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);
                            }

    In line five I got a warning while compiling. How can I see, whats wrong?

  • Try

    uint8_t test = 64;
    
    uint32_t err_code2; 
    uint16_t length = (uint16_t)1;
    
    err_code2 = ble_nus_data_send(&m_nus, &test, &length, 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);
    }

  • Hi Sigurd,

    thank you, this works!! But isn´t it possible, to send more than just one just one single byte per transmission?

    For example here I would like to send 12 bytes (array of type uint8_t with 12 elements). But then I get a warning while compiling.

    uint8_t ergebnis[12];
    
        for (int k=0;k<12;k++){
       
            ergebnis[k]=m_sample[k];
        }
    
      printf(" ACCEL_X:  %u", (unsigned int)ergebnis);
    
                  
                            // Daten über Bluetooth senden
                            
    nrf_delay_ms(500); 
    uint32_t err_code2; 
    uint16_t length = (uint16_t)12;
    
    err_code2 = ble_nus_data_send(&m_nus, &ergebnis, &length, 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);
    }

  • simon1516 said:
    But isn´t it possible, to send more than just one just one single byte per transmission?

     It's possible to send more than one byte.

    Since "ergebnis" is a array, the send function should then look like this:

    err_code2 = ble_nus_data_send(&m_nus, ergebnis, &length, m_conn_handle);

Reply Children
No Data
Related