Float to String conversion

OK, this must be just me being dumb on a Monday, but here it goes…

On other Arduino platforms I can do:

float sensorValue = sensor.readValue();
String sensorString = String(sensorValue);

Then I can send the float value converted to a string off to the Cloud (in this case ThingSpeak). However, for some strange reason, when I do this with the Dash it gives me no error message, but just has a null value for “sensorString” and nothing to send over.

Now, I can successfully do this:

 int sensorValue = sensor.readValue();
 String sensorString = String(sensorValue);

Then I have an integer converted to a string and I can send that along. That’s not a huge problem for me, but it would be nice to have that extra precision and really makes no sense to me!

?!?!

Hey, Chris,

Same issue here (posted in “Library Compatibility” (https://community.konekt.io/t/library-compatibility/94/6)) since it seems to relate to Dash not having the functionality of my beloved dtostrf() function, which can directly do what you and I need on a plain-Jane Arduino Uno. Sigh…

Glad to hear it isn’t just me losing my mind! I’m reusing code that works on Arduino Mega, Arduino Mini Pro and ESP8266 so I couldn’t figure out what was going on. I can live with integers for now, but when I try to send GPS data over that will need long decimal points or it won’t give me much of a position fix! :slight_smile:

HA! What’s the GPS precision for an integer? 500 miles or so? :sunglasses:

Indeed that float into string capability would be most welcome.

We just released a new arduino integration that should fix this. Your arduino IDE should detect it automatically

1 Like

Thanks very much! I will check it out tonight.

Thanks, Reuben. I will make good use of it.

Just tested it and it works fine! Thanks for getting this done so quickly!

Five fields of floating point data now heading to the Cloud in a single string, and on to a happy home in Thingspeak.