noam76

Main.ino

Jul 23rd, 2021
780
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* New with XML */
  2. #include <Arduino.h>
  3. #include <Wire.h>
  4. #include <ESP8266WiFi.h>
  5. #include <DNSServer.h>
  6. #include <ESP8266WebServer.h>
  7. #include <WiFiManager.h>
  8. #include <ArduinoJson.h>
  9. #include <FS.h>
  10. #include <LittleFS.h>
  11. #include "Adafruit_MCP23017.h"
  12.  
  13. Adafruit_MCP23017 mcp;
  14.  
  15. #define S0 D0   /* Assign Multiplexer pin S0 connect to pin D0 of NodeMCU */
  16. #define S3 D3   /* Assign Multiplexer pin S3 connect to pin D3 of NodeMCU */
  17. #define S1 D7   /* Assign Multiplexer pin S1 connect to pin D1 of NodeMCU */
  18. #define S2 D8   /* Assign Multiplexer pin S2 connect to pin D2 of NodeMCU */
  19. #define SIG A0  /* Assign SIG pin Analog output for all Multiplexer's channels to A0 of NodeMCU */
  20.  
  21. #define PUMP D6
  22. #define solenoid0 0   //Connect Solenoid0 for Sens0 GPA0 on mcp
  23. #define solenoid1 1   //Connect Solenoid1 for Sens1 GPA1 on mcp
  24. #define solenoid2 2   //Connect Solenoid2 for Sens2 GPA2 on mcp
  25. #define solenoid3 3   //Connect Solenoid3 for Sens3 GPA3 on mcp
  26. #define solenoid4 4   //Connect Solenoid4 for Sens4 GPA4 on mcp
  27. #define solenoid5 5   //Connect Solenoid5 for Sens5 GPA5 on mcp
  28. #define solenoid6 6   //Connect Solenoid6 for Sens6 GPA6 on mcp
  29. #define solenoid7 7   //Connect Solenoid7 for Sens7 GPB0 on mcp
  30. #define solenoid8 8   //Connect Solenoid8 for Sens8 GPB1 on mcp
  31. #define solenoid9 9   //Connect Solenoid9 for Sens9 GPB2 on mcp
  32. #define solenoid10 10 //Connect Solenoid10 for Sens10 GPB3 on mcp
  33. #define solenoid11 11 //Connect Solenoid11 for Sens11 GPB4 on mcp
  34. #define solenoid12 12 //Connect Solenoid11 for Sens11 GPB5 on mcp
  35. #define solenoid13 13 //Connect Solenoid11 for Sens11 GPB6 on mcp
  36. #define solenoid14 14 //Connect Solenoid11 for Sens11 GPB7 on mcp
  37. #define solenoid15 15 //Connect Solenoid11 for Sens11 GPB8 on mcp
  38.  
  39. int sensor[15];
  40. /* Assign the name "sensor[0]" as analog output value from Channel C0 */
  41. /* Assign the name "sensor[1]" as analog output value from Channel C1 */
  42. /* Assign the name "sensor[2]" as analog output value from Channel C2 */
  43. /* Assign the name "sensor[3]" as analog output value from Channel C3 */
  44. /* Assign the name "sensor[4]" as analog output value from Channel C4 */
  45. /* Assign the name "sensor[5]" as analog output value from Channel C5 */
  46. /* Assign the name "sensor[6]" as analog output value from Channel C6 */
  47. /* Assign the name "sensor[7]" as analog output value from Channel C7 */
  48. /* Assign the name "sensor[8]" as analog output value from Channel C8 */
  49. /* Assign the name "sensor[9]" as analog output value from Channel C9 */
  50. /* Assign the name "sensor[10]" as analog output value from Channel C10 */
  51. /* Assign the name "sensor[11]" as analog output value from Channel C11 */
  52. /* Assign the name "sensor[12]" as analog output value from Channel C12 */
  53. /* Assign the name "sensor[13]" as analog output value from Channel C13 */
  54. /* Assign the name "sensor[14]" as analog output value from Channel C14 */
  55. /* Assign the name "sensor[15]" as analog output value from Channel C15 */
  56.  
  57. String pumpstate = "OFF";      //pump for Status ON/OFF
  58. String solenoidState0 = "OFF";    //Solenoid0 for Status ON/OFF
  59. String solenoidState1 = "OFF";    //Solenoid1 for Status ON/OFF
  60. String solenoidState2 = "OFF";    //Solenoid2 for Status ON/OFF
  61. String solenoidState3 = "OFF";    //Solenoid3 for Status ON/OFF
  62. String solenoidState4 = "OFF";    //Solenoid4 for Status ON/OFF
  63. String solenoidState5 = "OFF";    //Solenoid5 for Status ON/OFF
  64. String solenoidState6 = "OFF";    //Solenoid6 for Status ON/OFF
  65. String solenoidState7 = "OFF";    //Solenoid7 for Status ON/OFF
  66. String solenoidState8 = "OFF";    //Solenoid8 for Status ON/OFF
  67. String solenoidState9 = "OFF";    //Solenoid9 for Status ON/OFF
  68. String solenoidState10 = "OFF";   //Solenoid10 for Status ON/OFF
  69. String solenoidState11 = "OFF";   //Solenoid11 for Status ON/OFF
  70. String solenoidState12 = "OFF";   //Solenoid11 for Status ON/OFF
  71. String solenoidState13 = "OFF";   //Solenoid11 for Status ON/OFF
  72. String solenoidState14 = "OFF";   //Solenoid11 for Status ON/OFF
  73. String solenoidState15 = "OFF";   //Solenoid11 for Status ON/OFF
  74. String XML; // pour envoyer le code XML a ma page web
  75.  
  76.  //User input from WebForm
  77. int Usermax0,Usermax1,Usermax2,Usermax3,Usermax4,Usermax5,Usermax6,Usermax7,Usermax8,Usermax9,Usermax10,Usermax11,Usermax12,Usermax13,Usermax14,Usermax15;
  78. int Usermin0,Usermin1,Usermin2,Usermin3,Usermin4,Usermin5,Usermin6,Usermin7,Usermin8,Usermin9,Usermin10,Usermin11,Usermin12,Usermin13,Usermin14,Usermin15;
  79.  
  80. ESP8266WebServer server(80);
  81.  
  82. #include "html.h"
  83. #include "readSensor.h"
  84. #include "jsonconfig1.h"
  85.  
  86. void handleRoot(){
  87.   server.send_P(200, "text/html", INDEX_HTML); //Send web page
  88. }
  89.  
  90. void handleReadUserPlantSelected(){
  91.  // Read Value from the User selected from the Html WebForm to String
  92.  if(server.arg("S00max").toInt() != 0) {Usermax0 = server.arg("S00max").toInt();}
  93.  if(server.arg("S00min").toInt() != 0) {Usermin0 = server.arg("S00min").toInt();}
  94.  if(server.arg("S01max").toInt() != 0) {Usermax1 = server.arg("S01max").toInt();}
  95.  if(server.arg("S01min").toInt() != 0) {Usermin1 = server.arg("S01min").toInt();}
  96.  if(server.arg("S02max").toInt() != 0) {Usermax2 = server.arg("S02max").toInt();}
  97.  if(server.arg("S02min").toInt() != 0) {Usermin2 = server.arg("S02min").toInt();}
  98.  if(server.arg("S03max").toInt() != 0) {Usermax3 = server.arg("S03max").toInt();}
  99.  if(server.arg("S03min").toInt() != 0) {Usermin3 = server.arg("S03min").toInt();}
  100.  if(server.arg("S04max").toInt() != 0) {Usermax4 = server.arg("S04max").toInt();}
  101.  if(server.arg("S04min").toInt() != 0) {Usermin4 = server.arg("S04min").toInt();}
  102.  if(server.arg("S05max").toInt() != 0) {Usermax5 = server.arg("S05max").toInt();}
  103.  if(server.arg("S05min").toInt() != 0) {Usermin5 = server.arg("S05min").toInt();}
  104.  if(server.arg("S06max").toInt() != 0) {Usermax6 = server.arg("S06max").toInt();}
  105.  if(server.arg("S06min").toInt() != 0) {Usermin6 = server.arg("S06min").toInt();}
  106.  if(server.arg("S07max").toInt() != 0) {Usermax7 = server.arg("S07max").toInt();}
  107.  if(server.arg("S07min").toInt() != 0) {Usermin7 = server.arg("S07min").toInt();}
  108.  if(server.arg("S08max").toInt() != 0) {Usermax8 = server.arg("S08max").toInt();}
  109.  if(server.arg("S08min").toInt() != 0) {Usermin8 = server.arg("S08min").toInt();}
  110.  if(server.arg("S09max").toInt() != 0) {Usermax9 = server.arg("S09max").toInt();}
  111.  if(server.arg("S09min").toInt() != 0) {Usermin9 = server.arg("S09min").toInt();}
  112.  if(server.arg("S10max").toInt() != 0) {Usermax10 = server.arg("S10max").toInt();}
  113.  if(server.arg("S10min").toInt() != 0) {Usermin10 = server.arg("S10min").toInt();}
  114.  if(server.arg("S11max").toInt() != 0) {Usermax11 = server.arg("S11max").toInt();}
  115.  if(server.arg("S11min").toInt() != 0) {Usermin11 = server.arg("S11min").toInt();}
  116.  if(server.arg("S12max").toInt() != 0) {Usermax12 = server.arg("S12max").toInt();}
  117.  if(server.arg("S12min").toInt() != 0) {Usermin12 = server.arg("S12min").toInt();}
  118.  if(server.arg("S13max").toInt() != 0) {Usermax13 = server.arg("S13max").toInt();}
  119.  if(server.arg("S13min").toInt() != 0) {Usermin13 = server.arg("S13min").toInt();}
  120.  if(server.arg("S14max").toInt() != 0) {Usermax14 = server.arg("S14max").toInt();}
  121.  if(server.arg("S14min").toInt() != 0) {Usermin14 = server.arg("S14min").toInt();}
  122.  if(server.arg("S15max").toInt() != 0) {Usermax15 = server.arg("S15max").toInt();}
  123.  if(server.arg("S15min").toInt() != 0) {Usermin15 = server.arg("S15min").toInt();}
  124.  // Print Value to Serial Monitor
  125.  Serial.println("Form Soil Humidity");
  126.  Serial.print("Max0: "); Serial.print(Usermax0); Serial.print("\t Min0: "); Serial.println(Usermin0);
  127.  Serial.print("Max1: "); Serial.print(Usermax1); Serial.print("\t Min1: "); Serial.println(Usermin1);  
  128.  Serial.print("Max2: "); Serial.print(Usermax2); Serial.print("\t Min2: "); Serial.println(Usermin2);  
  129.  Serial.print("Max3: "); Serial.print(Usermax3); Serial.print("\t Min3: "); Serial.println(Usermin3);  
  130.  Serial.print("Max4: "); Serial.print(Usermax4); Serial.print("\t Min4: "); Serial.println(Usermin4);
  131.  Serial.print("Max5: "); Serial.print(Usermax5); Serial.print("\t Min5: "); Serial.println(Usermin5);
  132.  Serial.print("Max6: "); Serial.print(Usermax6); Serial.print("\t Min6: "); Serial.println(Usermin6);
  133.  Serial.print("Max7: "); Serial.print(Usermax7); Serial.print("\t Min7: "); Serial.println(Usermin7);
  134.  Serial.print("Max8: "); Serial.print(Usermax8); Serial.print("\t Min8: "); Serial.println(Usermin8);
  135.  Serial.print("Max9: "); Serial.print(Usermax9); Serial.print("\t Min9: "); Serial.println(Usermin9);
  136.  Serial.print("Max10: "); Serial.print(Usermax10); Serial.print("\t Min10: "); Serial.println(Usermin10);
  137.  Serial.print("Max11: "); Serial.print(Usermax11); Serial.print("\t Min11: "); Serial.println(Usermin11);
  138.  Serial.print("Max12: "); Serial.print(Usermax12); Serial.print("\t Min12: "); Serial.println(Usermin12);
  139.  Serial.print("Max13: "); Serial.print(Usermax13); Serial.print("\t Min13: "); Serial.println(Usermin13);
  140.  Serial.print("Max14: "); Serial.print(Usermax14); Serial.print("\t Min14: "); Serial.println(Usermin14);
  141.  Serial.print("Max15: "); Serial.print(Usermax15); Serial.print("\t Min15: "); Serial.println(Usermin15);
  142.  
  143.  if(!saveConfiguration) {
  144.   Serial.println(F("failed to Save..."));
  145.  }
  146.  else {
  147.   Serial.println(F("Saved OK..."));
  148.  }
  149.  
  150.  server.sendHeader("Location","/"); // Add header to go to the home page again
  151.  server.send(303); // Send it back to the browser with an HTTP status 303
  152. }
  153.  
  154. void handleNotFound() {
  155.   String message = "File Not Found\n\n";
  156.   message += "URI: ";
  157.   message += server.uri();
  158.   message += "\nMethod: ";
  159.   message += (server.method() == HTTP_GET) ? "GET" : "POST";
  160.   message += "\nArguments: ";
  161.   message += server.args();
  162.   message += "\n";
  163.   for (uint8_t i = 0; i < server.args(); i++) {
  164.     message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  165.   }
  166.   server.send(404, "text/plain", message);
  167. }
  168. // include read sensor
  169.  
  170. // Drive the Solenoid
  171. String solenoidStatus(int sensor, int solenoidPin, int SoilHumidityMax, int SoilHumidityMin) {
  172.   String solenoidState;
  173.   if(sensor <= SoilHumidityMin) {
  174.     solenoidState = "OFF";
  175.     mcp.digitalWrite(solenoidPin,LOW);
  176.   }
  177.   else if(sensor >= SoilHumidityMax){
  178.   solenoidState = "ON";
  179.   mcp.digitalWrite(solenoidPin,HIGH);
  180.   }
  181.   return(solenoidState);
  182. }
  183.  
  184. // Read Solenoid status and display status in html
  185. void driveSolenoid() {
  186.   solenoidState0 = solenoidStatus(sensor[0], solenoid0, Usermax0, Usermin0);
  187.   solenoidState1 = solenoidStatus(sensor[1], solenoid1, Usermax1, Usermin1);
  188.   solenoidState2 = solenoidStatus(sensor[2], solenoid2, Usermax2, Usermin2);
  189.   solenoidState3 = solenoidStatus(sensor[3], solenoid3, Usermax3, Usermin3);
  190.   solenoidState4 = solenoidStatus(sensor[4], solenoid4, Usermax4, Usermin4);
  191.   solenoidState5 = solenoidStatus(sensor[5], solenoid5, Usermax5, Usermin5);
  192.   solenoidState6 = solenoidStatus(sensor[6], solenoid6, Usermax6, Usermin6);
  193.   solenoidState7 = solenoidStatus(sensor[7], solenoid7, Usermax7, Usermin7);
  194.   solenoidState8 = solenoidStatus(sensor[8], solenoid8, Usermax8, Usermin8);
  195.   solenoidState9 = solenoidStatus(sensor[9], solenoid9, Usermax9, Usermin9);
  196.   solenoidState10 = solenoidStatus(sensor[10], solenoid10, Usermax10, Usermin10);
  197.   solenoidState11 = solenoidStatus(sensor[11], solenoid11, Usermax11, Usermin11);
  198.   solenoidState12 = solenoidStatus(sensor[12], solenoid12, Usermax12, Usermin12);
  199.   solenoidState13 = solenoidStatus(sensor[13], solenoid13, Usermax13, Usermin13);
  200.   solenoidState14 = solenoidStatus(sensor[14], solenoid14, Usermax14, Usermin14);
  201.   solenoidState15 = solenoidStatus(sensor[15], solenoid15, Usermax15, Usermin15);
  202. }
  203.  
  204. // Drive the pump and display status in html
  205. void drivePump() {
  206.   if(solenoidState0 == "OFF" && solenoidState1 == "OFF" && solenoidState2 == "OFF" && solenoidState3 == "OFF" &&
  207.      solenoidState4 == "OFF" && solenoidState5 == "OFF" && solenoidState6 == "OFF" && solenoidState7 == "OFF" &&
  208.      solenoidState8 == "OFF" && solenoidState9 == "OFF" && solenoidState10 == "OFF" && solenoidState11 == "OFF" &&
  209.      solenoidState12 == "OFF" && solenoidState13 == "OFF" && solenoidState14 == "OFF" && solenoidState15 == "OFF") {
  210.     if(pumpstate == "ON") {
  211.       pumpstate = "OFF";
  212.       digitalWrite(PUMP,LOW);
  213.     }
  214.   }
  215.   else {
  216.     if(pumpstate == "OFF") {
  217.     pumpstate = "ON";
  218.     digitalWrite(PUMP,HIGH);
  219.     }
  220.   }
  221. }
  222.  
  223. void handleXML(){
  224.   XML="<?xml version='1.0'?>";
  225.   XML+="<xml>";
  226.   XML+="<pumpstate>";  XML+= pumpstate;  XML+="</pumpstate>";
  227.   XML+="<sensor0>";  XML+= sensor[0];  XML+="</sensor0>";  
  228.   XML+="<sensor1>";  XML+= sensor[1];  XML+="</sensor1>";
  229.   XML+="<sensor2>";  XML+= sensor[2];  XML+="</sensor2>";
  230.   XML+="<sensor3>";  XML+= sensor[3];  XML+="</sensor3>";
  231.   XML+="<sensor4>";  XML+= sensor[4];  XML+="</sensor4>";
  232.   XML+="<sensor5>";  XML+= sensor[5];  XML+="</sensor5>";
  233.   XML+="<sensor6>";  XML+= sensor[6];  XML+="</sensor6>";
  234.   XML+="<sensor7>";  XML+= sensor[7];  XML+="</sensor7>";
  235.   XML+="<sensor8>";  XML+= sensor[8];  XML+="</sensor8>";
  236.   XML+="<sensor9>";  XML+= sensor[9];  XML+="</sensor9>";
  237.   XML+="<sensor10>";  XML+= sensor[10];  XML+="</sensor10>";
  238.   XML+="<sensor11>";  XML+= sensor[11];  XML+="</sensor11>";
  239.   XML+="<sensor12>";  XML+= sensor[12];  XML+="</sensor12>";
  240.   XML+="<sensor13>";  XML+= sensor[13];  XML+="</sensor13>";
  241.   XML+="<sensor14>";  XML+= sensor[14];  XML+="</sensor14>";
  242.   XML+="<sensor15>";  XML+= sensor[15];  XML+="</sensor15>";
  243.   XML+="<solenoidState0>";  XML+= solenoidState0;  XML+="</solenoidState0>";
  244.   XML+="<solenoidState1>";  XML+= solenoidState1;  XML+="</solenoidState1>";
  245.   XML+="<solenoidState2>";  XML+= solenoidState2;  XML+="</solenoidState2>";
  246.   XML+="<solenoidState3>";  XML+= solenoidState3;  XML+="</solenoidState3>";
  247.   XML+="<solenoidState4>";  XML+= solenoidState4;  XML+="</solenoidState4>";
  248.   XML+="<solenoidState5>";  XML+= solenoidState5;  XML+="</solenoidState5>";
  249.   XML+="<solenoidState6>";  XML+= solenoidState6;  XML+="</solenoidState6>";
  250.   XML+="<solenoidState7>";  XML+= solenoidState7;  XML+="</solenoidState7>";
  251.   XML+="<solenoidState8>";  XML+= solenoidState8;  XML+="</solenoidState8>";
  252.   XML+="<solenoidState9>";  XML+= solenoidState9;  XML+="</solenoidState9>";
  253.   XML+="<solenoidState10>";  XML+= solenoidState10;  XML+="</solenoidState10>";
  254.   XML+="<solenoidState11>";  XML+= solenoidState11;  XML+="</solenoidState11>";
  255.   XML+="<solenoidState12>";  XML+= solenoidState12;  XML+="</solenoidState12>";
  256.   XML+="<solenoidState13>";  XML+= solenoidState13;  XML+="</solenoidState13>";
  257.   XML+="<solenoidState14>";  XML+= solenoidState14;  XML+="</solenoidState14>";
  258.   XML+="<solenoidState15>";  XML+= solenoidState15;  XML+="</solenoidState15>";
  259.   XML+="<max00>";  XML+= Usermax0;  XML+="</max00>";
  260.   XML+="<min00>";  XML+= Usermin0;  XML+="</min00>";
  261.   XML+="<max01>";  XML+= Usermax1;  XML+="</max01>";
  262.   XML+="<min01>";  XML+= Usermin1;  XML+="</min01>";
  263.   XML+="<max02>";  XML+= Usermax2;  XML+="</max02>";
  264.   XML+="<min02>";  XML+= Usermin2;  XML+="</min02>";
  265.   XML+="<max03>";  XML+= Usermax3;  XML+="</max03>";
  266.   XML+="<min03>";  XML+= Usermin3;  XML+="</min03>";
  267.   XML+="<max04>";  XML+= Usermax4;  XML+="</max04>";
  268.   XML+="<min04>";  XML+= Usermin4;  XML+="</min04>";
  269.   XML+="<max05>";  XML+= Usermax5;  XML+="</max05>";
  270.   XML+="<min05>";  XML+= Usermin5;  XML+="</min05>";
  271.   XML+="<max06>";  XML+= Usermax6;  XML+="</max06>";
  272.   XML+="<min06>";  XML+= Usermin6;  XML+="</min06>";
  273.   XML+="<max07>";  XML+= Usermax7;  XML+="</max07>";
  274.   XML+="<min07>";  XML+= Usermin7;  XML+="</min07>";
  275.   XML+="<max08>";  XML+= Usermax8;  XML+="</max08>";
  276.   XML+="<min08>";  XML+= Usermin8;  XML+="</min08>";
  277.   XML+="<max09>";  XML+= Usermax9;  XML+="</max09>";
  278.   XML+="<min09>";  XML+= Usermin9;  XML+="</min09>";
  279.   XML+="<max10>";  XML+= Usermax10;  XML+="</max10>";
  280.   XML+="<min10>";  XML+= Usermin10;  XML+="</min10>";
  281.   XML+="<max11>";  XML+= Usermax11;  XML+="</max11>";
  282.   XML+="<min11>";  XML+= Usermin11;  XML+="</min11>";
  283.   XML+="<max12>";  XML+= Usermax12;  XML+="</max12>";
  284.   XML+="<min12>";  XML+= Usermin12;  XML+="</min12>";
  285.   XML+="<max13>";  XML+= Usermax13;  XML+="</max13>";
  286.   XML+="<min13>";  XML+= Usermin13;  XML+="</min13>";
  287.   XML+="<max14>";  XML+= Usermax14;  XML+="</max14>";
  288.   XML+="<min14>";  XML+= Usermin14;  XML+="</min14>";
  289.   XML+="<max15>";  XML+= Usermax15;  XML+="</max15>";
  290.   XML+="<min15>";  XML+= Usermin15;  XML+="</min15>";
  291.   XML+="</xml>";
  292.  server.send(200,"text/xml",XML);
  293. }
  294.  
  295. void setup() {
  296.   Serial.begin(115200);
  297.   mcp.begin();
  298.   pinMode(S0,OUTPUT);   /* Define digital pin as output to the Multiplexer pin SO */
  299.   pinMode(S1,OUTPUT);   /* Define digital pin as output to the Multiplexer pin S1 */
  300.   pinMode(S2,OUTPUT);   /* Define digital pin as output to the Multiplexer pin S2 */
  301.   pinMode(S3,OUTPUT);   /* Define digital pin as output to the Multiplexer pin S3 */
  302.   pinMode(SIG, INPUT);  /* Define analog pin as input from the Multiplexer pin SIG */
  303.   pinMode(PUMP,OUTPUT); /* Define digital pin os output to control pump */
  304.   mcp.pinMode(solenoid0, OUTPUT);
  305.   mcp.pinMode(solenoid1, OUTPUT);
  306.   mcp.pinMode(solenoid2, OUTPUT);
  307.   mcp.pinMode(solenoid3, OUTPUT);
  308.   mcp.pinMode(solenoid4, OUTPUT);
  309.   mcp.pinMode(solenoid5, OUTPUT);
  310.   mcp.pinMode(solenoid6, OUTPUT);
  311.   mcp.pinMode(solenoid7, OUTPUT);
  312.   mcp.pinMode(solenoid8, OUTPUT);
  313.   mcp.pinMode(solenoid9, OUTPUT);
  314.   mcp.pinMode(solenoid10, OUTPUT);
  315.   mcp.pinMode(solenoid11, OUTPUT);
  316.   mcp.pinMode(solenoid12, OUTPUT);
  317.   mcp.pinMode(solenoid13, OUTPUT);
  318.   mcp.pinMode(solenoid14, OUTPUT);
  319.   mcp.pinMode(solenoid15, OUTPUT);
  320.   digitalWrite(PUMP,LOW);
  321.   mcp.digitalWrite(solenoid0,LOW);
  322.   mcp.digitalWrite(solenoid1,LOW);
  323.   mcp.digitalWrite(solenoid2,LOW);
  324.   mcp.digitalWrite(solenoid3,LOW);
  325.   mcp.digitalWrite(solenoid4,LOW);
  326.   mcp.digitalWrite(solenoid5,LOW);
  327.   mcp.digitalWrite(solenoid6,LOW);
  328.   mcp.digitalWrite(solenoid7,LOW);
  329.   mcp.digitalWrite(solenoid8,LOW);
  330.   mcp.digitalWrite(solenoid9,LOW);
  331.   mcp.digitalWrite(solenoid10,LOW);
  332.   mcp.digitalWrite(solenoid11,LOW);
  333.   mcp.digitalWrite(solenoid12,LOW);
  334.   mcp.digitalWrite(solenoid13,LOW);
  335.   mcp.digitalWrite(solenoid14,LOW);
  336.   mcp.digitalWrite(solenoid15,LOW);
  337.  
  338.   Serial.println("");
  339.   delay(1000);
  340.   Serial.println("Mounting FS...");
  341.   if (!LittleFS.begin()) {
  342.     Serial.println("Failed to mount file system");
  343.     return;
  344.   }
  345.   if(!loadConfiguration) { Serial.println(F("Failed to load...")); }
  346.    else {  Serial.println(F("Load OK...")); }
  347.   delay(1000);
  348.  
  349.   WiFiManager wifiManager;
  350.   wifiManager.autoConnect("AutoConnectAP");
  351.   Serial.println("Yourconnected...yeey :)");
  352.   server.on("/", handleRoot);
  353.   server.on("/reqEtatVariables",handleXML);
  354.   server.on("/get",handleReadUserPlantSelected);
  355.   server.onNotFound(handleNotFound);   /* page not found */
  356.  
  357.   server.begin();
  358.   Serial.println("HTTP server started");
  359.   Serial.println(WiFi.localIP());
  360. }
  361.  
  362. void loop() {
  363.   server.handleClient();
  364.   getSoilHumidity();
  365.   driveSolenoid();
  366.   drivePump();
  367. }
RAW Paste Data