Float number Formatting Options from hardware

Hi
I was wondering if it is possible to set formatting options for float numbers (/pin.#/°C) from hardware,
something like Blynk.setProperty(V1,“format”,"/pin.#/°C");
If yes, what is the required syntax
What about HTTP RESTful api
:slightly_smiling_face:

Yes, but it has nothing to do with Blynk per se… Just Arduino code that works with Serial.print() and String()
It works just as well with Blynk.virtualWrite()

int temperature = bme.readTemperature();  // get raw temperature value (normally displayed to three decimal points)
Blynk.virtualWrite(V0, String(temperature, 1) + " C");  // Display with only one decimal point and add in the C

33

Bear in mind if you send a String + “C” to the Virtual Pin it won’t Log/graph

1 Like

Thanks!
Log/graph is a prerequisite in my case.
So, i guess i shall pass it to the wishlists
:slightly_smiling_face:

Good point @ldb

But as Blynk sends all virtual pin data as strings anyhow, I figured out that ‘pre formatting’ the string (numbers only) will allow proper (and confirmed as graphable) decimal formatting at least.

  char temperature[4];
  dtostrf(bme.readTemperature(), 3, 1, temperature);
  Blynk.virtualWrite(V0, temperature);

Learned something today, didn’t know dtostrf but I think the String method would work but without “C”

Silly me… I never even tried :blush:

EDIT - Yep, works just fine on the SuperChart… and simpler too :stuck_out_tongue:

 Blynk.virtualWrite(V0, String(temperature, 1));

Just use this in the widget /pin/ °C

3 Likes