user55184: Im using ESP12E DevKit v2 (esp8266 wifi module) board for controlling relays and displaying DHT22 temp,humidity on web server. 
It runs smoothly when the web client is closed but when i leave the website on for like a 20mins it crashes.
I have installed the ESPdecoder and the stack trace always leads mostly to libraries. I tried using 
  ESP.wdtDisable(); 
   ESP.wdtEnable(WDTO_8S); commands and yield(); function but doesnt make any difference.
How can i fix this or what am i doing wrong in the code?
Soft WDT reset

>>>stack>>>

ctx: sys
sp: 3fffed40 end: 3fffffb0 offset: 01b0
3fffeef0:  3ffe93dc c84524b8 60000600 4020ea06  
3fffef00:  00000000 3ffeda08 00000000 00000000  
3fffef10:  4022d488 3ffeda08 3ffee9c0 60000600  
3fffef20:  4022fdd1 3ffeda08 3ffee9c0 c84550ad  
3fffef30:  4022fe16 3fffdab0 00000000 3fffdcb0  
3fffef40:  3ffee9d0 3fffdab0 00000000 40206223  
3fffef50:  40000f49 40000f49 3fffdab0 40000f49  
3fffef60:  40000e19 40001878 00000002 00000000  
3fffef70:  3fffff10 aa55aa55 000000f0 40104ba0  
3fffef80:  40104ba6 00000002 00000000 3715d4f6  
3fffef90:  4010000d 0e060f10 942b6d57 69e0d507  
3fffefa0:  40100b40 3fffef3c 40100aed 3ffffea8  
3fffefb0:  3fffffc0 00000000 00000000 feefeffe  
3fffefc0:  feefeffe feefeffe feefeffe feefeffe  
3fffefd0:  feefeffe feefeffe feefeffe feefeffe  
3fffefe0:  feefeffe feefeffe feefeffe feefeffe  
3fffeff0:  feefeffe feefeffe feefeffe feefeffe  
3ffff000:  feefeffe feefeffe feefeffe feefeffe  
3ffff010:  feefeffe feefeffe feefeffe feefeffe  
3ffff020:  feefeffe feefeffe feefeffe feefeffe  
3ffff030:  feefeffe feefeffe feefeffe feefeffe  
3ffff040:  feefeffe feefeffe feefeffe feefeffe  
3ffff050:  feefeffe feefeffe feefeffe feefeffe  
3ffff060:  feefeffe feefeffe feefeffe feefeffe  
3ffff070:  feefeffe feefeffe feefeffe feefeffe  
3ffff080:  feefeffe feefeffe feefeffe feefeffe  
3ffff090:  feefeffe feefeffe feefeffe feefeffe  
3ffff0a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff100:  feefeffe feefeffe feefeffe feefeffe  
3ffff110:  feefeffe feefeffe feefeffe feefeffe  
3ffff120:  feefeffe feefeffe feefeffe feefeffe  
3ffff130:  feefeffe feefeffe feefeffe feefeffe  
3ffff140:  feefeffe feefeffe feefeffe feefeffe  
3ffff150:  feefeffe feefeffe feefeffe feefeffe  
3ffff160:  feefeffe feefeffe feefeffe feefeffe  
3ffff170:  feefeffe feefeffe feefeffe feefeffe  
3ffff180:  feefeffe feefeffe feefeffe feefeffe  
3ffff190:  feefeffe feefeffe feefeffe feefeffe  
3ffff1a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff200:  feefeffe feefeffe feefeffe feefeffe  
3ffff210:  feefeffe feefeffe feefeffe feefeffe  
3ffff220:  feefeffe feefeffe feefeffe feefeffe  
3ffff230:  feefeffe feefeffe feefeffe feefeffe  
3ffff240:  feefeffe feefeffe feefeffe feefeffe  
3ffff250:  feefeffe feefeffe feefeffe feefeffe  
3ffff260:  feefeffe feefeffe feefeffe feefeffe  
3ffff270:  feefeffe feefeffe feefeffe feefeffe  
3ffff280:  feefeffe feefeffe feefeffe feefeffe  
3ffff290:  feefeffe feefeffe feefeffe feefeffe  
3ffff2a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff300:  feefeffe feefeffe feefeffe feefeffe  
3ffff310:  feefeffe feefeffe feefeffe feefeffe  
3ffff320:  feefeffe feefeffe feefeffe feefeffe  
3ffff330:  feefeffe feefeffe feefeffe feefeffe  
3ffff340:  feefeffe feefeffe feefeffe feefeffe  
3ffff350:  feefeffe feefeffe feefeffe feefeffe  
3ffff360:  feefeffe feefeffe feefeffe feefeffe  
3ffff370:  feefeffe feefeffe feefeffe feefeffe  
3ffff380:  feefeffe feefeffe feefeffe feefeffe  
3ffff390:  feefeffe feefeffe feefeffe feefeffe  
3ffff3a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff400:  feefeffe feefeffe feefeffe feefeffe  
3ffff410:  feefeffe feefeffe feefeffe feefeffe  
3ffff420:  feefeffe feefeffe feefeffe feefeffe  
3ffff430:  feefeffe feefeffe feefeffe feefeffe  
3ffff440:  feefeffe feefeffe feefeffe feefeffe  
3ffff450:  feefeffe feefeffe feefeffe feefeffe  
3ffff460:  feefeffe feefeffe feefeffe feefeffe  
3ffff470:  feefeffe feefeffe feefeffe feefeffe  
3ffff480:  feefeffe feefeffe feefeffe feefeffe  
3ffff490:  feefeffe feefeffe feefeffe feefeffe  
3ffff4a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff500:  feefeffe feefeffe feefeffe feefeffe  
3ffff510:  feefeffe feefeffe feefeffe feefeffe  
3ffff520:  feefeffe feefeffe feefeffe feefeffe  
3ffff530:  feefeffe feefeffe feefeffe feefeffe  
3ffff540:  feefeffe feefeffe feefeffe feefeffe  
3ffff550:  feefeffe feefeffe feefeffe feefeffe  
3ffff560:  feefeffe feefeffe feefeffe feefeffe  
3ffff570:  feefeffe feefeffe feefeffe feefeffe  
3ffff580:  feefeffe feefeffe feefeffe feefeffe  
3ffff590:  feefeffe feefeffe feefeffe feefeffe  
3ffff5a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff600:  feefeffe feefeffe feefeffe feefeffe  
3ffff610:  feefeffe feefeffe feefeffe feefeffe  
3ffff620:  feefeffe feefeffe feefeffe feefeffe  
3ffff630:  feefeffe feefeffe feefeffe feefeffe  
3ffff640:  feefeffe feefeffe feefeffe feefeffe  
3ffff650:  feefeffe feefeffe feefeffe feefeffe  
3ffff660:  feefeffe feefeffe feefeffe feefeffe  
3ffff670:  feefeffe feefeffe feefeffe feefeffe  
3ffff680:  feefeffe feefeffe feefeffe feefeffe  
3ffff690:  feefeffe feefeffe feefeffe feefeffe  
3ffff6a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff700:  feefeffe feefeffe feefeffe feefeffe  
3ffff710:  feefeffe feefeffe feefeffe feefeffe  
3ffff720:  feefeffe feefeffe feefeffe feefeffe  
3ffff730:  feefeffe feefeffe feefeffe feefeffe  
3ffff740:  feefeffe feefeffe feefeffe feefeffe  
3ffff750:  feefeffe feefeffe feefeffe feefeffe  
3ffff760:  feefeffe feefeffe feefeffe feefeffe  
3ffff770:  feefeffe feefeffe feefeffe feefeffe  
3ffff780:  feefeffe feefeffe feefeffe feefeffe  
3ffff790:  feefeffe feefeffe feefeffe feefeffe  
3ffff7a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff800:  feefeffe feefeffe feefeffe feefeffe  
3ffff810:  feefeffe feefeffe feefeffe feefeffe  
3ffff820:  feefeffe feefeffe feefeffe feefeffe  
3ffff830:  feefeffe feefeffe feefeffe feefeffe  
3ffff840:  feefeffe feefeffe feefeffe feefeffe  
3ffff850:  feefeffe feefeffe feefeffe feefeffe  
3ffff860:  feefeffe feefeffe feefeffe feefeffe  
3ffff870:  feefeffe feefeffe feefeffe feefeffe  
3ffff880:  feefeffe feefeffe feefeffe feefeffe  
3ffff890:  feefeffe feefeffe feefeffe feefeffe  
3ffff8a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff900:  feefeffe feefeffe feefeffe feefeffe  
3ffff910:  feefeffe feefeffe feefeffe feefeffe  
3ffff920:  feefeffe feefeffe feefeffe feefeffe  
3ffff930:  feefeffe feefeffe feefeffe feefeffe  
3ffff940:  feefeffe feefeffe feefeffe feefeffe  
3ffff950:  feefeffe feefeffe feefeffe feefeffe  
3ffff960:  feefeffe feefeffe feefeffe feefeffe  
3ffff970:  feefeffe feefeffe feefeffe feefeffe  
3ffff980:  feefeffe feefeffe feefeffe feefeffe  
3ffff990:  feefeffe feefeffe feefeffe feefeffe  
3ffff9a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9f0:  feefeffe feefeffe feefeffe feefeffe  
3ffffa00:  feefeffe feefeffe feefeffe feefeffe  
3ffffa10:  feefeffe feefeffe feefeffe feefeffe  
3ffffa20:  feefeffe feefeffe feefeffe feefeffe  
3ffffa30:  feefeffe feefeffe feefeffe feefeffe  
3ffffa40:  feefeffe feefeffe feefeffe feefeffe  
3ffffa50:  feefeffe feefeffe feefeffe feefeffe  
3ffffa60:  feefeffe feefeffe feefeffe feefeffe  
3ffffa70:  00000000 00000000 0000001f 40105379  
3ffffa80:  4000050c feefeffe feefeffe feefeffe  
3ffffa90:  40222216 00000030 00000010 ffffffff  
3ffffaa0:  40218973 3fff0884 00000000 00000000  
3ffffab0:  00000a43 00000000 00000a43 3fff07b4  
3ffffac0:  00000a43 00000000 00000020 000000fd  
3ffffad0:  00000005 00000000 00000020 40101696  
3ffffae0:  3ffe96b5 40104a97 3ffed118 40101696  
3ffffaf0:  401023ad 3ffed118 3ffed118 40101696  
3ffffb00:  00000005 00000000 00000020 40101696  
3ffffb10:  3ffe96b5 40104a97 3ffed0f0 4010257e  
3ffffb20:  00000002 00000000 00000020 40101696  
3ffffb30:  3ffe96b2 40104a7c 3ffece48 4010257e  
3ffffb40:  00000001 40103c9f 3ffed878 00000001  
3ffffb50:  40104102 c047a314 401029be 00000100  
3ffffb60:  00000000 00000000 0000001f 40105379  
3ffffb70:  40103be6 00000023 7fffffff 00000002  
3ffffb80:  00000123 3ffed118 3ffe9801 00000008  
3ffffb90:  40102a5b 00080000 3ffedb88 4010257e  
3ffffba0:  00000000 00000000 00002200 4000050c  
3ffffbb0:  3fffc278 40102758 3fffc200 00000022  
3ffffbc0:  3ffffbd0 3ffe9f6c 3ffe9f6c 00000001  
3ffffbd0:  4021bddb 00000030 00000010 ffffffff  
3ffffbe0:  4021bddb 00000001 00000000 0000c005  
3ffffbf0:  0000024e 00000001 ffff7f72 0000888e  
3ffffc00:  000005e0 00000020 401038a1 3ffed830  
3ffffc10:  0000013a 00000000 3fff0c70 000000fd  
3ffffc20:  0000005a 00000001 401049e2 3ffed830  
3ffffc30:  00000000 00000000 00000020 40101696  
3ffffc40:  3ffe96b0 40104a7c 3fff034c 3ffed830  
3ffffc50:  00000001 40103c9f 3ffed830 40101696  
3ffffc60:  40104102 00040000 40229be3 00000001  
3ffffc70:  ffffffff 00000000 3ffe9801 00000008  
3ffffc80:  40229c32 3ffecdd0 3ffefa4c 00000001  
3ffffc90:  40229d3e 3ffecdd0 3ffefa4c 3ffecdd0  
3ffffca0:  00000002 00000000 00000020 40101696  
3ffffcb0:  3ffe96b2 40228cef 3ffecdd0 3fff0c54  
3ffffcc0:  00000000 4021bf97 3ffee2d8 40105379  
3ffffcd0:  00000000 00000002 00000000 3ffecdd0  
3ffffce0:  3fff1882 4010511f 3fff0c54 3fff01dc  
3ffffcf0:  3fff184c 0000002f 00000000 00000001  
3ffffd00:  00000004 4020e2d9 3ffef418 3fff01dc  
3ffffd10:  3fff1882 00000045 00000001 3ffeefc8  
3ffffd20:  3fffff20 3fffff20 0000000a 00000000  
3ffffd30:  3ffef83c 3ffef804 3fff184c 4020e55b  
3ffffd40:  00000002 3ffef804 3fff184c 4020e94c  
3ffffd50:  3ffef6a8 4bc6a7f0 94bc6a7f 00000001  
3ffffd60:  00000001 00000000 4bc6a7f0 3ffef6ac  
3ffffd70:  3ffef83c 00000003 3ffef804 40216024  
3ffffd80:  00000000 3ffee998 8d04d0fb 00000000  
3ffffd90:  00000002 3fff184c 3ffef294 00000000  
3ffffda0:  3ffee9c0 3ffef294 3ffe851c 3fff184c  
3ffffdb0:  00000001 4bc6a7f0 deb851eb 00000001  
3ffffdc0:  00000001 00000000 4bc6a7f0 00000000  
3ffffdd0:  3ffef2bc 000001d3 000001d3 40100664  
3ffffde0:  00000001 00000000 3fff0774 40100aa8  
3ffffdf0:  3b172b21 000001d3 3ffe851c 4020e175  
3ffffe00:  00000001 3ffffe8f 40206268 402036f7  
3ffffe10:  00000001 00000000 3fff0774 40203e3f  
3ffffe20:  00000002 3ffffeae 3fff0774 40203ec5  
3ffffe30:  00000001 4bc6a7f0 8083126e 3fffff40  
3ffffe40:  00000030 0000000a 3fffff40 402057ed  
3ffffe50:  3ffffe8f 000001d3 000001d3 40100664  
3ffffe60:  00000001 4bc6a7f0 3c6a7efa 00000001  
3ffffe70:  00000001 00000000 4bc6a7f0 00000000  
3ffffe80:  00000001 00000000 401001c0 00334411  
3ffffe90:  00000000 000001d3 000001d3 40100664  
3ffffea0:  3b46b3ee 00000000 3ffe851c 00000000  
3ffffeb0:  00000002 3ffe9259 40206268 3fffefa0  
3ffffec0:  00000002 00000000 3fff0774 40203e73  
3ffffed0:  0000000b 00000000 3fff0774 40203ec5  
3ffffee0:  3fffff40 3fe0004f 3fff0774 41cccccd  
3ffffef0:  423c999a 00000000 3fffff40 402057ed  
3fffff00:  3ffe9259 3ffef020 3fffff40 402057ed  
3fffff10:  3ffe8be4 3ffef020 3fffff40 40205818  
3fffff20:  423c999a 3ffef020 3fffff40 40205864  
3fffff30:  429a0000 3ffef020 3ffef03c 40202cc9  
3fffff40:  40206988 00000000 00001388 40206738  
3fffff50:  00000000 3fff0774 00000000 00000000  
3fffff60:  00000000 00000000 00000000 00000000  
3fffff70:  3fff0ccc 0000007f 00000000 feefeffe  
3fffff80:  429c28f6 00000000 42473333 feefeffe  
3fffff90:  00000000 00000000 00000001 3ffef238  
3fffffa0:  3fffdad0 00000000 3ffef208 40206314  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

