am working with and Arduino nano and according to this, I can append strings to numbers by doing: stringThree = stringOne + 123; but
when I do:
sensorValue = analogRead(A0);
String x1 = "{\"Volt\":"+sensorValue;
Serial.print(x1);
I get this unwanted output!
=gëÙrïË:_³ß»þ™¹Æ3+Ç#ÿ¼¿.Õ[Oû/g¯>ïÿ1þ†lú0
but doing this it works fine.
sensorValue = analogRead(A0);
String x1 = "{\"Volt\":";
x1 += sensorValue;
Serial.print(x1);
"Volt":646
why?
Stringconcatenation uses dynamic allocation, which can be problematic on small-memory devices. Anyhow, concatentation isn't needed for output -- see eg my answer to questions/33319 forStreamingalternative, and my answer to questions/16122 for another example. – James Waldby - jwpat7 Feb 07 '17 at 17:55