Are there limits on string length in Arduino? -


i've been trying hours put simple json object string on arduino send raspberry pi running node.

i cannot seem build string. have tried building string in 1 go:

"{" + string1 + "," + string2 + "," + string3 + "}" etc... 

i've tried using string.replace function. each time end bit of string, or none @ all. below code shows what's happening:

string msg = "{ \"message\" : \"statusupdate\", "; string active = " \"active\" : token, "; string intaketemp = " \"intaketemp\" : token, "; string intakehumid = " \"intakehumid\" : token, "; string exhausttemp = " \"exhausttemp\" : token, "; string exhausthumid = " \"exhausthumid\" : token, "; string targethumid = " \"targethumid\" : token, "; string completed = " \"taskcompleted\" : token }";   if(isactive)   active.replace("token","true"); else   active.replace("token","false");  intaketemp.replace("token",floattostring(intaketemperature,0)); intakehumid.replace("token",floattostring(intakehumidity,0)); exhausttemp.replace("token",floattostring(exhausttemperature,0)); exhausthumid.replace("token",floattostring(exhausthumidity,0)); targethumid.replace("token",floattostring(targethumidity,0));  if(taskfinished)   taskcompleted.replace("token","true"); else   taskcompleted.replace("token","false");      string body = msg;   serial.println(body);   body += active;   serial.println(body);   body += intaketemp;   serial.println(body);   body += intakehumid;   serial.println(body);   body += exhausttemp;   serial.println(body);   body += exhausthumid;   serial.println(body);   body += targethumid;   serial.println(body);   body += taskcompleted;   serial.println(body); 

you can see last bit of code above string being built, i'm spitting out serial monitor. however, here serial output:

{ "message" : "statusupdate",  { "message" : "statusupdate",  "active" : false,  { "message" : "statusupdate",  "active" : false,  "intaketemp" : 0.0,  { "message" : "statusupdate",  "active" : false,  "intaketemp" : 0.0,  "intakehumid" : 0.0,  { "message" : "statusupdate",  "active" : false,  "intaketemp" : 0.0,  "intakehumid" : 0.0,  "exhausttemp" : 0.0,  { "message" : "statusupdate",  "active" : false,  "intaketemp" : 0.0,  "intakehumid" : 0.0,  "exhausttemp" : 0.0,  { "message" : "statusupdate",  "active" : false,  "intaketemp" : 0.0,  "intakehumid" : 0.0,  "exhausttemp" : 0.0,  { "message" : "statusupdate",  "active" : false,  "intaketemp" : 0.0,  "intakehumid" : 0.0,  "exhausttemp" : 0.0,  

is there limit string length? haven't found mention of such limits in docs. there's not else sketch except standard ethernet library , code send via http request (from sample project).

any idea might happening?

edit: ok, i've shortened string so:

string msg = "{ \"m\" : \"status\", "; string active = " \"a\" : token, "; string intaketemp = " \"it\" : token, "; string intakehumid = " \"ih\" : token, "; string exhausttemp = " \"et\" : token, "; string exhausthumid = " \"eh\" : token, "; string targethumid = " \"th\" : token, "; string dryerjustfinished = " \"f\" : token }"; 

and sure enough, it's started work:

{ "m" : "status",  { "m" : "status",  "a" : false,  { "m" : "status",  "a" : false,  "it" : 0.0,  { "m" : "status",  "a" : false,  "it" : 0.0,  "ih" : 0.0,  { "m" : "status",  "a" : false,  "it" : 0.0,  "ih" : 0.0,  "et" : 0.0,  { "m" : "status",  "a" : false,  "it" : 0.0,  "ih" : 0.0,  "et" : 0.0,  "eh" : 0.0,  { "m" : "status",  "a" : false,  "it" : 0.0,  "ih" : 0.0,  "et" : 0.0,  "eh" : 0.0,  "th" : 0.0,  { "m" : "status",  "a" : false,  "it" : 0.0,  "ih" : 0.0,  "et" : 0.0,  "eh" : 0.0,  "th" : 0.0,  "f" : false } 

which means there limitation. memory limitation?

by way, hardware arduino uno r3

atmel processor has limited memory management easy end fragmented memory. remember runtime stack , heap limited.

static string can put progmem also

there freememory function on arduino.cc show how free memory have.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -