OK, so I changed the code around a bit but it still does not verify:
void SendData(int sensor, float temp, float humid)
{
HTTPClient http;
String dataline; //Added this to build command outside of GET call
dataline = "source=" + sensor + "&temp=" + temp + "&humid=" + humid;
http.begin("http://www.mydomain.com/php/tempreport.php");
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
int httpCode = http.GET(dataline);
if(httpCode != HTTP_CODE_OK)
{
SerialDebug.print("Error when sending to server: ");
SerialDebug.println(httpCode);
}
}
But I get this error output:
..\DHT_MONITOR.ino:250:34: error: invalid operands of types 'const char*' and 'const char [7]' to binary 'operator+'
dataline = "source=" + sensor + "&temp=" + temp + "&humid=" + humid;
^
..\DHT_MONITOR.ino:254:34: error: no matching function for call to 'HTTPClient::GET(String&)'
int httpCode = http.GET(dataline);
I have seen many examples where one can build strings containing textual representations of variables and tried to use this here, but I don't understand the error messages, can someone please explain what is the problem?