Due y w5500

Hello, i try made a control of lights y sensors PIR, i have a problem whit the w5500, i supous it hangs, because when the web not response i conect board to usb, i open and conect the terminal to serial port, then y have response of the web again, but while the web not respons, if de alarm is active, the board send sms same if the pir active, i supose the board follow running.
I dont know because i have this problem.
Sorry for my english.
Attach code and picture (https://1drv.ms/u/s!AhhKR3kOC87bgdFa31ya90rBraXv_w)
Thanks

#include <SimpleDHT.h>
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>


byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 0, 49);
EthernetServer server(80);

//Lector de DHT11 Temperatura y Humedad
int pinDHT11 = 7;
SimpleDHT11 dht11(pinDHT11);
byte temperature = 0;
byte humidity = 0;
long tiempo = 0;

//Pines y Variables de Reles y sensores

int luzL = 22;
int luzO = 23;
int ledpir = 5;
int pir = 28;
int pirState = LOW;


//Strings de estado y lectura
String readString = String(30);
String estadosms = String(3);
String estadoPir = String(15);

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
  Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  Serial1.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Ethernet WebServer Example");

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected");
  }

  // start the server
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());

  pinMode(luzL, OUTPUT);
  pinMode(luzO, OUTPUT);
  pinMode(pir, INPUT);
  pinMode(ledpir, OUTPUT);
  digitalWrite(ledpir, LOW);
  digitalWrite(luzL, HIGH);
  digitalWrite(luzO, HIGH);
  estadosms = "Des";
}


void loop() {
  // listen for incoming clients



  
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    bool currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        if (readString.length() < 30) //Leemos petición HTTP caracter a caracter
        {
          readString.concat(c); //Almacenar los caracteres en la variable readString
        }
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {

          int RluzL = readString.indexOf("RluzL=");
          int RluzO = readString.indexOf("RluzO=");
          int sms = readString.indexOf("sms=");
          
         if(readString.substring(RluzL, RluzL + 7)=="RluzL=T"){
             encender("luzL");
          //digitalWrite(luzL, LOW);
          //EnviarSMS("Probando Enviar SMS, Prende luz");
         }
         if(readString.substring(RluzO, RluzO + 7)=="RluzO=T"){
          encender("luzO");
          //digitalWrite(luzL, HIGH);
         // EnviarSMS("Probando Enviar SMS, Prende luz");
         }
         if(readString.substring(sms, sms + 5)=="sms=T"){
          Serial.println("entra al sms1");
          if(estadosms == "Des"){
            estadosms = "Arm";
            Serial.println("estado arm");
            }else {
              estadosms = "Des";
            }
         }
         
          
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          //client.println("Refresh: 15");  // refresh the page automatically every 15 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println("<center>");
          client.print("<body><h1>Situacion Ambiente</h1> <h2><p> ");
          client.print(temphum());// Aqui va la temperatura
          client.print("</p>");
          client.print("</h2>");
          client.print("<p><h2>PirEstado:  ");
          client.print("Estado pir");//Variables del estado del Pir
          client.print("</p></h2>");
          client.print("<p><h2>On/Off Luces:  ");
          client.println("<input type=submit value=LuzL style=width:100px;height:35px onClick=location.href='./?RluzL=T\'>");
          client.println("<input type=submit value=LuzO style=width:100px;height:35px onClick=location.href='./?RluzO=T\'>");
          client.print("<p><h2>Alarma:  ");
          client.println("<input type=submit value=Sms style=width:100px;height:35px onClick=location.href='./?sms=T\'>");
          client.print("Estado: ");
          client.print(estadosms);
          client.print("</p></h2>");
          client.print("<p><h2>Estado Sensores:  "+estadoPir);
          client.print("</p></h2>");
          client.println("</center>");
          client.println("</body>");       
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
    readString = "";
  }

          controlPir(estadosms);
        

  
}

String temphum (){
  
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT11 failed, err="); Serial.println(err);tiempo = millis();
    //return;
  } 
int  temp = ((int)temperature); 
int  hum = ((int)humidity);
      
      String output = "Datos: ";
      output += "Temp: ";
      output += temp;
      output += " C - Hume: ";
      output += hum;
      output += " %";
  return output;   
}

void EnviarSMS (String pir) {
  //Se establece el formato de SMS en ASCII
  Serial1.println("AT+CMGF=1");
  delay(1000);

  //Enviar comando para un nuevos SMS al numero establecido
  Serial1.println("AT+CMGS=\"+59899707574\"");
  delay(1000);

  //Enviar contenido del SMS
  Serial1.print("Se activo el Sensor: " + pir);
  delay(1000);

  //Enviar Ctrl+Z
  Serial1.print((char)26);
  delay (1000);

  //Serial.println("Enviando sms...");
}

void encender (String dato){

  if (dato == "luzL"){
    if (digitalRead(luzL)==LOW){
      digitalWrite(luzL, HIGH);
    }else{
      digitalWrite(luzL, LOW);
    }
  }

  if (dato == "luzO"){
    if (digitalRead(luzO)==LOW){
      digitalWrite(luzO, HIGH);
    }else{
      digitalWrite(luzO, LOW);
    }
  }

}

void controlPir(String estado){
  if(estado == "Arm"){
    int val = digitalRead(pir);
    
   if (val == HIGH) {   //si está activado
         
      if (pirState == LOW){ //si previamente estaba apagado
             // Serial.println("Sensor activado");
       if (millis()-tiempo>15000){
            EnviarSMS("Se activo PIR");
            digitalWrite(luzL, LOW);
            digitalWrite(ledpir, LOW);
            tiempo = millis();          
            pirState = HIGH;
          }
       } else {
        digitalWrite(ledpir, LOW);
       }
   }else {  //si esta desactivado
    if(millis()-tiempo>15000){
      digitalWrite(luzL, HIGH);
      digitalWrite(ledpir, HIGH);
    }
      if (pirState == HIGH)  //si previamente estaba encendido
       {
        //Serial.println("Sensor parado");
         pirState = LOW;
       }
}
  }else{
    int prueba = digitalRead(pir);
      if(prueba == HIGH){
        estadoPir="Movimiento";
      }else{
        estadoPir="Todo quieto";
      }
  }
}