Complicated value display outputs - rounding a float

so if i have a float that i want to send to a value display widget to say something like

“base is X.X’C cooler” were X.X is a float

so i used this:

Blynk.virtualWrite(V55, "base is ", inletDifference, "'C cooler"); //inlet vs outlet calculation

and it outputs:

base is 5.613’C cooler

but i want it to output

base is 5.6’C cooler

is there an easy way to do this?

You need to use labeled display with formatting options and send only inletDifference - http://docs.blynk.cc/#widgets-displays-labeled-value and you may use /pin.#/ formatting.

1 Like

i want to use words in it - i can just type these into the labeled widget?

SUPERB!

Exactly.

cool thanks!


Labeled Value
Displays incoming data in a formatted way. It is a better version of ‘Value Display’ where you can add suffixes and prefixes on the app side, with no coding on the hardware.

Formatting options
For example: your sensor sends value of 12.6789 to Blynk application. [insert:]The following [delete:]Next formatting options are supported:


(just a couple of typos and syntax suggestions noted on the help page)

Or use sprintf to do a formatted copy to a string and do a blynk.virtualWrite of that string.

1 Like

well that sounds terribly complicated!

but i might have to use this becuase i want the display to tell me

  1. warmest
  2. coolest
  3. driest

so off i go to learn how to sprintf…

Quite simple really.

char inletDifferenceMsg[44];
sprintf(inletDifferenceMsg, "base is %02.2f'C cooler", inletDifference);
Blynk.virtualWrite(V55, inletDifferenceFormatted); //inlet vs outlet calculation