My code: 
#include <ESP8266WiFi.h>
#include <DHT.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#define DHTTYPE DHT22

const char* ssid = "ID";
const char* password = "pass";
const char* ssid2 = "ID2";
const char* password2 = "pass2";

// Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);

WiFiServer server(80); // Set web server port number to 80
String header; // Variable to store the HTTP request

// Decode HTTP GET value
String valueString = "0";
int pos1 = 0;
int pos2 = 0;

// Variables to store the current output state
int relay0State = 0;
int relay1State = 0;
int relay2State = 0;
String brightness = "0";

// Variables to save date and time
String formattedDate;
String dayStamp;
String timeStamp;

// Variables assigned to pins
const int relay0 = 16;
const int relay1 = 5;
const int relay2 = 4;
const int DHT1Pin = 0;
const int DHT2Pin = 2;

// Initialize DHT sensors
DHT dht1(DHT1Pin, DHTTYPE);
DHT dht2(DHT2Pin, DHTTYPE);

void setup() {
  //Watchdog timer settings
  ESP.wdtDisable();
  ESP.wdtEnable(WDTO_8S); 

  Serial.begin(115200);
  // Initialize the output variables as outputs
  pinMode(relay0, OUTPUT);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  // Set outputs to LOW
  digitalWrite(relay0, LOW);
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);

  dht1.begin();
  dht2.begin();

  // Connect to available Wi-Fi network with SSID and password
  Serial.print("Connecting to ");
  int n = WiFi.scanNetworks();
  if (n == 0)
    Serial.println("No networks found!");
  else {
    for(int i=0;i<n;i++) {
      if(WiFi.SSID(i)==ssid) {
        WiFi.begin(ssid,password);
        ssid = ssid;
      } else if (WiFi.SSID(i)== ssid2) {
        WiFi.begin(ssid2,password2);
        ssid = ssid2;
      } 
    }
  }
  Serial.println(ssid);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  // Print local IP address and start web server
  Serial.println("");
  Serial.println("WiFi CONNECTED with IP: ");
  Serial.println(WiFi.localIP());
  server.begin();
  timeClient.begin(); // Initialize a NTPClient to get time
  timeClient.setTimeOffset(7200); // Setting offset time in seconds to adjust for current timezone -> GMT +1 = 3600
}

