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

How to print floats with NRF_LOG macros

Trying to print floats with NRF_LOG functions always prints a value of 0.00000.

E.g.

float value = 123.456; NRF_LOG_ERROR( "Float %f\r\n", value );

prints:

ERROR:Float 0.00000

but NRF_LOG_ERROR( "Float %u\r\n", (uint16_t)value );

prints

ERROR:Float 123

I have the _printf_float linker option enabled. It's clear from the output that something is recognizing the float param and handling it. How can I print floats to the LOG output?

Printing a char* string variable with "%s" also fails to compile.

Related