Nodemcu stops sending the messages to the API Here is my code which sends some data to the firebase cloud functions. The code works well and the nodemcu sends the data to the cloud for about half an hour and then stops sending the messages.

#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;
#include &lt;ESP8266WiFi.h&gt;
#include &lt;WiFiClientSecure.h&gt;

#define ONE_WIRE_BUS 5

// Use WiFiClientSecure class to create TLS connection
WiFiClientSecure client;

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&amp;oneWire);
String data="";
const char* ssid = "***************";
const char* password = "**************";

const char* host = "**************************";
const int httpsPort = 443;

String url = "/getData";
float Celcius=0;
float Fahrenheit=0;
int sensor_light;
int sensor_temp;
int sensor_moist;
void setup() {
ESP.wdtDisable();
pinMode(16,OUTPUT);//moist
pinMode(0,OUTPUT);//light
Serial.begin(115200);  //Serial connection
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());

Serial.print("connecting to ");
Serial.println(host);
if (!client.connect(host, httpsPort)) {
Serial.println("connection failed");
return;
}
ESP.wdtEnable(WDTO_8S); 
}
void loop()
{ 
 client.connect(host, httpsPort);
 int l,m,t;
 data=" ";
 l=get_light();
 t=get_temp();
 m=get_moist();
 if(WiFi.status()== WL_CONNECTED){
    data+="{";
    data+="\"";
    data+="Node-Id";
    data+="\"";
    data+=":";
    data+=1;
    data+=",";
    data+="\"";
    data+="light";
    data+="\"";
    data+=":";
    data+=l;
    data+=",";
    data+="\"";
    data+="temperature";
    data+="\"";
    data+=":";
    data+=t;
    data+=",";
    data+="\"";
    data+="humidity";
    data+="\"";
    data+=":";
    data+=m;
    data+=",";
    data+="\"";
    data+="Latitude";
    data+="\"";
    data+=":";
    data+=29.3589362;
    data+=",";
    data+="\"";
    data+="Longitude";
    data+="\"";
    data+=":";
    data+=79.5506528;
    data+="} ";
    Serial.println(data);
    client.print(String("POST ") + url + " HTTP/1.1\r\n" +
           "Host: " + host + "\r\n" +
           "Connection: close\r\n"+   
           "Content-Length: " + data.length()+ "\r\n" +
           "Content-Type: application/json;charset=UTF-8\r\n\r\n"+
            data +"\r\n");
    //  Serial.println("Sent"); 
    String line = client.readStringUntil('\n');
    Serial.println(line);
    while(!client.connected())
        { client.stop();
          ESP.wdtFeed();
         }
     }
    delay(4000); 
    }

    int get_light()
    {   
    digitalWrite(0, HIGH); 
    sensor_light=0;
    sensor_light = analogRead(A0);
    digitalWrite(0, LOW);
    delay(2000);
    return sensor_light; 
    }
    int get_temp()
    {
    int  sum=0,i;
    for(i=0;i&lt;10;i++)
      {
    sensors.requestTemperatures(); 
    Celcius=sensors.getTempCByIndex(0);
    delay(250);
    sum+=Celcius;
    }
    Celcius=sum/20;
    delay(2000);
    return Celcius;
    }

    int get_moist()
    { 
     digitalWrite(16, HIGH); 
    sensor_moist=0;
    sensor_moist = analogRead(A0);
    digitalWrite(16, LOW);
    delay(2000);
    return sensor_moist;
    }


If I do not use ESP.wdtFeed() and other similar functions then I am getting Soft wdt reset error. I am using the laptop to power it. Any help?
Remove the return in setup function and check. And set regular yield () statements to ensure smooth running of background tasks. And use if statement in the loop for !client.connected()