I connected nodemcu with batteries and uploaded a code which sends http post request every 10 min and goes to deep sleep. But after 2 hours node mcu stops sending the data. Voltage regulator used is LD33V
Used AA batteries.
Battery level when stopped working was 2.5V.(Do not know why the power consumption was high though we used deepsleep mode).
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266HTTPClient.h>
long duration, distance;
char* ssid = "****";
char* password = "******";
void connectWiFi() {
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid, password);
delay(5000);
}
}
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
connectWiFi();
WiFiClientSecure client;
distance = 4;
String data = " {\"value\":"+String(distance)+"}";
if(client.connect("********.com",443)){
client.println("POST /****/**** HTTP/1.1");
client.println("Host:********.com");
client.println("Content-Type:application/json");
client.println("x-apikey:******************");
client.print("Content-Length: ");
client.println(data.length());
client.println("");
client.println(data);
}
delay(1000);
ESP.deepSleep(600000000);
}
void loop() {
}