WIFIMANAGER MERGE MY CODE

Hi, I've combined the wifi manager library with my project, but I'm having trouble. Can you check what is the problem? wifi reset pin rx pin did not use continuously.

//DHT11 TX PININE TAK
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>  
#define ROLE  D0  // D0
#define ROLE1 D1  // D1
#define ROLE2 D4  // D4
#define ROLE3 D6  // D6

#define ANAHTAR D2 // D2
#define ANAHTAR1 D3 // D3
#define ANAHTAR2 D5 // D5
#define ANAHTAR3 D7 // D7
#define TRIGGER_PIN 03 // WIFIMANAGER SETTING RESET PIN
ESP8266WebServer server;

//char* kablosuzadi = "okhan";
//char* parola = "atakan2009";
bool mevcutdurum = false;
bool sonANAHTARDurum = false;
bool ROLEDurum = false;
////
bool mevcutdurum1 = false;
bool sonANAHTARDurum1 = false;
bool ROLEDurum1 = false;
///
bool mevcutdurum2 = false;
bool sonANAHTARDurum2 = false;
bool ROLEDurum2 = false;
///
bool mevcutdurum3 = false;
bool sonANAHTARDurum3 = false;
bool ROLEDurum3 = false;

const bool bascekDurum = 0;     // 0 role durumları dusuk
const bool bascekDurum1 = 0;     // 0 role durumları dusuk
const bool bascekDurum2 = 0;     // 0 role durumları dusuk
const bool bascekDurum3 = 0;     // 0 role durumları dusuk
//====================================================
String HTML_Root = "<!doctype html><html><body>\<a href=\'toggle\'><ANAHTAR type=\"ANAHTAR\">ROLE1</ANAHTAR> <a href=\'role2\'><ANAHTAR type=\"ANAHTAR\">role2</ANAHTAR> <a href=\'role3\'><ANAHTAR type=\"ANAHTAR\">role3</ANAHTAR> <a href=\'role4\'><ANAHTAR type=\"ANAHTAR\">role4</ANAHTAR>\</body></html>";

//====================================================
void handleRoot() {
  server.send ( 200, "text/html", HTML_Root );
}

//====================================================
void bascekfzkANAHTAR() {// 1NOLU FİZİKSEL BUTON
  mevcutdurum = digitalRead(ANAHTAR);

  if (mevcutdurum != sonANAHTARDurum) {
    sonANAHTARDurum = mevcutdurum;

    if (mevcutdurum == bascekDurum)
    {
      ROLEDurum = !ROLEDurum;
    }
    digitalWrite(ROLE, ROLEDurum);
    Serial.print("RÖLE 1!\n");
  }
  delay(50);
}
//SONRAKI ROLELER

void bascekfzkANAHTAR1() { //// İKİ NOLU FİZİKSEL
  mevcutdurum1 = digitalRead(ANAHTAR1);

  if (mevcutdurum1 != sonANAHTARDurum1) {
    sonANAHTARDurum1 = mevcutdurum1;

    if (mevcutdurum1 == bascekDurum1)
    {
      ROLEDurum1 = !ROLEDurum1;
    }
    digitalWrite(ROLE1, ROLEDurum1);
    Serial.print("RÖLE 2!\n");
  }
  delay(50);
}
//SONRAKI ROLE
//
//SONRAKI ROLE1
void bascekfzkANAHTAR2() { // 3 NOLU FİZİK
  mevcutdurum2 = digitalRead(ANAHTAR2);

  if (mevcutdurum2 != sonANAHTARDurum2) {
    sonANAHTARDurum2 = mevcutdurum2;

    if (mevcutdurum2 == bascekDurum2)
    {
      ROLEDurum2 = !ROLEDurum2;
    }
    digitalWrite(ROLE2, ROLEDurum2);
    Serial.print("RÖLE 3!\n");
  }
  delay(50);
}
//2
void bascekfzkANAHTAR3() {
  //4 NOLU FİZİKSEL BUTON
  mevcutdurum3 = digitalRead(ANAHTAR3);

  if (mevcutdurum3 != sonANAHTARDurum3) {
    sonANAHTARDurum3 = mevcutdurum3;

    if (mevcutdurum3 == bascekDurum3)
    {
      ROLEDurum3 = !ROLEDurum3;
    }
    digitalWrite(ROLE3, ROLEDurum3);
    Serial.print("RÖLE 4!\n");
  }
  delay(50);
}
//

