Arduino Mega Temperature and humidity monitoring stops working

Hi All,

I'm a new one on this forum, so I hope I will do everything as I should. I'm also fresh with Arduino, so I will be asking a lot of basic questions. I did some research on the issue I'm having, but I don't know where to start, because there are so many options.

I set up an Arduino Mega with Ethernet Shield.
The Arduino Mega is: https://si.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=15001&langId=386&urlRequestType=Base&partNumber=2830990&storeId=10175
and the Ethernet Shield is: https://www.amazon.de/gp/product/B009N826DY/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1
Power supply is 5V over the USB port.
For displaying the graphs I'm using the Blynk App.

I have connected 4x digital temperature sensors DS18B20 with 4.7k pull up resistors and 2x DTH22 digital temperature and humidity sensors at first with no pull up resistor, later I have added the 4.7k pull up resistors to the DTH22 also.

The issue I'm having is following:

  • after powering up the unit it all works fine for about 1 - 6 hours
  • after that I stop getting results from one of the DTH22 sensors (both temperature and humidity at the same time.
  • about half an hour later, I stop getting the results from the second DTH22 sensor also
  • and some time after that (few hour) the unit is down from Blynk also, so it seems as the Network Shield would go down

This is the code I'm using:

//______________________________________kniznice_____________________________________________________
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#include <DHT.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
char auth[] = "xxx";
SimpleTimer timer;

//_______________________________________senzorji___________________________________________________
#define DHTPIN1 7
#define DHTPIN2 8
#define DHTPIN3 9
#define DHTTYPE DHT22
DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
//DHT dht3(DHTPIN3, DHTTYPE);
#define ONE_WIRE_BUS1 2
#define ONE_WIRE_BUS2 3
#define ONE_WIRE_BUS3 5
#define ONE_WIRE_BUS4 6
#define W5100_CS  10
#define SDCARD_CS 4
OneWire oneWire1(ONE_WIRE_BUS1);
OneWire oneWire2(ONE_WIRE_BUS2);
OneWire oneWire3(ONE_WIRE_BUS3);
OneWire oneWire4(ONE_WIRE_BUS4);
DallasTemperature sensor1(&oneWire1);
DallasTemperature sensor2(&oneWire2);
DallasTemperature sensor3(&oneWire3);
DallasTemperature sensor4(&oneWire4);
BlynkTimer timer1;
BlynkTimer timer2;
BlynkTimer timer3;
//BlynkTimer timer4;
//____________________________________________________________________________________________________
BLYNK_CONNECTED() {
  Blynk.syncAll();            //sinhroniziranje nastavitev iz Blynka
  }
 // WidgetLED led1(6); //virtual led 
 // WidgetLED led2(7); //virtual led
 // WidgetLED led3(8); //virtual led
  //______________________________________merjenje nivoja vode___________________________________________
/*
void Nvode()
{
  int nivovode=digitalRead(A0);
  //Serial.println(Vinfo);
  delay(10);
  if (nivovode == HIGH) {
    Blynk.virtualWrite(V9, 0);
  }else {
    Blynk.virtualWrite(V9, 1);
  }
}
*/
//________________________________________driver za senzorje__________________________________________
void senzorji()
{
  Blynk.virtualWrite(V5, sensor1.getTempCByIndex(0));
  Blynk.virtualWrite(V6, sensor2.getTempCByIndex(0));
  Blynk.virtualWrite(V7, sensor3.getTempCByIndex(0)); 
  Blynk.virtualWrite(V8, sensor4.getTempCByIndex(0));
  sensor1.requestTemperatures();
  sensor2.requestTemperatures();
  sensor3.requestTemperatures();
  sensor4.requestTemperatures();
}
//______________________________________________DHT__________________________________________________________

void Dht1()
{
  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
 if (isnan(h1) || isnan(t1)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V2, h1);
  Blynk.virtualWrite(V1, t1);
}

void Dht2()
{
   float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();
 if (isnan(h2) || isnan(t2)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V4, h2);
  Blynk.virtualWrite(V3, t2);
}
/*
void Dht3()
{
  float h3 = dht3.readHumidity();
  float t3 = dht3.readTemperature();
 if (isnan(h3) || isnan(t3)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V10, h3);
  Blynk.virtualWrite(V9, t3);
}
*/
//___________________________________________nastavitve programa_______________________________________
void setup() 
{
//___________________________________________nastavlanje shilda__________________________________________
  Serial.begin(9600);
  Blynk.begin(auth);
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); 
//___________________________________________vklop senzorjev_____________________________________________
  sensor1.begin();
  sensor2.begin();
  sensor3.begin();
  sensor4.begin();
  timer1.setInterval(1000L, senzorji);
  timer2.setInterval(1000L, Dht1);
  timer3.setInterval(1000L, Dht2);
  //timer4.setInterval(1000L, Dht3);
//_________________________________________povezovanje z blynkom__________________________________________
  Blynk.config(auth);
  Blynk.syncAll();
  Serial.println("povezan.");
  dht1.begin();
}
  void loop() 
{
  Blynk.run(); 
  timer1.run();
  timer2.run();
  timer3.run();
  //timer4.run();
}

If someone could help me solving this issue, I would be grateful.

Regards,