twilkers:
having trouble printf a float. does anyone know a better way to do this than below?
How to sprintf a float? - Syntax & Programs - Arduino Forum
thx
Sorry about that, I forgot that the Arduino does not support floats in printf statements. It was decided to exclude support for floats due to code bloat in the format routines.
Here is a solution from StackOverFlow Arduino Float to Char
char str_temp[6];
/* 4 is mininum width, 2 is precision; float value is copied onto str_temp*/
dtostrf(temp, 4, 2, str_temp);
sprintf(temperature,"%s F", str_temp);
If you really want to get tricky, dtostrf returns a pointer to its destination string, so this should work:
char buf[60];
uint8_t b=sprintf_P(buf,PSTR("this is a big float %s"),dtostrf(Temp,9,6,(char*)buf[50]));
// this assumes that buf[50..59] are not being used already. In this explicit case, only the
// first 20 character are in use before the 'string' is appended.
Chuck.