Skip to main content
JFlor.4
Associate II
August 4, 2022
Question

APP_LOG print float

  • August 4, 2022
  • 6 replies
  • 2655 views

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
August 5, 2022

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
August 6, 2022

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
August 6, 2022

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
August 8, 2022

Hi,

I've tested it and it works.

Thank you

FPicc.1
Associate III
April 7, 2024

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
April 7, 2024
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..