I need to collect a message like: "Temperature: 15.8" to send to UART. For this, I want to use sprintf. I know that this is not supported, but people solved a similar problem by converting the float to another type. I tried several options and as a result, instead of a float, I get "?". Testing at Tinkerkad.

My code:

char msg_buffer[60];
float temperature = 10.5;

void setup()
 //snprintf(msg_buffer, sizeof(msg_buffer), "%f", 3.333333);
 //dtostrf(temperature, 4, 3, charVal);
 sprintf(msg_buffer, "Temperature: %.0f", temperature);
 pinMode(13, OUTPUT);

void loop() {}

Browse other questions tagged or ask your own question.