#include #include #include const char *ssid = ""; const char *password = ""; const char *host = ""; const int port = 8000; const char *sensor_1 = "Home_bme280_balkon"; const char *sensor_2 = "Villa_bme280_base1"; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } if (WiFi.status() == WL_CONNECTED) { Serial.println("\nOK !"); } //===================================================== String sensorKeys = sensor_1; sensorKeys += ","; sensorKeys += sensor_2; WiFiClient client; HTTPClient http; String url = "http://" + String(host) + ":" + String(port) + "/"; Serial.println("Sending POST to: " + url); Serial.println("Data: " + sensorKeys); http.begin(client, url); http.addHeader("Content-Type", "text/plain"); http.setTimeout(10000); // Отправляем POST с нашими ключами int httpCode = http.POST(sensorKeys); // Анализируем ответ if (httpCode > 0) { Serial.printf("Response code: %d\n", httpCode); if (httpCode == HTTP_CODE_OK) { String payload = http.getString(); Serial.println("Server response: \n" + payload); } } else { Serial.printf("POST failed, error: %s\n", http.errorToString(httpCode).c_str()); } http.end(); //===================================================== // if (client.connect(host, 8000)) // { // client.println("GET / HTTP/1.1"); // client.print("Host: "); // client.println(host); // client.println("Connection: close"); // client.println(); // Serial.println("Отправили запрос"); // delay(500); // while (client.available()) // { // String line = client.readStringUntil('\r'); // Serial.print(line); // } // } } void loop() {}