Issues with converting float to string with sprintf

Are you running this on the core or on the photon? For 0.4.0, sprintf(%f) has been removed since it adds many kilobytes to the firmware size.

The way to do this portably across all firmware versions is to use the String class:

float f = 1.23456;
String sf(f, 5);  // <--- number of decimals
Serial.print(sf);
1 Like