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

how to print float values using ble_app_template

i have done ble_app_template writing values from nrf app connect, in that i have send only integer values from nrf app connect

now i want to write float values from nrf app and flaot values have to print 

which part of the code i have to change

Parents
  • Bluetooth Low Energy only transmits a uint8_t byte array. However, you can convert the the float into ASCII chars and then transmit that. It should display as text in the nRF Connect app. 

    double temp = read_temperature();
    
    // Place the temperature measurement into the data array
    uint32_t err_code;
    uint8_t data[20];
    sprintf((char *)data, "Temperature: %f", temp);
    
    // Pass the data array to sd_ble_gatts_hvx() to send it to the connected central.

    Best regards

    Bjørn

Reply
  • Bluetooth Low Energy only transmits a uint8_t byte array. However, you can convert the the float into ASCII chars and then transmit that. It should display as text in the nRF Connect app. 

    double temp = read_temperature();
    
    // Place the temperature measurement into the data array
    uint32_t err_code;
    uint8_t data[20];
    sprintf((char *)data, "Temperature: %f", temp);
    
    // Pass the data array to sd_ble_gatts_hvx() to send it to the connected central.

    Best regards

    Bjørn

Children
Related