summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlapa <vlapa@ya.ru>2026-06-13 21:07:04 +0300
committervlapa <vlapa@ya.ru>2026-06-13 21:07:04 +0300
commit47ddc975c2a3d70a6773f7696d29f43a5adb86fe (patch)
tree8d93df25a56bb04b9793b1b9a50d2592d9bff154
First
-rw-r--r--.gitignore2
-rw-r--r--platformio.ini17
-rw-r--r--src/main.cpp88
3 files changed, 107 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b9f3806
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.pio
+.vscode
diff --git a/platformio.ini b/platformio.ini
new file mode 100644
index 0000000..5f27019
--- /dev/null
+++ b/platformio.ini
@@ -0,0 +1,17 @@
+; PlatformIO Project Configuration File
+;
+; Build options: build flags, source filter
+; Upload options: custom upload port, speed and extra flags
+; Library options: dependencies, extra library storages
+; Advanced options: extra scripting
+;
+; Please visit documentation for the other options and examples
+; https://docs.platformio.org/page/projectconf.html
+
+[env:d1_mini]
+platform = espressif8266
+board = d1_mini
+framework = arduino
+
+monitor_speed = 115200
+upload_speed = 460800
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..f30686f
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,88 @@
+#include <ESP8266WiFi.h>
+#include <ESP8266HTTPClient.h>
+#include <WiFiClient.h>
+
+const char *ssid = "link";
+const char *password = "dkfgf#*12091997";
+const char *host = "89.110.92.137";
+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() {} \ No newline at end of file