{"id":1228,"date":"2024-06-15T16:49:50","date_gmt":"2024-06-15T14:49:50","guid":{"rendered":"https:\/\/www.domotic.phdata.fr\/domotic\/?p=1228"},"modified":"2024-06-16T06:41:39","modified_gmt":"2024-06-16T04:41:39","slug":"declaration-variables","status":"publish","type":"post","link":"https:\/\/www.domotic.phdata.fr\/domotic\/declaration-variables\/","title":{"rendered":"D\u00e9claration des variables"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">1 &#8211; D\u00e9claration variables<\/h1>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;lib.h>\n\n\/\/ todo--------------------------------------Variables g\u00e9n\u00e9rales ----------------------------\nconst char *PARAM_INPUT_1 = \"output\";\nconst char *PARAM_INPUT_2 = \"state\";\nint led = LED_BUILTIN; \/\/ led interne au ESP8266 fonction sur recherche connexion WIFI\nint cpt = 0;\nuint8_t wifi_ok = 1;\nint Mode_AM = false;\nString inputMessage1;\nString inputMessage2;\nint val_out = 0;\nint val_state = 0;\nint AutoManu = 0;\nString T1M, T2M; \/\/ Ajout 0 si les Mn plage horaire\n\nString mode_am = \"\";\nAsyncWebServer server(80); \/\/ Create AsyncWebServer object on port 80\n\n\/\/----------------------------------------- Afficheur LCD ---------------------------------------\n\n#define SCREEN_WIDTH 128    \/\/ OLED largeur \u00e9cran en pixels\n#define SCREEN_HEIGHT 32    \/\/ OLED hauteur \u00e9cran en pixels\n#define OLED_RESET -1       \/\/ Reset pin # (or -1 if sharing Arduino reset pin)\n#define SCREEN_ADDRESS 0x3C \/\/ L'adresse i2c -> 0x3C de l'\u00e9cran oled 128x32\nAdafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;Wire, OLED_RESET);\nuint16_t EcritureTexteBlanc = SSD1306_WHITE; \/\/ Affichage du texte en \"blanc\"\nuint16_t EcritureTexteNoir = SSD1306_BLACK;  \/\/ Affichage du texte en \"noir\"\nuint16_t FondTexteBlanc = SSD1306_WHITE;     \/\/ Affichage du fond texte en \"blanc\"\nuint16_t FondTexteNoir = SSD1306_BLACK;      \/\/ Affichage du fond texte en \"noir\"\nunsigned long timer_ecran = millis();        \/\/ Compteur gestion marche arr\u00eat \u00e9cran\nunsigned long tempo_ecran = 100000;          \/\/ valeur de la dur\u00e9e avec extinction \u00e9cran\nint ecran = 0;                               \/\/ Drapeau bascule ecran\n#define input_ecran 15                       \/\/ (D8) BP cde allumage ecran\n\n\/\/ important -------------------------------------- Gestion PCF8574 -------------------------------\nPCF8574 PCF_21(0x21); \/\/ Ajout entr\u00e9es sorties avec module PCF8574 \u00e0 l'adresse 0X21\n\n\/\/ *** les interrupteurs de commande\nuint8_t I_EV1; \/\/ Goutte a goutte avant\nuint8_t I_EV2; \/\/ Goutte a goutte arri\u00e8re\nuint8_t I_EV3; \/\/ Circuit tuyeres\nuint8_t I_EV4; \/\/ Circuit turbines\n\n\/\/ *** les sorties relais\nint S_EV1 = 3; \/\/ Sortie relais\nint S_EV2 = 2; \/\/ Sortie relais\nint S_EV3 = 1; \/\/ Sortie relais\nint S_EV4 = 0; \/\/ Sortie relais\n\n\/\/--------------------------------------Variables gestion horaire ----------------------\n\/\/***** Gestion Heures minutes EV1 tranche 1 *****\nString T1_Debut_EV1, T1_Debut_M_EV1, T1_Nb_Cycle_EV1, T1_Periode_Cycle_EV1, T1_Duree_Cycle_EV1; \/\/ D\u00e9claration des variables pour la page web\nint T1_Total_Debut_EV1, T1_Total_Fin_Cycle_EV1, T1_Cpt_Nb_Cycle_EV1;\nint T1_Debut_EV1_Int, T1_Debut_M_EV1_Int, Nb_Cycle_EV1_Int, T1_Periode_Cycle_EV1_Int, T1_Duree_Cycle_EV1_Int;\n\n\/\/------------------------ Variables temp\u00e9rature &amp; humidit\u00e9  ATH10----------------------------\n\nAdafruit_AHTX0 aht; \/\/ SCL -> D1 - SDA -> D2\nint humidite;       \/\/\nsensors_event_t humidity, temp;\n\n\/\/--------------------------------- Variables GPS --------------------------------------\n#define SerialGPS Serial                    \/\/ D\u00e9finir les entr\u00e9es TX &amp; RX du gps\nTinyGPSPlus gps;                            \/\/ Lib TinyGPS et SoftwareSerial sont l'\u0153uvre de Mikal Hart\ntime_t prevDisplay = 0;                     \/\/ lorsque l'horloge num\u00e9rique \u00e9tait affich\u00e9e\nfloat Latitude, Longitude;                  \/\/ variables GPS\nint Year, Month, Day, Hour, Minute, Second; \/\/ Mois, jour, heure, minute, seconde GPS\nint changement_heure = 2;                   \/\/ D\u00e9calage des heures par rapport \u00e0 l'heure GPS (UTC)\n\n\/\/--------------------------Variables Heure &amp; date ------------------------------------------\n\nString zs;                  \/\/ pour ajout 0 formatage ex seconde 02\nString zmn;                 \/\/ pour ajout 0 formatage ex minute 02\nString zh;                  \/\/ pour ajout 0 formatage ex heure 02\nString zmois;               \/\/ pour ajout 0 formatage ex  mois 05\nString val_heure, val_date; \/\/ calcul de l'heure au format String\"02:05:05\" ou \"10:15:25\"\nint total_mn_gps;           \/\/ Calcul le total en minute de l'heure r\u00e9elle.\n\/\/ String Val_T1EV1;           \/\/= \"test pour verification bon fonctionnement \"; \/\/ Cr\u00e9ation d'une variable pour affichage WEB de la plage horaire de EV1 (d\u00e9but fin matin )\n\/\/  String Plage_horaire_EV2;        \/\/ Cr\u00e9ation d'une variable pour affichage WEB de la plage horaire de EV2 (d\u00e9but fin matin )\nString EtatWeb_EV1, EtatWeb_EV2; \/\/ envois sur web \u00e9tat inter marche forc\u00e9e\n\n\/\/ ---------------------------------- Variables sonde pluie -----------------------------------\nString EtatPluie;\nint presence_pluie;    \/\/ si detection pluie alors \"presence_pluie\" = 1 (microswitch \"NO\" sur la sonde )<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><\/ul>\n\n\n\n<h1 class=\"wp-block-heading\"><a href=\"https:\/\/www.domotic.phdata.fr\/domotic\/declaration-variables\/#fonctions\" data-type=\"internal\" data-id=\"#fonctions\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Les fonctions<\/a><\/h1>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\"><\/div>\n<\/div>\n<\/div><\/div>\n\n\n\n<ul class=\"wp-block-list\"><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/-------------------------------------- Sous programmes -------------------------------\n\nvoid ecriture_json()\n{ \/\/ Cr\u00e9er un document JSON avec la capacit\u00e9 d\u00e9finie\n  JsonDocument doc;\n  \/\/ Assigner des valeurs aux variables\n  doc[\"T1_Debut_EV1\"] = T1_Debut_EV1;\n  doc[\"T1_Debut_M_EV1\"] = T1_Debut_M_EV1;\n  doc[\"T1_Nb_Cycle_EV1\"] = T1_Nb_Cycle_EV1;\n  doc[\"T1_Periode_Cycle_EV1\"] = T1_Periode_Cycle_EV1;\n  doc[\"T1_Duree_Cycle_EV1\"] = T1_Duree_Cycle_EV1;\n\n  \/\/ Convertir le document JSON en cha\u00eene JSON\n  String output;\n  serializeJson(doc, output);\n\n  \/\/ Enregistrer la cha\u00eene JSON dans l'EEPROM\n  for (size_t i = 0; i &lt; output.length(); ++i)\n  {\n    EEPROM.write(i, output[i]);\n  }\n  EEPROM.commit(); \/\/ N'oubliez pas de faire un commit apr\u00e8s avoir \u00e9crit dans l'EEPROM\n\n  Serial.println(\"Donn\u00e9es enregistr\u00e9es dans l'EEPROM !\");\n}\n\nvoid lecture_json()\n{\n  \/\/ Lire la cha\u00eene JSON enregistr\u00e9e dans l'EEPROM\n  String input;\n  for (int i = 0; i &lt; 200; ++i)\n  {\n    input += char(EEPROM.read(i));\n  }\n\n  \/\/ Convertir la cha\u00eene JSON en document JSON\n  JsonDocument doc;\n  DeserializationError error = deserializeJson(doc, input);\n  if (error)\n  {\n    Serial.print(\"Erreur lors de la lecture du JSON : \");\n    Serial.println(error.c_str());\n    return;\n  }\n\n  \/\/ Extraire les valeurs du document JSON\n  T1_Debut_EV1 = doc[\"T1_Debut_EV1\"].as&lt;String>();\n  T1_Debut_M_EV1 = doc[\"T1_Debut_M_EV1\"].as&lt;String>();\n  T1_Nb_Cycle_EV1 = doc[\"T1_Nb_Cycle_EV1\"].as&lt;String>();\n  T1_Periode_Cycle_EV1 = doc[\"T1_Periode_Cycle_EV1\"].as&lt;String>();\n  T1_Duree_Cycle_EV1 = doc[\"T1_Duree_Cycle_EV1\"].as&lt;String>();\n  Serial.print(\" lecture du JSON ok \");\n}\n\nString readHeure()\n{\n  if (val_heure == \"\")\n  {\n    val_heure = \"En attente signal GPS\";\n    return val_heure;\n  }\n  else\n  {\n    \/\/ Serial.println(val_heure);\n    return val_heure;\n  }\n}\n\nString readDate()\n{\n  \/\/ Serial.println(val_date);\n  return val_date;\n}\n\nString readAHTTemperature()\n{\n  aht.getEvent(&amp;humidity, &amp;temp);\n  float temperatureInt = temp.temperature;\n  if (isnan(temperatureInt))\n  {\n    Serial.println(\"Echec de la lecture du capteur AHT!\");\n    return \"--\";\n  }\n  else\n  {\n    \/\/ Serial.print(\"temp\u00e9rature :\");\n    \/\/ Serial.println(temperatureInt);\n    return String(temperatureInt);\n  }\n}\n\nString readAHTHumidity()\n{\n  \/\/ Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)\n  aht.getEvent(&amp;humidity, &amp;temp);\n  humidite = humidity.relative_humidity;\n  if (isnan(humidite))\n  {\n    Serial.println(\"Echec de la lecture du capteur AHT\");\n    return \"--\";\n  }\n  else\n  {\n    \/\/ Serial.print(\"Humidit\u00e9 :\");\n    \/\/ Serial.println(humidite);\n    return String(humidite);\n  }\n}\n\nString outputState(int output)\n{\n  if (digitalRead(output))\n  {\n    return \"checked\";\n  }\n  else\n  {\n    return \"\";\n  }\n}\n\nvoid GestionZero()\n{\n  zh = \"\";\n  if (Hour &lt; 10)\n  {\n    zh = \"0\";\n  }\n  zmn = \"\";\n  if (Minute &lt; 10)\n  {\n    zmn = \"0\";\n  }\n  zs = \"\";\n  if (Second &lt; 10)\n  {\n    zs = \"0\";\n  }\n\n  zmois = \"\";\n  if (Month &lt; 10)\n  {\n    zmois = \"0\";\n  }\n}\nvoid Affiche_gpio()\n{\n  Serial.print(\"GPIO: \");\n  Serial.print(inputMessage1);\n  Serial.print(\" - Etat: \");\n  Serial.println(inputMessage2);\n  Serial.print(\" - Mode Am \");\n  Serial.println(Mode_AM);\n}\nvoid Clignotement(int temps)\n{\n  digitalWrite(led, LOW); \/\/ led clignote en attende de synchronisation avec le WIFI\n  delay(temps);\n  digitalWrite(led, HIGH);\n  delay(temps);\n}\n\nvoid affiche_ecran()\n{\n  display.setCursor(0, 0);\n  display.clearDisplay();\n  display.print(val_date);\n  display.print(\" \");\n  display.println(val_heure);\n  display.setCursor(0, 24);\n  display.print(\"Mem libre:\");\n  display.print(ESP.getFreeHeap()); \/\/ Imprimez la quantit\u00e9 de m\u00e9moire libre\n  \/\/ display.println(\" octets\");\n  display.display();\n}\n\nString readOut()\n{\n  String output = String(val_out);\n  String state = String(val_state);\n  return output + \"&amp;\" + state;\n}\n\/\/ Replaces placeholder with button section in your web page\nString processor(const String &amp;var)\n{\n\n  if (var == \"T1_Debut_EV1\")\n  {\n    return T1_Debut_EV1;\n  }\n\n  if (var == \"T1_Debut_M_EV1\")\n  {\n    return T1_Debut_M_EV1;\n  }\n\n  if (var == \"T1_Nb_Cycle_EV1\")\n  {\n    return T1_Nb_Cycle_EV1;\n  }\n\n  if (var == \"T1_Periode_Cycle_EV1\")\n  {\n    return T1_Periode_Cycle_EV1;\n  }\n\n  if (var == \"T1_Duree_Cycle_EV1\")\n  {\n    return T1_Duree_Cycle_EV1;\n  }\n\n  if (var == \"HEURE\")\n  {\n    return readHeure();\n  }\n\n  if (var == \"DATE\")\n  {\n    return readDate();\n  }\n\n  if (var == \"TEMPERATURE\")\n  {\n    return readAHTTemperature();\n  }\n  else if (var == \"HUMIDITY\")\n  {\n    return readAHTHumidity();\n  }\n   if (var == \"BUTTONPLACEHOLDER\")\n  {\n    String buttons = \"\";\n    \/\/ buttons += \"&lt;h4>Manu\/Auto&lt;\/h4>&lt;label class=\\\"switch\\\">&lt;input type=\\\"checkbox\\\" onchange=\\\"toggleMode(this)\\\" id=\\\"modeSwitch\\\" \" + outputState(1) + \">&lt;span class=\\\"slider\\\">&lt;\/span>&lt;\/label>\";\n    buttons += \"&lt;h4>Manu\/Auto&lt;\/h4>&lt;label class=\\\"switch\\\">&lt;input type=\\\"checkbox\\\" onchange=\\\"toggleCheckbox(this)\\\" id=\\\"4\\\" id=\\\"modeSwitch\\\"\" + outputState(1) + \">&lt;span class=\\\"slider\\\">&lt;\/span>&lt;\/label>\";\n    buttons += \"&lt;div id=\\\"manualControls\\\">\";\n    buttons += \"&lt;h4>Arret\/Marche EV1&lt;\/h4>&lt;label class=\\\"switch\\\">&lt;input type=\\\"checkbox\\\" onchange=\\\"toggleCheckbox(this)\\\" id=\\\"3\\\" \" + outputState(1) + \">&lt;span class=\\\"slider\\\">&lt;\/span>&lt;\/label>\";\n    buttons += \"&lt;h4>Arret\/Marche EV2&lt;\/h4>&lt;label class=\\\"switch\\\">&lt;input type=\\\"checkbox\\\" onchange=\\\"toggleCheckbox(this)\\\" id=\\\"2\\\" \" + outputState(1) + \">&lt;span class=\\\"slider\\\">&lt;\/span>&lt;\/label>\";\n    buttons += \"&lt;h4>Arret\/Marche EV3&lt;\/h4>&lt;label class=\\\"switch\\\">&lt;input type=\\\"checkbox\\\" onchange=\\\"toggleCheckbox(this)\\\" id=\\\"1\\\" \" + outputState(1) + \">&lt;span class=\\\"slider\\\">&lt;\/span>&lt;\/label>\";\n    buttons += \"&lt;h4>Arret\/Marche EV4&lt;\/h4>&lt;label class=\\\"switch\\\">&lt;input type=\\\"checkbox\\\" onchange=\\\"toggleCheckbox(this)\\\" id=\\\"0\\\" \" + outputState(1) + \">&lt;span class=\\\"slider\\\">&lt;\/span>&lt;\/label>\";\n    buttons += \"&lt;\/div>\";\n\n    return buttons;\n  }\n  return String();\n}\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Void (setup)<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void setup()\n{\n\n  \/\/ Serial port for debugging purposes\n  Serial.begin(9600);\n  EEPROM.begin(512);\n  PCF_21.begin(); \/\/ Entr\u00e9es sortie sup.\n  \/\/-------------------------------------- Gestion AHT10 -------------------------------\n  aht.begin();\n\n  \/\/---------------------------------------- Gestion GPS -------------------------------\n  SerialGPS.begin(9600);\n\n  \/\/--------------------------- Gestion \u00e9cran OLED -----------------------------\n\n  pinMode(input_ecran, INPUT_PULLUP);\n\n  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))\n  {\n    Serial.println(F(\"SSD1306 allocation erreur\"));\n    for (;;)\n      ; \/\/ Ne continuez pas, bouclez pour toujours\n  }\n  display.clearDisplay();\n  display.drawBitmap(0, 0, logo_arrosage, 128, 64, 1); \/\/ affiche le logo arrosage sur l'\u00e9cran Oled\n  display.display();\n  delay(1000); \/\/ Pause de 1 secondes\n\n  display.setCursor(0, 0); \/\/ D\u00e9placement du curseur en position (0,0), angle sup\u00e9rieur gauche\n  display.clearDisplay();\n  display.setTextColor(EcritureTexteBlanc, FondTexteNoir);\n  display.println(\"Recherche borne Wifi\");\n\n  \/\/-------------------------------------- Gestion Wi-Fi -------------------------------\n  WiFi.begin(ssid, password);\n  Serial.print(\"Recherche borne Wifi\");\n  while (WiFi.status() != WL_CONNECTED)\n  {\n    Clignotement(500);\n    Serial.print(\".\");\n    display.print(\".\");\n    display.display();\n    cpt++;\n    if (cpt == 1000)\n    {\n      wifi_ok = 0;\n      return; \/\/ Sortir de la boucle si non connexion au bout de x tentatives}\n    }\n  }\n\n  Serial.print(\"Connection \u00e0 l'adresse  IP: \");\n  Serial.println(WiFi.localIP());\n  WiFi.printDiag(Serial); \/\/ imprimer les principales informations du wifi\n  Serial.println();\n\n  \/\/ ---------- Etat connection du wifi sur ecran Oled -------------\n\n  display.setCursor(0, 0);\n  display.clearDisplay();\n  display.display();\n  display.println(WiFi.localIP());\n  display.display();\n\n  lecture_json(); \/\/ lire les valeurs des heure et incorporer dans les variables\n\n  \/\/  ---- Page web bouton &amp; varables (heure\/date ...)  Initialisation du serveur Web ------------------\n\n  server.on(\"\/\", HTTP_POST, [](AsyncWebServerRequest *request) { \/\/ HTTP POST ssid value\n  });\n\n  server.on(\"\/get_out\", HTTP_GET, [](AsyncWebServerRequest *request)\n            { request->send_P(200, \"text\/plain\", readOut().c_str()); });\n\n  server.on(\"\/\", HTTP_GET, [](AsyncWebServerRequest *request)\n            { request->send_P(200, \"text\/html\", index_html, processor); });\n  server.on(\"\/val_heure\", HTTP_GET, [](AsyncWebServerRequest *request)\n            { request->send_P(200, \"text\/plain\", readHeure().c_str()); });\n  server.on(\"\/val_date\", HTTP_GET, [](AsyncWebServerRequest *request)\n            { request->send_P(200, \"text\/plain\", readDate().c_str()); });\n  server.on(\"\/temperatureInt\", HTTP_GET, [](AsyncWebServerRequest *request)\n            { request->send_P(200, \"text\/plain\", readAHTTemperature().c_str()); });\n  server.on(\"\/humidite\", HTTP_GET, [](AsyncWebServerRequest *request)\n            { request->send_P(200, \"text\/plain\", readAHTHumidity().c_str()); });\n  server.on(\"\/update\", HTTP_GET, [](AsyncWebServerRequest *request)\n            {\n    if (request->hasParam(PARAM_INPUT_1) &amp;&amp; request->hasParam(PARAM_INPUT_2))\n    {\n      inputMessage1 = request->getParam(PARAM_INPUT_1)->value();\n      inputMessage2 = request->getParam(PARAM_INPUT_2)->value();\n    }\n\n    Affiche_gpio();\n\n    request->send(200, \"text\/plain\", \"OK\"); });\n\n  \/\/  ----------------------------- Formulaire -------------------------------\n  server.on(\"\/\", HTTP_GET, [](AsyncWebServerRequest *request)\n            {\n              request->send_P(200, \"text\/html\", index_html); \/\/ Envoyer la page HTML depuis le fichier index_html.h\n            });\n\n  server.on(\"\/submit\", HTTP_POST, [](AsyncWebServerRequest *request)\n            {\n    if (request->hasParam(\"T1_Debut_EV1\", true)) {\n      T1_Debut_EV1 = request->getParam(\"T1_Debut_EV1\", true)->value();\n    }\n if (request->hasParam(\"T1_Debut_M_EV1\", true)) {\n      T1_Debut_M_EV1 = request->getParam(\"T1_Debut_M_EV1\", true)->value();\n    }\n    if (request->hasParam(\"T1_Nb_Cycle_EV1\", true)) {\n      T1_Nb_Cycle_EV1 = request->getParam(\"T1_Nb_Cycle_EV1\", true)->value();\n    }\n    if (request->hasParam(\"T1_Periode_Cycle_EV1\", true)) {\n      T1_Periode_Cycle_EV1 = request->getParam(\"T1_Periode_Cycle_EV1\", true)->value();\n    }\n    if (request->hasParam(\"T1_Duree_Cycle_EV1\", true)) {\n      T1_Duree_Cycle_EV1 = request->getParam(\"T1_Duree_Cycle_EV1\", true)->value();\n    }\n\n    String response = \"&lt;!DOCTYPE html>&lt;html lang=\\\"fr\\\">&lt;head>&lt;meta charset=\\\"UTF-8\\\">&lt;meta name=\\\"viewport\\\" content=\\\"width=device-width, initial-scale=1.0\\\">&lt;title>R\u00e9sultat de l'Arrosage&lt;\/title>&lt;\/head>&lt;body>\";\n    response += \"&lt;div style=\\\"background-color: blue; padding: 10px;\\\">\";\n    response += \"&lt;h3 style=\\\"color: white;\\\">Zone 1&lt;\/h3>\";\n    response += \"&lt;p style=\\\"color: white;\\\">Heure de d\u00e9marrage: \" + T1_Debut_EV1 + \"&lt;\/p>\";\n    response += \"&lt;p style=\\\"color: white;\\\">Minute de d\u00e9marrage: \" + T1_Debut_M_EV1 + \"&lt;\/p>\";\n    response += \"&lt;p style=\\\"color: white;\\\">Nombre d'arrosage: \" + T1_Nb_Cycle_EV1 + \"&lt;\/p>\";\n    response += \"&lt;p style=\\\"color: white;\\\">Intervalle d'arrosage: \" + T1_Periode_Cycle_EV1 + \"&lt;\/p>\";\n    response += \"&lt;p style=\\\"color: white;\\\">Dur\u00e9e d'arrosage: \" + T1_Duree_Cycle_EV1 + \"&lt;\/p>\";\n    response += \"&lt;\/div>\";\n    response += \"&lt;br>&lt;br>&lt;a href=\\\"\/\\\" style=\\\"background-color: white; color: blue; padding: 10px 20px; text-decoration: none; border: 1px solid blue;\\\">Retour&lt;\/a>\";\n    response += \"&lt;\/body>&lt;\/html>\";\n    ecriture_json();\n    request->send(200, \"text\/html\", response); });\n\n  \/\/ Start server\n  server.begin();\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Void (loop)<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void loop()\n{\n  while (SerialGPS.available() > 0)\n  {\n    if (gps.encode(SerialGPS.read()))\n    {\n      if (gps.date.isValid())\n      {\n        Day = gps.date.day();\n        Month = gps.date.month();\n        Year = gps.date.year();\n      }\n      if (gps.time.isValid())\n      {\n        Hour = gps.time.hour() + changement_heure; \/\/ ajuste UTC (heure hivers +1 - heure \u00e9t\u00e9 +2)\n        Minute = gps.time.minute();\n        Second = gps.time.second();\n      }\n      GestionZero(); \/\/ Ajout 0 si var &lt; 10\n\n      val_heure = zh + String(Hour) + \":\" + zmn + String(Minute) + \":\" + zs + String(Second);\n      val_date = String(Day) + \"\/\" + zmois + String(Month) + \"\/\" + String(Year);\n      total_mn_gps = (Hour) * 60 + Minute; \/\/ calcul nb total en minutes des heures du GPS\n    }\n  }\n\n  \/\/ ------------------------- Conversion des heures en minutes &amp; calcul tranche d\u00e9but fin --------------------------\n  if (T1_Debut_EV1 != \"\")\n  {\n    T1_Debut_EV1_Int = T1_Debut_EV1.toInt();\n  }\n\n  if (T1_Debut_M_EV1 != \"\")\n  {\n    T1_Debut_M_EV1_Int = T1_Debut_M_EV1.toInt();\n  }\n\n  if (T1_Nb_Cycle_EV1 != \"\")\n  {\n    Nb_Cycle_EV1_Int = T1_Nb_Cycle_EV1.toInt();\n  }\n\n  if (T1_Periode_Cycle_EV1 != \"\")\n  {\n    T1_Periode_Cycle_EV1_Int = T1_Periode_Cycle_EV1.toInt();\n  }\n\n  if (T1_Duree_Cycle_EV1 != \"\")\n  {\n    T1_Duree_Cycle_EV1_Int = T1_Duree_Cycle_EV1.toInt();\n  }\n\n  \/\/ ----------------------------------- traitement des tranches \u00e0 afficher sur la page web -----------------------------\n\n  T1M = \"\"; \/\/ Ajout 0 si mn entre 0et 9\n  if (T1_Debut_M_EV1_Int &lt; 10)\n  {\n    T1M = \"0\";\n  }\n  T1_Total_Debut_EV1 = T1_Debut_EV1_Int * 60 + T1_Debut_M_EV1_Int + T1_Periode_Cycle_EV1_Int * T1_Cpt_Nb_Cycle_EV1; \/\/ Conversion des heures en minutes\n  T1_Total_Fin_Cycle_EV1 = T1_Total_Debut_EV1 + T1_Duree_Cycle_EV1_Int;                                             \/\/ Calcul de la fin des cycles\n  if (T1_Total_Fin_Cycle_EV1 == total_mn_gps &amp;&amp; T1_Cpt_Nb_Cycle_EV1 &lt; Nb_Cycle_EV1_Int)                             \/\/ A la fin du cycle calcul le cycle suivant\n  {\n    T1_Cpt_Nb_Cycle_EV1++;\n  }\n\n  if (T1_Cpt_Nb_Cycle_EV1 == Nb_Cycle_EV1_Int)\n  {\n    T1_Cpt_Nb_Cycle_EV1 = 0;\n  }\n  \/\/------------------------------Gestion des cde de sortie \u00e9lectrovannes (PCF8475) -----------------------------\n  I_EV1 = PCF_21.read(7); \/\/ inter marche\/arr\u00eat forc\u00e9e EV1\n  I_EV2 = PCF_21.read(6); \/\/ inter march\/arr\u00eate forc\u00e9e EV2\n  I_EV3 = PCF_21.read(5); \/\/ inter marche\/arr\u00eat forc\u00e9e EV3\n  I_EV4 = PCF_21.read(4); \/\/ inter marche\/arr\u00eat forc\u00e9e EV4\n\n  if (inputMessage1 == \"4\" &amp;&amp; inputMessage2 == \"0\")\n  {\n    Mode_AM = 0;\n    inputMessage1 == \"\";\n  }\n\n  if (inputMessage1 == \"4\" &amp;&amp; inputMessage2 == \"1\")\n  {\n    Mode_AM = 1;\n    inputMessage1 == \"\";\n  }\n\n  \/\/* ----------------------- Marche\/Arr\u00eat mode manuel -----------------------\n  if (Mode_AM == 0)\n  {\n      val_out = 5; \/\/! permet de na pas activer les sortie de 0 \u00e0 4 (essai)\n      val_state = 0;\n    if (inputMessage1 == \"3\")\n    {\n      if (I_EV1 == 1 || inputMessage2 == \"1\")\n      {\n        PCF_21.write(S_EV1, 0); \/\/ Marche EV1\n      }\n      else if (I_EV1 == 0 || inputMessage2 == \"0\")\n      {\n        PCF_21.write(S_EV1, 1); \/\/  Arr\u00eat EV1\n      }\n    }\n\n    if (inputMessage1 == \"2\")\n    {\n      if (I_EV2 == 1 || inputMessage2 == \"1\")\n      {\n        PCF_21.write(S_EV2, 0); \/\/ Marche EV2\n      }\n      else if (I_EV2 == 0 || inputMessage2 == \"0\")\n      {\n        PCF_21.write(S_EV2, 1); \/\/  Arr\u00eat EV2\n      }\n    }\n    if (inputMessage1 == \"1\")\n    {\n      if (I_EV3 == 1 || inputMessage2 == \"1\")\n      {\n        PCF_21.write(S_EV3, 0); \/\/ Marche EV3\n      }\n      else if (I_EV3 == 0 || inputMessage2 == \"0\")\n      {\n        PCF_21.write(S_EV3, 1); \/\/  Arr\u00eat EV3\n      }\n    }\n    if (inputMessage1 == \"0\")\n    {\n      if (I_EV4 == 1 || inputMessage2 == \"1\")\n      {\n        PCF_21.write(S_EV4, 0); \/\/ Marche EV4\n      }\n      else if (I_EV4 == 0 || inputMessage2 == \"0\")\n      {\n        PCF_21.write(S_EV4, 1); \/\/  Arr\u00eat EV4\n      }\n    }\n  }\n\n  \/\/* ----------------------- Marche\/Arr\u00eat mode automatique -----------------------\n  if (Mode_AM == 1)\n  {\n    \/\/ if (((total_mn_gps >= T1_Total_Debut_EV1) &amp;&amp; (total_mn_gps &lt; T1_Total_Fin_Cycle_EV1)))\n    if (total_mn_gps >= T1_Total_Debut_EV1 &amp;&amp; total_mn_gps &lt; T1_Total_Fin_Cycle_EV1)\n    {\n      PCF_21.write(S_EV1, 0); \/\/ marche auto\n      val_out = 3;\n      val_state = 1;\n    }\n    else\n    {\n      PCF_21.write(S_EV1, 1); \/\/ arr\u00eat auto\n      val_out = 3;\n      val_state = 0;\n    }\n  }\n\n  affiche_ecran();\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1 &#8211; D\u00e9claration variables Les fonctions Void (setup) Void (loop)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"elementor_canvas","format":"standard","meta":{"_eb_attr":"","ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","_jetpack_memberships_contains_paid_content":false,"ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[16],"tags":[15],"class_list":["post-1228","post","type-post","status-publish","format-standard","hentry","category-blog","tag-arrosage","entry"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/posts\/1228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/comments?post=1228"}],"version-history":[{"count":20,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/posts\/1228\/revisions"}],"predecessor-version":[{"id":1319,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/posts\/1228\/revisions\/1319"}],"wp:attachment":[{"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/media?parent=1228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/categories?post=1228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/tags?post=1228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}