dtostrf() alternative for concatenating a float and a string

robtillaart:
try this,

int potValue = analogRead(pinSensor);

float volts = 5*(float)potValue/1023;

char tmp[25] = "Pot Voltage = ";

dtostrf(volts,1,2, &tmp[12]);

Serial.println(tmp);



The char array is declared big enough to hold the fixed string and the float. (25)
The whole trick is to let the dtostrf add to the tmp array at the right position. (you might need to change 12 in 13 or so)

give it a try.

I'll give this a shot--I wonder if it'd be possible to write a wrapper function for dtostrf so that you could just use it in-line.
Is there a reason that adding the string literal and variable (see my first post for code) doesn't work? seems like it should from the string constructor tutorial.