Skip to main content
JFlor.4
Associate II
Aug 4, 2022 8:40 PM UTC
Question

APP_LOG print float

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

This topic has been closed for replies.

6 replies

KnarfB
Super User
Aug 5, 2022 5:57 AM UTC

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
JFlor.4Author
Associate II
Aug 6, 2022 6:48 AM UTC

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

KnarfB
Super User
Aug 6, 2022 9:10 AM UTC

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
JFlor.4Author
Associate II
Aug 8, 2022 6:38 AM UTC

Hi,

I've tested it and it works.

Thank you

FPicc.1
Associate III
Apr 7, 2024 6:53 PM UTC

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,

Tesla DeLorean
Guru
Apr 7, 2024 8:22 PM UTC
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..