This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LOG_INF doesn't print float numbers on RTT logs

I am using nRF_Connect_sdk and RTT logs.

In RTT logs, float numbers are not getting displayed.

I am getting just 0.00 for floating numbers.

Can you help me with how to display floating numbers on RTT logs?

Parents Reply Children
  • hi,

    Below is the code snippet:

     #define float_num 10.234
     
     /* Print the AIN0 values */
        int ret;
        float adc_voltage = 0;
        ret = adc_read(adc_battery_voltage, &sequence);
        LOG_INF("ADC read err: %d\n", ret);
        adc_voltage = (float)(((float)m_sample_buffer[i] / 1023.0f) * 3600.0f);
        LOG_INF("ADC raw value: %d\n", m_sample_buffer[i]);
        LOG_INF("Measured voltage: %d mV\n", (int)adc_voltage);
        LOG_INF("Float Num: %0.3f \n", float_num);
        LOG_INF("Measured voltage: %0.2f mV\n", adc_voltage);

    and here is RTT log:

    So as you can see, when I print the value in integer format, it shows in log, else it displays 0.00 on RTT logs.

Related