You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
859 B

void sendData() {
if((WiFiMulti.run() == WL_CONNECTED)) {
WiFiClient client;
HTTPClient http;
char apiString[100] = "";
sprintf_P(apiString, server, windDirection, windSpeed, temperature, humidity, pressure);
Serial.print("[HTTP] begin...\n");
if (http.begin(client, apiString)) {
Serial.print("[HTTP] GET...\n");
int httpCode = http.GET();
if (httpCode > 0) {
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
} else {
Serial.printf("[HTTP} Unable to connect\n");
}
}
}