cancel
Showing results for 
Search instead for 
Did you mean: 

APP_LOG print float

JFlor.4
Associate II

Hi,

I'm usin the seed LoRa-e5 with the BME680.

I want send the output of the sensor through uart to the console. The thing is, that most of the output values are float.

I'm using the LoRaWAN_End_Node sample as base.

Regards,

Johannes

6 REPLIES 6
KnarfB
Principal III

float is omitted by default because it drags in alot of additional code. In STM32CubeIDE Project Settings > C/C++ Build Settings > MCU Settings you may check the Use float checkbox(es).

hth

KnarfB

JFlor.4
Associate II

Hi,

that was not my question.I know how enable the float settings.

To precise my question:

I use APP_LOG respectively UTIL_ADV_TRACE_COND_FSend() to write to uart.

I dont know if it is possible to write float with APP_LOG. If yes what specifier I must use, if not whats fuction can I use ?

Johannes

UTIL_ADV_TRACE_COND_FSend is implemented in https://github.com/STMicroelectronics/STM32CubeWL/blob/main/Utilities/trace/adv_trace/stm32_adv_trace.c and calls UTIL_ADV_TRACE_VSNPRINTF for formatting.

Your project defines that to tiny_vsnprintf_like, see https://github.com/STMicroelectronics/STM32CubeWL/blob/main/Projects/NUCLEO-WL55JC/Applications/LoRaWAN/LoRaWAN_End_Node/Core/Inc/utilities_conf.h

You may change that definition to vnsprintf (stdio.h) and then use the usual format specifiers.

(not tested)

hth

KnarfB

JFlor.4
Associate II

Hi,

I've tested it and it works.

Thank you

Hi @JFlor.4 

How do you got it to work?
I want to print some lines to serial but I can only print int variables.
Here's an example:
APP_LOG(TS_OFF, VLEVEL_L, "%d,%d,%d,%d,%d,", accumulator_voltage*10, accumulator_current*10, power*10, ((rightPlanetary_temperature+leftPlanetary_temperature)/2)*10, rightMotor_temperature*10);

How can I print float variables?

Tks,

https://community.st.com/t5/stm32cubeide-mcus/how-to-use-float-in-printf/td-p/323872

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..