//====================================================
void bascekWebANAHTAR() {
  ROLEDurum = !ROLEDurum;
  digitalWrite(ROLE, ROLEDurum);
  Serial.print("RÖLE1 WEB BUTON!\n");
  server.send(200, "text/html", HTML_Root);
}
// SONRAKİLER
void bascekWebANAHTAR1() {
  ROLEDurum1 = !ROLEDurum1;
  digitalWrite(ROLE1, ROLEDurum1);
  Serial.print("ROLE2 WEB BUTON!\n");
  server.send(200, "text/html", HTML_Root);
}
//
void bascekWebANAHTAR2() {
  ROLEDurum2 = !ROLEDurum2;
  digitalWrite(ROLE2, ROLEDurum2);
  Serial.print("ROLE3 WEB BUTON!\n");
  server.send(200, "text/html", HTML_Root);
}
//
void bascekWebANAHTAR3() {
  ROLEDurum3 = !ROLEDurum3;
  digitalWrite(ROLE3, ROLEDurum3);
  Serial.print("ROLE4 WEB BUTON!\n");
  server.send(200, "text/html", HTML_Root);
}

//====================================================
void setup() {
  Serial.begin(115200);
  Serial.println("\n Basladi. Ayar icin Reset Dugmesine Bas");
  pinMode(ANAHTAR, INPUT_PULLUP);
  pinMode(ANAHTAR1, INPUT_PULLUP);
  pinMode(ANAHTAR2, INPUT_PULLUP);
  pinMode(ANAHTAR3, INPUT_PULLUP);
   pinMode(TRIGGER_PIN, INPUT);
  pinMode(ROLE, OUTPUT);
  pinMode(ROLE1, OUTPUT);
  pinMode(ROLE2, OUTPUT);
  pinMode(ROLE3, OUTPUT);
  // wifi
 // WiFi.mode(WIFI_STA);
  //WiFi.begin(kablosuzadi, parola);
 // Serial.println("");
  //while (WiFi.status() != WL_CONNECTED) {
   // Serial.print(".");
   // delay(500);
 // }
  //Serial.println(WiFi.localIP());
  // webserver
  server.on ("/", handleRoot);
  server.on("/toggle", bascekWebANAHTAR);
  server.on("/role2", bascekWebANAHTAR1);
  server.on("/role3", bascekWebANAHTAR2);
  server.on("/role4", bascekWebANAHTAR3);
  server.begin();
}

//====================================================
void loop() 

{
   // is configuration portal requested?
  if ( digitalRead(TRIGGER_PIN) == LOW ) {
    //WiFiManager
    //Local intialization. Once its business is done, there is no need to keep it around
    WiFiManager wifiManager;

    //reset settings - for testing
    //wifiManager.resetSettings();

    //sets timeout until configuration portal gets turned off
    //useful to make it all retry or go to sleep
    //in seconds
    //wifiManager.setTimeout(120);

    //it starts an access point with the specified name
    //here  "AutoConnectAP"
    //and goes into a blocking loop awaiting configuration

    //WITHOUT THIS THE AP DOES NOT SEEM TO WORK PROPERLY WITH SDK 1.5 , update to at least 1.5.1
    //WiFi.mode(WIFI_STA);
    
    if (!wifiManager.startConfigPortal("EVOTO")) {
      Serial.println("ZAMANASIMI");
      delay(3000);
      //reset and try again, or maybe put it to deep sleep
      ESP.reset();
      delay(5000);
    }

    //if you get here you have connected to the WiFi
    Serial.println("EVOTO BAGLANDI)");
  }
  
  server.handleClient();
  bascekfzkANAHTAR();
    bascekfzkANAHTAR1();
      bascekfzkANAHTAR2();
        bascekfzkANAHTAR3();
}

You need to be a bit more specific than just "having trouble". Does it compile? If not, what is the error? Does it run? If not, what behaviour do you expect and what behaviour do you get?

#define ROLE  D0  // D0
#define ROLE1 D1  // D1

These might give you trouble if you're using the Serial device.

Hi, I'm not using serial device, I'm just doing the relay open shutdown process. i can't connect with wifi manager. can you review the code?

ykilicaslan:
Hi, I'm not using serial device,

yes but, you are ..

Serial.begin(115200);
  Serial.println("\n Basladi. Ayar icin Reset Dugmesine Bas");

Writing to the Serial-port sets the TX pin to output and actually writes the bits. No idea what that all means, but i think the error comes from your wifimanager object being constructed within loop(), it should be within setup() Probably before that Serial.println() oh man.. it does make it a tad easier for us if the function names and comments are in a language most of us understand.