Esp8266 sleep offline issues

Hi I’m monitoring a greenhouse and for the most part it is working great. Unfortunately I can’t figure out why it goes offline for a period of time. No pattern, sometimes it will be fine for weeks, other times days. Most of the time it will reconnect after an few hours again but not always the case. Below is my code, I apologize if it is messy I’ve compiled it together from others.


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TimeLib.h>
#include <DHT.h>
#include <SimpleTimer.h>

#define ONE_WIRE_BUS 0
#define TWO_WIRE_BUS 4
#define THREE_WIRE_BUS 19

#define DHTPIN 13
#define DHTPIN1 12
#define DHTTYPE DHT22
#define DHTTYPE1 DHT21

const int LED_PIN = 5; // Thing's onboard, green LED

// Time to sleep (in seconds):
const int sleepTimeS = 60;

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensorA(&oneWire);
OneWire twoWire(TWO_WIRE_BUS);
DallasTemperature sensorB(&twoWire);
OneWire threeWire(THREE_WIRE_BUS);
DallasTemperature sensorC(&twoWire);


DHT dht(DHTPIN, DHTTYPE);
DHT dht1(DHTPIN1, DHTTYPE1);

SimpleTimer timer;

float humidity, temp_f; // Values read from sensor

char auth[] = "d7508302c13f4727ad5b6e9f7c5"; // thing 4cd36f13454c56c6b80038958 forwifi  7a2c5d52b3bf45a9d4c1b0ef504  test 91b23bee09549eb8c7d2b885c32ed


void sendData() {

  float h = dht.readHumidity();
  delay(300);
  float t = dht.readTemperature();
  delay(300);
  float h1 = dht1.readHumidity();
  delay(300);
  float t1 = dht1.readTemperature();
  delay(300);
  
  sensorA.requestTemperatures();
  sensorB.requestTemperatures();// Polls the sensors
  sensorB.requestTemperatures();

  delay(300);

  float tempHotTub1 = sensorA.getTempCByIndex(0);
  float tempHotTub2 = sensorB.getTempCByIndex(0);// Gets first probe on wire in lieu of by address
  float tempHotTub3 = sensorC.getTempCByIndex(0);

  Blynk.virtualWrite(4, tempHotTub1);
  Blynk.virtualWrite(5, tempHotTub2);
  Blynk.virtualWrite(6, tempHotTub3);

  Blynk.virtualWrite(11, h);
  Blynk.virtualWrite(10, t);
  Blynk.virtualWrite(13, h1);
  Blynk.virtualWrite(12, t1);
  Blynk.virtualWrite(20, LED_PIN);

  if (t < 6) {
    Blynk.notify("cold below 6");
  }

  if (t > 25) {
    Blynk.notify("temp above 25");

  }

  // at if (t1 < 25)
  if (t > 25) {
    digitalWrite(LED_PIN, HIGH);
  } else {
    digitalWrite(LED_PIN, LOW);
  }



  // if (t < 0){
  // Blynk.email("m_robe1@me.com", "LOW ALARM", "Temp is below 0C");
  // }

  // if (t > 55){
  // Blynk.email("m_rober1@me.com", "HIGH ALARM", "Temp is above 45C");
  delay(16000);

  ESP.deepSleep(sleepTimeS * 6000000);

  delay(300);
}




void setup() {

  Serial.begin(9600); // See the connection status in Serial Monitor
  timer.setInterval(8000, sendData);

  pinMode(5, OUTPUT); // on board LED on/off button from app
  digitalWrite(5, HIGH);
  delay(300);
  digitalWrite(5, LOW);
  delay(300);
  digitalWrite(5, HIGH);
  delay(300);
  digitalWrite(5, LOW);

  delay(500);

  Blynk.begin(auth, "McGill", "$tra3re"); //insert here your SSID and password

  delay(2000);

  sensorA.begin();
  sensorB.begin();
  sensorC.begin();

  delay(200);

  Serial.print("device alive, go  to phone app");
  digitalWrite(5, HIGH);
  delay(300);
  digitalWrite(5, LOW);
  delay(300);
  digitalWrite(5, HIGH);
  delay(300);
  digitalWrite(5, LOW);

delay(300);


}


void loop() {



  Blynk.run();
  timer.run();


}


I thought it might have been a distance issue with wifi but I have brought it inside for the winter and it is still doing it. Here you can see it has been offline since this morning. I’ll upload another pic once it reconnects. If I reset my esp it will reconnect as well.

Thanks