I want to send 2 variables, temperature and humidity but i receive an error while compiling in arduino IDE. The code is this:
void httpRequest() {
// close any connection before send a new request.
// This will free the socket on the WiFi shield
client.stop();
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
String PostData[2] = String("[{\"variable\":\"temperature\", \"value\":") + String(value_string_temp)+ String(",\"unit\":\"C\"}","{\"variable\":\"humidity\", \"value\":") + String(value_string_hum)+ String(",\"unit\":\"Bar\"}]");
String Dev_token = String("Device-Token: ")+ String(Device_Token);
if (client.connect(server,80)) { // we will use non-secured connnection (HTTP) for tests
Serial.println("connected to server");
// Make a HTTP request:
client.println("POST /data? HTTP/1.1");
client.println("Host: api.tago.io");
client.println("_ssl: false"); // for non-secured connection, use this option "_ssl: false"
client.println(Dev_token);
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(PostData.length());
client.println();
client.println(PostData);
// note the time that the connection was made:
lastConnectionTime = millis();
}
else {
// if you couldn’t make a connection:
Serial.println(“connection failed”);
}
}