Converting float to char

Hey there,

I have a Arduino Uno and I just want to convert a float to char. My code is


char hum[6];

int n = sprintf(hum, "%f", 56.98);

Serial.println(hum);
Serial.println(n);

And it just prints:

?
1

I don't understand what I'm doing wrong.

sprintf(hum, "%d", 356);

works normally.

Help is very welcome! :slight_smile:

dtostrf()

sprintf() does not support floats to save space. try dtostrf().

AVR docs on dtostrf()