void loop(){
  ESP.wdtFeed(); //Feed the watchdog timer
  WiFiClient client = server.available();   // Listen for incoming clients

   while(!timeClient.update()) {
    timeClient.forceUpdate();
  }
  formattedDate = timeClient.getFormattedDate(); // The formattedDate comes with the following format 2018-05-28T16:00:13Z
  // Extract date
  int splitT = formattedDate.indexOf("T");
  dayStamp = formattedDate.substring(0, splitT);
  // Extract time
  timeStamp = formattedDate.substring(splitT+1, formattedDate.length()-1);

  if (client) {                             
    String currentLine = "";               // String to hold incoming data from the client
    while (client.connected()) {           // loop while the client's connected
      if (client.available()) {            // if there's bytes to read from the client,
        char c = client.read();            // read a byte, then
        header += c;
        if (c == '\n') {                    // if the byte is a newline character
                                            // if the current line is blank, you got two newline characters in a row. That's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();

            // Read humidity 
            float h1 = dht1.readHumidity();
            float h2 = dht2.readHumidity();
            // Read temperature as Celsius (the default)
            float t1 = dht1.readTemperature();
            float t2 = dht2.readTemperature();
            // Read temperature as Fahrenheit (isFahrenheit = true)
            float f1 = dht1.readTemperature(true);
            float f2 = dht2.readTemperature(true);

            // Calculating average temp and humidity from DHT22 sensors
            float temperature = (t1 + t2)/2;
            float temperaturef = (f1 + f2)/2;
            float humidity = (h1 + h2)/2;

            if(header.indexOf("GET /1/") | header.indexOf("GET /0/") < 0){
                if(humidity < 50){
                relay1State = 1;
                digitalWrite(relay1, HIGH);
              } else {
                relay1State = 0;
                digitalWrite(relay1, LOW);
              }
              if(temperature < 23) {
                relay0State = 1;
                digitalWrite(relay0, HIGH);
              } else {
                relay0State = 0;
                digitalWrite(relay0, LOW);
              }
            }

            if (header.indexOf("GET /0/on") >= 0) {
              relay0State = 1;
              digitalWrite(relay0, HIGH);
            } else if (header.indexOf("GET /0/off") >= 0) {
              relay0State = 0;
              digitalWrite(relay0, LOW);
            } else if (header.indexOf("GET /1/on") >= 0) {
              relay1State = 1;
              digitalWrite(relay1, HIGH);
            } else if (header.indexOf("GET /1/off") >= 0) {
              relay1State = 0;
              digitalWrite(relay1, LOW);
            }

            // Display the HTML web page
            client.println("<!DOCTYPE html><html>");
            client.println("<head><meta http-equiv=\"refresh\" content=\"1\" name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
            client.println("<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>");
            client.println("<style> html {font-family: Helvetica; display: inline-block; margin: 0px; text-align: center; height: auto; box-sizing: border-box;} h1, h2{width: 100%; color: #444444; font-size: 55px;} h2 {font-size: 30px;} h3, h4 {width: 50%; font-size: 24px; color: #444444; padding: 18px; margin: 10px; border-radius: 35px; margin: 4px auto;} h4 {padding: 5px;} .button {background-color: #4CAF50; border: none; color: white; padding: 16px 40px; text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;} .button2 {background-color: #555555;} .content {width: 100%; } .light {border-radius: 35px; width: 50%; margin: 4px auto;} .slider {-webkit-appearance: none; width: 30%; height: 10px; border-radius: 5px; margin-bottom: 20px; background: #d3d3d3; outline: none; } .slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #444444; cursor: pointer;} @media (max-width: 1000px) {h1{font-size: 40px;} h2{font-size: 25px;} h3,h4{width: 75%; font-size: 20px;} .light{ width: 75%;}}</style><title>Smart TERA</title> </head> ");
            client.println("<body><div class=\"header\"> <h1>Smart TERA</h1><h2>");
            client.println(timeStamp);
            client.println(" / " + dayStamp);
            client.println("</h2> </div> <div class=\"content\"><h3 style =\"background-color: #ff8000;\">Temperature: ");
            client.println(temperature);
            client.println("&#8451; /  ");
            client.println(temperaturef);
            client.println("&#8457; </h3><h3 style =\"background-color: #4da6ff;\">Humidity: ");
            client.println(humidity);
            client.println("%</h3><div class=\"light\" style=\"background-color: #ffff33;\"><h3>Light Brightness: <span id=\"lightPos\"></span> %</h3> <input class=\"slider\" type=\"range\" min=\"0\" max=\"100\" step=\"25\" value="+brightness+" id=\"myRange\">");
            client.println("<script> var slider = document.getElementById(\"myRange\"); var lightP = document.getElementById(\"lightPos\"); lightP.innerHTML = slider.value; $.ajaxSetup({timeout:1000}); slider.oninput = function() { slider.value = this.value; lightP.innerHTML = this.value; $.get(\"/?value=\" + this.value + \"&\"); {Connection: close};}</script> </div>");

            if(header.indexOf("GET /?value=")>=0) {
                pos1 = header.indexOf('=');
                pos2 = header.indexOf('&');
                valueString = header.substring(pos1+1, pos2);
                if(valueString == "0" ){
                  brightness = "0";
                  analogWrite(relay2, 0);
                } else if (valueString == "25"){
                  brightness = "25";
                  analogWrite(relay2, 256);
                } else if (valueString == "50"){
                  brightness = "50";
                  analogWrite(relay2, 512);
                } else if (valueString == "75"){
                  brightness = "75";
                  analogWrite(relay2, 768);
                } else if (valueString == "100"){
                  brightness = "100";
                  analogWrite(relay2, 1024);
                } 
           }
            // Display current state, and ON/OFF buttons for controlling relays, If the relay0State is off, it displays the ON button  
            client.println("<h4>Rock Heater - State ");      
            if (relay0State == 0) {
              client.println("off</h4><p><a href=\"/0/on\"><button class=\"button\">ON</button></a></p>");
            } else {
              client.println("on</h4><p><a href=\"/0/off\"><button class=\"button button2\">OFF</button></a></p>");
            } 

            client.println("<h4>Humidifier - State ");     
            if (relay1State == 0) {
              client.println("off </h4><p><a href=\"/1/on\"><button class=\"button\">ON</button></a></p>");
            } else {
              client.println("on </h4><p><a href=\"/1/off\"><button class=\"button button2\">OFF</button></a></p>");
            }
            client.println("</div></body></html>");

            // The HTTP response ends with another blank line
            client.println();
            // Break out of the while loop
            yield();
            break;
          } else { // if you got a newline, then clear currentLine
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      } 
    }
    // Clear the header variable and close the connection
    header = "";
    client.stop();
   }
}

Decoded error:


user57606: i had look like this problem before.
for me , when i much used of " Serial.print " this RST fault occur for me..
so i use of a function:
void Serial_Show() {
    Serial.println();
}

maybe your problem is this.
you can test it by deleting all Serial.print() function and next add one by one...

user56976: First, take out the wdt.feed all that does is delay the real problem and/or shift it somewhere else. As a rule of thumb, if you even THINK you have to use / touch / play with / cancel the WDT, your code is already wrong. The root problem is your code is "blocking" longer than the underlying WiFI stack is happy with. A culprit is: while(!timeClient.update()) How long does that take? If it "blocks" then your code will fail. "Multiple" / "Parallel" tasks must run asynchronously and yield() to the backgound WiFi if they are long-running. If you mix old fashioned, blocking code with modern asynchronous code, THIS is exactly what you will get.
Other points: all that println stuff in the main loop is horribly inefficient and won't be helping. Setup the main body of text once and edit / resend the bits that change.
Also I believe DHT11 can sometimes take a while to settle / read. If the library you are using is not optimised for ESP8266 and / or non-blocking, there's another potential source of error. I believe DHT11 can also sometimes return NaN rather than a valid value - how do you cope with that?
There's an async webserver library that does all that side of things properly - you are reinventing a wheel and yours is square. You need to find an async NTP library too. "But I found it in the library examples!" Is NOT a guarantee / justification that the code is a) useful b) any good c) well-written d) functional for any other purpose. In my experience its usually the opposite of all four, especially if you mix two libraries together. It's an "example" - it's not production code.
Final takeaway: 

Use the right library for the right job 
NEVER mess with the WDT 
NEVER mix sync + async code 
Most example ESP8266 code assumes a single function, not needing to cooperate with any other. If you mix / blend separate examples / functions (e.g. DHT11 AND NTP AND WEBSERVER), YOU must provide the co-operation between functions + ESP8266 background WiFi. If you don't (and you haven't) you will cause a WDT reset, 100% guaranteed.


55184: <p>Im using <strong>ESP12E DevKit v2</strong> (esp8266 wifi module) board for controlling relays and displaying DHT22 temp,humidity on web server. 
It runs smoothly when the web client is closed but when i leave the website on for like a 20mins it crashes.
I have installed the ESPdecoder and the stack trace always leads mostly to libraries. I tried using 
  <strong><em>ESP.wdtDisable(); 
   ESP.wdtEnable(WDTO_8S);</em></strong> commands and <strong><em>yield();</em></strong> function but doesnt make any difference.</p>

<p>How can i fix this or what am i doing wrong in the code?</p>

<pre><code>Soft WDT reset

&gt;&gt;&gt;stack&gt;&gt;&gt;

ctx: sys
sp: 3fffed40 end: 3fffffb0 offset: 01b0
3fffeef0:  3ffe93dc c84524b8 60000600 4020ea06  
3fffef00:  00000000 3ffeda08 00000000 00000000  
3fffef10:  4022d488 3ffeda08 3ffee9c0 60000600  
3fffef20:  4022fdd1 3ffeda08 3ffee9c0 c84550ad  
3fffef30:  4022fe16 3fffdab0 00000000 3fffdcb0  
3fffef40:  3ffee9d0 3fffdab0 00000000 40206223  
3fffef50:  40000f49 40000f49 3fffdab0 40000f49  
3fffef60:  40000e19 40001878 00000002 00000000  
3fffef70:  3fffff10 aa55aa55 000000f0 40104ba0  
3fffef80:  40104ba6 00000002 00000000 3715d4f6  
3fffef90:  4010000d 0e060f10 942b6d57 69e0d507  
3fffefa0:  40100b40 3fffef3c 40100aed 3ffffea8  
3fffefb0:  3fffffc0 00000000 00000000 feefeffe  
3fffefc0:  feefeffe feefeffe feefeffe feefeffe  
3fffefd0:  feefeffe feefeffe feefeffe feefeffe  
3fffefe0:  feefeffe feefeffe feefeffe feefeffe  
3fffeff0:  feefeffe feefeffe feefeffe feefeffe  
3ffff000:  feefeffe feefeffe feefeffe feefeffe  
3ffff010:  feefeffe feefeffe feefeffe feefeffe  
3ffff020:  feefeffe feefeffe feefeffe feefeffe  
3ffff030:  feefeffe feefeffe feefeffe feefeffe  
3ffff040:  feefeffe feefeffe feefeffe feefeffe  
3ffff050:  feefeffe feefeffe feefeffe feefeffe  
3ffff060:  feefeffe feefeffe feefeffe feefeffe  
3ffff070:  feefeffe feefeffe feefeffe feefeffe  
3ffff080:  feefeffe feefeffe feefeffe feefeffe  
3ffff090:  feefeffe feefeffe feefeffe feefeffe  
3ffff0a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff0f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff100:  feefeffe feefeffe feefeffe feefeffe  
3ffff110:  feefeffe feefeffe feefeffe feefeffe  
3ffff120:  feefeffe feefeffe feefeffe feefeffe  
3ffff130:  feefeffe feefeffe feefeffe feefeffe  
3ffff140:  feefeffe feefeffe feefeffe feefeffe  
3ffff150:  feefeffe feefeffe feefeffe feefeffe  
3ffff160:  feefeffe feefeffe feefeffe feefeffe  
3ffff170:  feefeffe feefeffe feefeffe feefeffe  
3ffff180:  feefeffe feefeffe feefeffe feefeffe  
3ffff190:  feefeffe feefeffe feefeffe feefeffe  
3ffff1a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff1f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff200:  feefeffe feefeffe feefeffe feefeffe  
3ffff210:  feefeffe feefeffe feefeffe feefeffe  
3ffff220:  feefeffe feefeffe feefeffe feefeffe  
3ffff230:  feefeffe feefeffe feefeffe feefeffe  
3ffff240:  feefeffe feefeffe feefeffe feefeffe  
3ffff250:  feefeffe feefeffe feefeffe feefeffe  
3ffff260:  feefeffe feefeffe feefeffe feefeffe  
3ffff270:  feefeffe feefeffe feefeffe feefeffe  
3ffff280:  feefeffe feefeffe feefeffe feefeffe  
3ffff290:  feefeffe feefeffe feefeffe feefeffe  
3ffff2a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff2f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff300:  feefeffe feefeffe feefeffe feefeffe  
3ffff310:  feefeffe feefeffe feefeffe feefeffe  
3ffff320:  feefeffe feefeffe feefeffe feefeffe  
3ffff330:  feefeffe feefeffe feefeffe feefeffe  
3ffff340:  feefeffe feefeffe feefeffe feefeffe  
3ffff350:  feefeffe feefeffe feefeffe feefeffe  
3ffff360:  feefeffe feefeffe feefeffe feefeffe  
3ffff370:  feefeffe feefeffe feefeffe feefeffe  
3ffff380:  feefeffe feefeffe feefeffe feefeffe  
3ffff390:  feefeffe feefeffe feefeffe feefeffe  
3ffff3a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff3f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff400:  feefeffe feefeffe feefeffe feefeffe  
3ffff410:  feefeffe feefeffe feefeffe feefeffe  
3ffff420:  feefeffe feefeffe feefeffe feefeffe  
3ffff430:  feefeffe feefeffe feefeffe feefeffe  
3ffff440:  feefeffe feefeffe feefeffe feefeffe  
3ffff450:  feefeffe feefeffe feefeffe feefeffe  
3ffff460:  feefeffe feefeffe feefeffe feefeffe  
3ffff470:  feefeffe feefeffe feefeffe feefeffe  
3ffff480:  feefeffe feefeffe feefeffe feefeffe  
3ffff490:  feefeffe feefeffe feefeffe feefeffe  
3ffff4a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff4f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff500:  feefeffe feefeffe feefeffe feefeffe  
3ffff510:  feefeffe feefeffe feefeffe feefeffe  
3ffff520:  feefeffe feefeffe feefeffe feefeffe  
3ffff530:  feefeffe feefeffe feefeffe feefeffe  
3ffff540:  feefeffe feefeffe feefeffe feefeffe  
3ffff550:  feefeffe feefeffe feefeffe feefeffe  
3ffff560:  feefeffe feefeffe feefeffe feefeffe  
3ffff570:  feefeffe feefeffe feefeffe feefeffe  
3ffff580:  feefeffe feefeffe feefeffe feefeffe  
3ffff590:  feefeffe feefeffe feefeffe feefeffe  
3ffff5a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff5f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff600:  feefeffe feefeffe feefeffe feefeffe  
3ffff610:  feefeffe feefeffe feefeffe feefeffe  
3ffff620:  feefeffe feefeffe feefeffe feefeffe  
3ffff630:  feefeffe feefeffe feefeffe feefeffe  
3ffff640:  feefeffe feefeffe feefeffe feefeffe  
3ffff650:  feefeffe feefeffe feefeffe feefeffe  
3ffff660:  feefeffe feefeffe feefeffe feefeffe  
3ffff670:  feefeffe feefeffe feefeffe feefeffe  
3ffff680:  feefeffe feefeffe feefeffe feefeffe  
3ffff690:  feefeffe feefeffe feefeffe feefeffe  
3ffff6a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff6f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff700:  feefeffe feefeffe feefeffe feefeffe  
3ffff710:  feefeffe feefeffe feefeffe feefeffe  
3ffff720:  feefeffe feefeffe feefeffe feefeffe  
3ffff730:  feefeffe feefeffe feefeffe feefeffe  
3ffff740:  feefeffe feefeffe feefeffe feefeffe  
3ffff750:  feefeffe feefeffe feefeffe feefeffe  
3ffff760:  feefeffe feefeffe feefeffe feefeffe  
3ffff770:  feefeffe feefeffe feefeffe feefeffe  
3ffff780:  feefeffe feefeffe feefeffe feefeffe  
3ffff790:  feefeffe feefeffe feefeffe feefeffe  
3ffff7a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff800:  feefeffe feefeffe feefeffe feefeffe  
3ffff810:  feefeffe feefeffe feefeffe feefeffe  
3ffff820:  feefeffe feefeffe feefeffe feefeffe  
3ffff830:  feefeffe feefeffe feefeffe feefeffe  
3ffff840:  feefeffe feefeffe feefeffe feefeffe  
3ffff850:  feefeffe feefeffe feefeffe feefeffe  
3ffff860:  feefeffe feefeffe feefeffe feefeffe  
3ffff870:  feefeffe feefeffe feefeffe feefeffe  
3ffff880:  feefeffe feefeffe feefeffe feefeffe  
3ffff890:  feefeffe feefeffe feefeffe feefeffe  
3ffff8a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8f0:  feefeffe feefeffe feefeffe feefeffe  
3ffff900:  feefeffe feefeffe feefeffe feefeffe  
3ffff910:  feefeffe feefeffe feefeffe feefeffe  
3ffff920:  feefeffe feefeffe feefeffe feefeffe  
3ffff930:  feefeffe feefeffe feefeffe feefeffe  
3ffff940:  feefeffe feefeffe feefeffe feefeffe  
3ffff950:  feefeffe feefeffe feefeffe feefeffe  
3ffff960:  feefeffe feefeffe feefeffe feefeffe  
3ffff970:  feefeffe feefeffe feefeffe feefeffe  
3ffff980:  feefeffe feefeffe feefeffe feefeffe  
3ffff990:  feefeffe feefeffe feefeffe feefeffe  
3ffff9a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9f0:  feefeffe feefeffe feefeffe feefeffe  
3ffffa00:  feefeffe feefeffe feefeffe feefeffe  
3ffffa10:  feefeffe feefeffe feefeffe feefeffe  
3ffffa20:  feefeffe feefeffe feefeffe feefeffe  
3ffffa30:  feefeffe feefeffe feefeffe feefeffe  
3ffffa40:  feefeffe feefeffe feefeffe feefeffe  
3ffffa50:  feefeffe feefeffe feefeffe feefeffe  
3ffffa60:  feefeffe feefeffe feefeffe feefeffe  
3ffffa70:  00000000 00000000 0000001f 40105379  
3ffffa80:  4000050c feefeffe feefeffe feefeffe  
3ffffa90:  40222216 00000030 00000010 ffffffff  
3ffffaa0:  40218973 3fff0884 00000000 00000000  
3ffffab0:  00000a43 00000000 00000a43 3fff07b4  
3ffffac0:  00000a43 00000000 00000020 000000fd  
3ffffad0:  00000005 00000000 00000020 40101696  
3ffffae0:  3ffe96b5 40104a97 3ffed118 40101696  
3ffffaf0:  401023ad 3ffed118 3ffed118 40101696  
3ffffb00:  00000005 00000000 00000020 40101696  
3ffffb10:  3ffe96b5 40104a97 3ffed0f0 4010257e  
3ffffb20:  00000002 00000000 00000020 40101696  
3ffffb30:  3ffe96b2 40104a7c 3ffece48 4010257e  
3ffffb40:  00000001 40103c9f 3ffed878 00000001  
3ffffb50:  40104102 c047a314 401029be 00000100  
3ffffb60:  00000000 00000000 0000001f 40105379  
3ffffb70:  40103be6 00000023 7fffffff 00000002  
3ffffb80:  00000123 3ffed118 3ffe9801 00000008  
3ffffb90:  40102a5b 00080000 3ffedb88 4010257e  
3ffffba0:  00000000 00000000 00002200 4000050c  
3ffffbb0:  3fffc278 40102758 3fffc200 00000022  
3ffffbc0:  3ffffbd0 3ffe9f6c 3ffe9f6c 00000001  
3ffffbd0:  4021bddb 00000030 00000010 ffffffff  
3ffffbe0:  4021bddb 00000001 00000000 0000c005  
3ffffbf0:  0000024e 00000001 ffff7f72 0000888e  
3ffffc00:  000005e0 00000020 401038a1 3ffed830  
3ffffc10:  0000013a 00000000 3fff0c70 000000fd  
3ffffc20:  0000005a 00000001 401049e2 3ffed830  
3ffffc30:  00000000 00000000 00000020 40101696  
3ffffc40:  3ffe96b0 40104a7c 3fff034c 3ffed830  
3ffffc50:  00000001 40103c9f 3ffed830 40101696  
3ffffc60:  40104102 00040000 40229be3 00000001  
3ffffc70:  ffffffff 00000000 3ffe9801 00000008  
3ffffc80:  40229c32 3ffecdd0 3ffefa4c 00000001  
3ffffc90:  40229d3e 3ffecdd0 3ffefa4c 3ffecdd0  
3ffffca0:  00000002 00000000 00000020 40101696  
3ffffcb0:  3ffe96b2 40228cef 3ffecdd0 3fff0c54  
3ffffcc0:  00000000 4021bf97 3ffee2d8 40105379  
3ffffcd0:  00000000 00000002 00000000 3ffecdd0  
3ffffce0:  3fff1882 4010511f 3fff0c54 3fff01dc  
3ffffcf0:  3fff184c 0000002f 00000000 00000001  
3ffffd00:  00000004 4020e2d9 3ffef418 3fff01dc  
3ffffd10:  3fff1882 00000045 00000001 3ffeefc8  
3ffffd20:  3fffff20 3fffff20 0000000a 00000000  
3ffffd30:  3ffef83c 3ffef804 3fff184c 4020e55b  
3ffffd40:  00000002 3ffef804 3fff184c 4020e94c  
3ffffd50:  3ffef6a8 4bc6a7f0 94bc6a7f 00000001  
3ffffd60:  00000001 00000000 4bc6a7f0 3ffef6ac  
3ffffd70:  3ffef83c 00000003 3ffef804 40216024  
3ffffd80:  00000000 3ffee998 8d04d0fb 00000000  
3ffffd90:  00000002 3fff184c 3ffef294 00000000  
3ffffda0:  3ffee9c0 3ffef294 3ffe851c 3fff184c  
3ffffdb0:  00000001 4bc6a7f0 deb851eb 00000001  
3ffffdc0:  00000001 00000000 4bc6a7f0 00000000  
3ffffdd0:  3ffef2bc 000001d3 000001d3 40100664  
3ffffde0:  00000001 00000000 3fff0774 40100aa8  
3ffffdf0:  3b172b21 000001d3 3ffe851c 4020e175  
3ffffe00:  00000001 3ffffe8f 40206268 402036f7  
3ffffe10:  00000001 00000000 3fff0774 40203e3f  
3ffffe20:  00000002 3ffffeae 3fff0774 40203ec5  
3ffffe30:  00000001 4bc6a7f0 8083126e 3fffff40  
3ffffe40:  00000030 0000000a 3fffff40 402057ed  
3ffffe50:  3ffffe8f 000001d3 000001d3 40100664  
3ffffe60:  00000001 4bc6a7f0 3c6a7efa 00000001  
3ffffe70:  00000001 00000000 4bc6a7f0 00000000  
3ffffe80:  00000001 00000000 401001c0 00334411  
3ffffe90:  00000000 000001d3 000001d3 40100664  
3ffffea0:  3b46b3ee 00000000 3ffe851c 00000000  
3ffffeb0:  00000002 3ffe9259 40206268 3fffefa0  
3ffffec0:  00000002 00000000 3fff0774 40203e73  
3ffffed0:  0000000b 00000000 3fff0774 40203ec5  
3ffffee0:  3fffff40 3fe0004f 3fff0774 41cccccd  
3ffffef0:  423c999a 00000000 3fffff40 402057ed  
3fffff00:  3ffe9259 3ffef020 3fffff40 402057ed  
3fffff10:  3ffe8be4 3ffef020 3fffff40 40205818  
3fffff20:  423c999a 3ffef020 3fffff40 40205864  
3fffff30:  429a0000 3ffef020 3ffef03c 40202cc9  
3fffff40:  40206988 00000000 00001388 40206738  
3fffff50:  00000000 3fff0774 00000000 00000000  
3fffff60:  00000000 00000000 00000000 00000000  
3fffff70:  3fff0ccc 0000007f 00000000 feefeffe  
3fffff80:  429c28f6 00000000 42473333 feefeffe  
3fffff90:  00000000 00000000 00000001 3ffef238  
3fffffa0:  3fffdad0 00000000 3ffef208 40206314  
&lt;&lt;&lt;stack&lt;&lt;&lt;

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)
</code></pre>

