Esp8266 DHT11 get disconnected from sever

Hello
i am new… so please bear with me if the code is not good

My project is to monitor two area with DHT11 an to see those value over the web with the Blynk app on a iOs phone

It with a ESP8266 and DHt11

the code is running but after few hour it stop… the esp8266 get disconnected from my home internet

Any help would be appreciated

// Example testing DHT11 humidity/temperature sensors
// Demonstrates multiple Temperature sensors

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

#define DHT1TYPE DHT11   // Using Temperature Type = DHT11//
#define DHT4PIN 4        // what pin we're connected to ?//
#define DHT2PIN 2       // what pin we're connected to ?//

// Auth Token in the Blynk App.
char auth[] = "TTTT"; //Enter the Auth code which was send by Blink

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXX";  //Enter your WIFI Name
char pass[] = "ZZZZ";  //Enter your WIFI Password

///////////////////////////////////
DHT dht4(DHT4PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT1TYPE);
 
//Connection process
void setup() 
     {
      Serial.begin(9600); 
      //Serial.println("Connection in Process Please Wait");
      Blynk.begin(auth, ssid, pass);
      dht4.begin();
      dht2.begin();
     }

// Reading temperature or humidity
void loop() 
    {
     delay(2000);
     float h1 = dht2.readHumidity();
     float t1 = dht2.readTemperature();
     float h2 = dht4.readHumidity();
     float t2 = dht4.readTemperature();
 
    // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t1) || isnan(h1))
    {
    //Serial.println("Failed to read from DHT #1");
    }
    else
    {
     //Serial.print("Temperature 1 = "); 
     //Serial.print(t1,0);
     //Serial.print(" C");   
     //Serial.print("   Humidity 1 = "); 
     //Serial.print(h1,0);
     //Serial.println(" %\t");
    }
  if (isnan(t2) || isnan(h2)) 
    {
     //Serial.println("Failed to read from DHT #2");
    }
    else 
    { 
     //Serial.print("Temperature 2 = "); 
     //Serial.print(t2,0);
     //Serial.print(" C");
     //Serial.print("   Humidity 2 = "); 
     //Serial.print(h2,0);
     //Serial.println(" %\t");
     }
    {
// Sending Blynk values.
     Blynk.virtualWrite(V5, h1);  //V5 is for Humidity
     Blynk.virtualWrite(V6, t1);  //V6 is for Temperature
     Blynk.virtualWrite(V7, h2);  //V7 is for Humidity
     Blynk.virtualWrite(V8, t2);  //V8 is for Temperature
     }  
}

@PW43575 please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

done… sorry for that

The problem is being caused by your void loop.

You should read this:

Also, you are reading the DHT11 too frequently. These sensors are very slow, and I wouldn’t recommend reading them any more than once every 5 seconds.

So, when you restructure your code and remove the delay(2000) and replace it with a timer, set the timer to around 5000ms.

Pete.

Tks so much… i will do my homework :wink: