{"id":1342,"date":"2024-06-15T19:00:45","date_gmt":"2024-06-15T17:00:45","guid":{"rendered":"https:\/\/www.domotic.phdata.fr\/domotic\/?p=1342"},"modified":"2024-06-16T19:37:31","modified_gmt":"2024-06-16T17:37:31","slug":"void-setup","status":"publish","type":"post","link":"https:\/\/www.domotic.phdata.fr\/domotic\/void-setup\/","title":{"rendered":"void setup"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">3 &#8211; Void (setup)<\/h1>\n\n\n\n<ul class=\"wp-block-list\"><\/ul>\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<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=\"\">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","protected":false},"excerpt":{"rendered":"<p>3 &#8211; Void (setup)<\/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-1342","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\/1342","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=1342"}],"version-history":[{"count":2,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/posts\/1342\/revisions"}],"predecessor-version":[{"id":1344,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/posts\/1342\/revisions\/1344"}],"wp:attachment":[{"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/media?parent=1342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/categories?post=1342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.domotic.phdata.fr\/domotic\/wp-json\/wp\/v2\/tags?post=1342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}