<p><strong>My code:</strong> </p>

<pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;DHT.h&gt;
#include &lt;NTPClient.h&gt;
#include &lt;WiFiUdp.h&gt;
#define DHTTYPE DHT22

const char* ssid = "ID";
const char* password = "pass";
const char* ssid2 = "ID2";
const char* password2 = "pass2";

// Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);

WiFiServer server(80); // Set web server port number to 80
String header; // Variable to store the HTTP request

// Decode HTTP GET value
String valueString = "0";
int pos1 = 0;
int pos2 = 0;

// Variables to store the current output state
int relay0State = 0;
int relay1State = 0;
int relay2State = 0;
String brightness = "0";

// Variables to save date and time
String formattedDate;
String dayStamp;
String timeStamp;

// Variables assigned to pins
const int relay0 = 16;
const int relay1 = 5;
const int relay2 = 4;
const int DHT1Pin = 0;
const int DHT2Pin = 2;

// Initialize DHT sensors
DHT dht1(DHT1Pin, DHTTYPE);
DHT dht2(DHT2Pin, DHTTYPE);

void setup() {
  //Watchdog timer settings
  ESP.wdtDisable();
  ESP.wdtEnable(WDTO_8S); 

  Serial.begin(115200);
  // Initialize the output variables as outputs
  pinMode(relay0, OUTPUT);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  // Set outputs to LOW
  digitalWrite(relay0, LOW);
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);

  dht1.begin();
  dht2.begin();

  // Connect to available Wi-Fi network with SSID and password
  Serial.print("Connecting to ");
  int n = WiFi.scanNetworks();
  if (n == 0)
    Serial.println("No networks found!");
  else {
    for(int i=0;i&lt;n;i++) {
      if(WiFi.SSID(i)==ssid) {
        WiFi.begin(ssid,password);
        ssid = ssid;
      } else if (WiFi.SSID(i)== ssid2) {
        WiFi.begin(ssid2,password2);
        ssid = ssid2;
      } 
    }
  }
  Serial.println(ssid);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  // Print local IP address and start web server
  Serial.println("");
  Serial.println("WiFi CONNECTED with IP: ");
  Serial.println(WiFi.localIP());
  server.begin();
  timeClient.begin(); // Initialize a NTPClient to get time
  timeClient.setTimeOffset(7200); // Setting offset time in seconds to adjust for current timezone -&gt; GMT +1 = 3600
}

