 #include <DallasTemperature.h>
 #include <DHT.h>
 #include <ESPmDNS.h>
-#define ONE_WIRE_BUS 5
-#define DHTPIN 15
-#define DHTTYPE DHT11
+#define ONE_WIRE_BUS 5 //dallas sensor pin
+#define DHTPIN 15 // dht sensor pin
+#define DHTTYPE DHT11 //dht type 11 or 22
 DHT dht(DHTPIN, DHTTYPE);
 OneWire oneWire(ONE_WIRE_BUS);
 DallasTemperature sensors(&oneWire);
 // end of sensors
 
-// Settings you should check/change !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! mabe not anymore !!!!!!!!!!!!!
-
-const char* www_username = "admin";
-String resetpass = "admin"; // password to reset wifimanager when allready connected
-String thingkey = "none"; //your thingspeak API key
-String thingchanel = "none"; //your thingspeak Chanel #
-const long interval = 60000; // interval in ms for sending temperature data to thingspeak
-String liens = "";
-String dernadd = "Fraichement boot&eacute;"; //variable for ip logging (you can put your fresh boot mesage here in text/html)
 // led pins
 uint8_t pinRouge = 12;
-uint8_t pinVerte = 14; // internally pulled up
+uint8_t pinVerte = 14;
 uint8_t pinBleu = 13;
-// end of settings you should check/change
+//end of led pins
 
 // internally used vars
+// Some used vars, some of these are set and loaded in setup() using esp32 Preferences
+const long interval = 60000; // interval in ms for sending temperature data to thingspeak
+const char* www_username = "admin";
+String dernadd = "Fraichement boot&eacute;"; //variable for ip logging (you can put your fresh boot mesage here in text/html)
+String resetpass = ""; // password to reset wifimanager when allready connected
+String thingkey = ""; //your thingspeak API key
+String thingchanel = ""; //your thingspeak Chanel #
+String liens = "";
+String derncoul = "";
 WebServer server(80);
-String derncoul = "#000000";
 long r = 0;
 long g = 0;
 long b = 0;

  logtourne();
  logs[1] = addy;
  logs[1] += " : Settings : Password=";
  logs[1] += passme;
  logs[1].replace("<", "</"); //prevent html tags in logs so hackers cant code in log page lol
  if (ouireset == 1) {
    Serial.println("Settings changed");
    preferences.putString("resetpass", noupass);
    preferences.putString("thingkey", lakey);
    preferences.putString("thingchanel", lechan);
    resetpass = noupass;
    thingkey = lakey;
    thingchanel = lechan;
    liens = "<a href=\"/\">Acceuil</a> - <a href=\"/temp\">Temp&eacute;rature</a> - <a href=\"/version\">Version</a> - <a href=\"/setup\">Setup</a> - <a href=\"/reset\">Reset</a> - <a href=\"https://thingspeak.com/channels/";
    liens += thingchanel;
    liens += "\">Temp stats</a>\n";
  }
}

char* string2char(String command) {
  if (command.length() != 0) {
    char *p = const_cast<char*>(command.c_str());

  resetpass = preferences.getString("resetpass", "admin");
  thingkey = preferences.getString("thingkey", "none");
  thingchanel = preferences.getString("thingchanel", "none");
  liens = "<a href=\"/\">Acceuil</a> - <a href=\"/temp\">Temp&eacute;rature</a> - <a href=\"/version\">Version</a> - <a href=\"/setup\">Setup</a> - <a href=\"/reset\">Reset</a> - <a href=\"https://thingspeak.com/channels/";
  liens += thingchanel;
  liens += "\">Temp stats</a>\n";
  WiFiManager wifiManager;
