I have a working wood boiler Aquastat, I am not trying to add Ethernet to it so it will report the temperature of the boiler to my website. I have it working, regulating and logging the temperatures as I want. However....
I was reading about the evils of the Arduino String So I was hoping that I didn't cause myself problems down the road.
Every 5 min my code calls the httpRequest() function this function uses String() extensively to convert numbers and concatenate strings.
My questions are this:
Because this is called from a function does the arduino release the memory after the function is finished?
Is there a better way to build the post string and or should I not be using the String() at all?
Thank you
Below is the function:
//My variables
float mtemp = 0.0;
long mintemp = 165;
long maxtemp = 180;
long overheat = 200;
float maxhitemp = 0.0;
float maxlowtemp = 250.0;
long overheatcnt = 0;
boolean overheatswtch = false;
boolean fanstate = true;
void httpRequest() {
client.stop();
String PutString;
PutString = "GET /boilerset.cfm";
PutString = PutString + "?curtemp=" + String(mtemp);
PutString = PutString + "&mintemp=" + String(maxlowtemp);
PutString = PutString + "&maxtemp=" + String(maxhitemp);
PutString = PutString + "&overcnt=" + String(overheatcnt);
PutString = PutString + "&fanstate=" + String(fanstate);
PutString = PutString + "&isoverheat=" + String(overheatswtch);
PutString = PutString + "&SetFanOn=" + String(mintemp);
PutString = PutString + "&SetFanOff=" + String(maxtemp);
PutString = PutString + "&SetOverHeat=" + String(overheat);
PutString = PutString + " HTTP/1.1";
Serial.println(PutString);
if (client.connect(server, 80)) {
client.println(PutString);
client.println("Host: www.mydomain.com");
client.println("User-Agent: arduino-ethernet");
client.println("Connection: close");
client.println();
}
lastConnectionTime = millis();
}