Erdin:
I do not understand your question very well.
The pH sensor gives a string, representing a floating point number ?
And your sketch used a binary 'float' for the value ?
From string to float: atof()
From float to string: dtostrf()
When the 'stream' class is used (like for the Serial and Ethernet class), you can send a string or a 'float'. In that case you don't need a conversion.
There are a number of other options.
It is often possible to use an integer. I use sometimes an integer for centigrade for the temperature.
Suppose the temperature is 23.40 and the integer 'x' is 2340
I would use this: sprintf( buffer, "%d.%02d", (x/100), (x%100));
I should have actually asked a question, instead of saying "Any Idea how?" My question actually was, how can I convert a float into sprintf and have it retain the decimal? Since I am kind of OCD about having the decimal. I am probably going to treat the whole integers as X, and the fractional numbers as Y. Then just print each value individually.
dtostrf() just gave me the same values as when I used a float directly(~1683). I think it is trying to say 6.83, because that is my buffer solution at this point. Although if you have a way of going from float to sprintf() and retain the entire number(decimals included) I would love to hear it.
MichaelMeissner:
In order to save space, the Arduino *printf libraries are compiled without floating point support (so you can't do sprintf (buf, "%f", val)).
As has been mentioned, you need to use something like dtostrf or convert it to integer, dealing with the factional digits separately.
Note, in the AVR based systems, double internally is the same size as float (in the Due, double can hold larger numbers with more mantissa bits). In both the AVR and ARM based systems, the underlying hardware does not have floating point instructions, so every floating point operation is done by calling library functions.
Interesting. Thank you for this addition. Is there anyway to download a library for Arduino to allow printf libraries to compile floats?
Yeah, separate digits seems to make sense.