#include #include #include // id wifi const char* ssid = ""; const char* password = ""; // Adresse serveur API const char* serverURL = "https://waytec.fr/api/push.php"; void setup() { Serial.begin(115200); delay(1000); WiFi.begin(ssid, password); Serial.print("Connexion WiFi"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nConnecté au Wi-Fi"); } void loop() { if (WiFi.status() == WL_CONNECTED) { HTTPClient http; http.begin(serverURL); // Démarre la connexion HTTP http.addHeader("Content-Type", "application/json"); // Création du JSON avec les donnees qu'on veut envoyer et numero de serie et jeton secret StaticJsonDocument<200> doc; doc["ruche_id"] = "RUCHE001"; doc["token"] = "ABC123"; doc["weight"] = 43.7; doc["temperature"] = 26.2; doc["humidity"] = 60.1; doc["horodatage"] = "2025-03-24-08:12:00"; String json; serializeJson(doc, json); int httpResponseCode = http.POST(json); if (httpResponseCode > 0) { Serial.print("Réponse du serveur : "); Serial.println(httpResponseCode); String response = http.getString(); Serial.println("Corps de la réponse : " + response); } else { Serial.print("Erreur d’envoi : "); Serial.println(http.errorToString(httpResponseCode)); } http.end(); } else { Serial.println("WiFi non connecté !"); } delay(30000); // Envoi toutes les 30 secondes }