void loop(){
  ESP.wdtFeed(); //Feed the watchdog timer
  WiFiClient client = server.available();   // Listen for incoming clients

   while(!timeClient.update()) {
    timeClient.forceUpdate();
  }
  formattedDate = timeClient.getFormattedDate(); // The formattedDate comes with the following format 2018-05-28T16:00:13Z
  // Extract date
  int splitT = formattedDate.indexOf("T");
  dayStamp = formattedDate.substring(0, splitT);
  // Extract time
  timeStamp = formattedDate.substring(splitT+1, formattedDate.length()-1);

  if (client) {                             
    String currentLine = "";               // String to hold incoming data from the client
    while (client.connected()) {           // loop while the client's connected
      if (client.available()) {            // if there's bytes to read from the client,
        char c = client.read();            // read a byte, then
        header += c;
        if (c == '\n') {                    // if the byte is a newline character
                                            // if the current line is blank, you got two newline characters in a row. That's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();

            // Read humidity 
            float h1 = dht1.readHumidity();
            float h2 = dht2.readHumidity();
            // Read temperature as Celsius (the default)
            float t1 = dht1.readTemperature();
            float t2 = dht2.readTemperature();
            // Read temperature as Fahrenheit (isFahrenheit = true)
            float f1 = dht1.readTemperature(true);
            float f2 = dht2.readTemperature(true);

            // Calculating average temp and humidity from DHT22 sensors
            float temperature = (t1 + t2)/2;
            float temperaturef = (f1 + f2)/2;
            float humidity = (h1 + h2)/2;

            if(header.indexOf("GET /1/") | header.indexOf("GET /0/") &lt; 0){
                if(humidity &lt; 50){
                relay1State = 1;
                digitalWrite(relay1, HIGH);
              } else {
                relay1State = 0;
                digitalWrite(relay1, LOW);
              }
              if(temperature &lt; 23) {
                relay0State = 1;
                digitalWrite(relay0, HIGH);
              } else {
                relay0State = 0;
                digitalWrite(relay0, LOW);
              }
            }

            if (header.indexOf("GET /0/on") &gt;= 0) {
              relay0State = 1;
              digitalWrite(relay0, HIGH);
            } else if (header.indexOf("GET /0/off") &gt;= 0) {
              relay0State = 0;
              digitalWrite(relay0, LOW);
            } else if (header.indexOf("GET /1/on") &gt;= 0) {
              relay1State = 1;
              digitalWrite(relay1, HIGH);
            } else if (header.indexOf("GET /1/off") &gt;= 0) {
              relay1State = 0;
              digitalWrite(relay1, LOW);
            }

            // Display the HTML web page
            client.println("&lt;!DOCTYPE html&gt;&lt;html&gt;");
            client.println("&lt;head&gt;&lt;meta http-equiv=\"refresh\" content=\"1\" name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;");
            client.println("&lt;script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\"&gt;&lt;/script&gt;");
            client.println("&lt;style&gt; html {font-family: Helvetica; display: inline-block; margin: 0px; text-align: center; height: auto; box-sizing: border-box;} h1, h2{width: 100%; color: #444444; font-size: 55px;} h2 {font-size: 30px;} h3, h4 {width: 50%; font-size: 24px; color: #444444; padding: 18px; margin: 10px; border-radius: 35px; margin: 4px auto;} h4 {padding: 5px;} .button {background-color: #4CAF50; border: none; color: white; padding: 16px 40px; text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;} .button2 {background-color: #555555;} .content {width: 100%; } .light {border-radius: 35px; width: 50%; margin: 4px auto;} .slider {-webkit-appearance: none; width: 30%; height: 10px; border-radius: 5px; margin-bottom: 20px; background: #d3d3d3; outline: none; } .slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #444444; cursor: pointer;} @media (max-width: 1000px) {h1{font-size: 40px;} h2{font-size: 25px;} h3,h4{width: 75%; font-size: 20px;} .light{ width: 75%;}}&lt;/style&gt;&lt;title&gt;Smart TERA&lt;/title&gt; &lt;/head&gt; ");
            client.println("&lt;body&gt;&lt;div class=\"header\"&gt; &lt;h1&gt;Smart TERA&lt;/h1&gt;&lt;h2&gt;");
            client.println(timeStamp);
            client.println(" / " + dayStamp);
            client.println("&lt;/h2&gt; &lt;/div&gt; &lt;div class=\"content\"&gt;&lt;h3 style =\"background-color: #ff8000;\"&gt;Temperature: ");
            client.println(temperature);
            client.println("&amp;#8451; /  ");
            client.println(temperaturef);
            client.println("&amp;#8457; &lt;/h3&gt;&lt;h3 style =\"background-color: #4da6ff;\"&gt;Humidity: ");
            client.println(humidity);
            client.println("%&lt;/h3&gt;&lt;div class=\"light\" style=\"background-color: #ffff33;\"&gt;&lt;h3&gt;Light Brightness: &lt;span id=\"lightPos\"&gt;&lt;/span&gt; %&lt;/h3&gt; &lt;input class=\"slider\" type=\"range\" min=\"0\" max=\"100\" step=\"25\" value="+brightness+" id=\"myRange\"&gt;");
            client.println("&lt;script&gt; var slider = document.getElementById(\"myRange\"); var lightP = document.getElementById(\"lightPos\"); lightP.innerHTML = slider.value; $.ajaxSetup({timeout:1000}); slider.oninput = function() { slider.value = this.value; lightP.innerHTML = this.value; $.get(\"/?value=\" + this.value + \"&amp;\"); {Connection: close};}&lt;/script&gt; &lt;/div&gt;");

            if(header.indexOf("GET /?value=")&gt;=0) {
                pos1 = header.indexOf('=');
                pos2 = header.indexOf('&amp;');
                valueString = header.substring(pos1+1, pos2);
                if(valueString == "0" ){
                  brightness = "0";
                  analogWrite(relay2, 0);
                } else if (valueString == "25"){
                  brightness = "25";
                  analogWrite(relay2, 256);
                } else if (valueString == "50"){
                  brightness = "50";
                  analogWrite(relay2, 512);
                } else if (valueString == "75"){
                  brightness = "75";
                  analogWrite(relay2, 768);
                } else if (valueString == "100"){
                  brightness = "100";
                  analogWrite(relay2, 1024);
                } 
           }
            // Display current state, and ON/OFF buttons for controlling relays, If the relay0State is off, it displays the ON button  
            client.println("&lt;h4&gt;Rock Heater - State ");      
            if (relay0State == 0) {
              client.println("off&lt;/h4&gt;&lt;p&gt;&lt;a href=\"/0/on\"&gt;&lt;button class=\"button\"&gt;ON&lt;/button&gt;&lt;/a&gt;&lt;/p&gt;");
            } else {
              client.println("on&lt;/h4&gt;&lt;p&gt;&lt;a href=\"/0/off\"&gt;&lt;button class=\"button button2\"&gt;OFF&lt;/button&gt;&lt;/a&gt;&lt;/p&gt;");
            } 

            client.println("&lt;h4&gt;Humidifier - State ");     
            if (relay1State == 0) {
              client.println("off &lt;/h4&gt;&lt;p&gt;&lt;a href=\"/1/on\"&gt;&lt;button class=\"button\"&gt;ON&lt;/button&gt;&lt;/a&gt;&lt;/p&gt;");
            } else {
              client.println("on &lt;/h4&gt;&lt;p&gt;&lt;a href=\"/1/off\"&gt;&lt;button class=\"button button2\"&gt;OFF&lt;/button&gt;&lt;/a&gt;&lt;/p&gt;");
            }
            client.println("&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;");

            // The HTTP response ends with another blank line
            client.println();
            // Break out of the while loop
            yield();
            break;
          } else { // if you got a newline, then clear currentLine
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      } 
    }
    // Clear the header variable and close the connection
    header = "";
    client.stop();
   }
}
</code></pre>

<p><strong>Decoded error:</strong>
<a href="https://i.stack.imgur.com/N5Tks.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N5Tks.png" alt="stacktrace"></a></p>
 57606: <p>i had look like this problem before.
for me , when i much used of " Serial.print " this RST fault occur for me..
so i use of a function:</p>

<pre><code>void Serial_Show() {
    Serial.println();
}
</code></pre>

<p>maybe your problem is this.
you can test it by deleting all Serial.print() function and next add one by one...</p>
 56976: <p>First, take out the wdt.feed all that does is delay the real problem and/or shift it somewhere else. As a rule of thumb, if you even THINK you have to use / touch / play with / cancel the WDT, your code is already wrong. The root problem is your code is "blocking" longer than the underlying WiFI stack is happy with. A culprit is: while(!timeClient.update()) How long does that take? If it "blocks" then your code will fail. "Multiple" / "Parallel" tasks must run asynchronously and yield() to the backgound WiFi if they are long-running. If you mix old fashioned, blocking code with modern asynchronous code, THIS is exactly what you will get.</p>

<p>Other points: all that println stuff in the main loop is horribly inefficient and won't be helping. Setup the main body of text once and edit / resend the bits that change.</p>

<p>Also I believe DHT11 can sometimes take a while to settle / read. If the library you are using is not optimised for ESP8266 and / or non-blocking, there's another potential source of error. I believe DHT11 can also sometimes return NaN rather than a valid value - how do you cope with that?</p>

<p>There's an async webserver library that does all that side of things properly - you are reinventing a wheel and yours is square. You need to find an async NTP library too. "But I found it in the library examples!" Is NOT a guarantee / justification that the code is a) useful b) any good c) well-written d) functional for any other purpose. In my experience its usually the opposite of all four, especially if you mix two libraries together. It's an "example" - it's not production code.</p>

<p>Final takeaway: </p>

<ol>
<li>Use the right library for the right job </li>
<li>NEVER mess with the WDT </li>
<li>NEVER mix sync + async code </li>
<li>Most example ESP8266 code assumes a single function, not needing to cooperate with any other. If you mix / blend separate examples / functions (e.g. DHT11 AND NTP AND WEBSERVER), YOU must provide the co-operation between functions + ESP8266 background WiFi. If you don't (and you haven't) you will cause a WDT reset, 100% guaranteed.</li>
</ol>
