3

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() {

}
  • Did you checked the voltage of your battery after use? Please include what kind of batteries were you using? What was their voltage? – ron123456 Jul 24 '18 at 05:16
  • @ron123456 included. – a-c-sreedhar-reddy Jul 24 '18 at 05:21
  • have you checked your current consumption, when in deep sleep and when not in deep sleep? Is your controller getting heated up? – ron123456 Jul 24 '18 at 05:40
  • @ron123456 should I stop client . client.stop() – a-c-sreedhar-reddy Jul 24 '18 at 05:42
  • 1
    I am not sure whether that will help. You can go through these links: https://github.com/esp8266/Arduino/issues/719 https://github.com/esp8266/Arduino/issues/3979 – ron123456 Jul 24 '18 at 05:48
  • @ron123456's link pretty sums up everything you need to know about reducing the consumption. You cannot do much from software, you have problem with the hardware. – Bence Kaulics Jul 24 '18 at 19:48
  • WiFi and battery power are not naturally compatible. With very skilled engineering from the bottom of the system on up you may be able to get it to sort of work for a while, but it's not a great combination. – Chris Stratton Jul 25 '18 at 05:27
  • @ChrisStratton You are correct. But deepsleep mode disables WIFI. So I think the battery should last longer. – a-c-sreedhar-reddy Jul 25 '18 at 05:29
  • Sleep is challenging to do right - you need to make sure it's really happening, that no signals are asserted against pulling resistors, etc. Then you need to look at what the regulator may use without load... – Chris Stratton Jul 25 '18 at 16:38

2 Answers2

3

Your 'question' implies several possible questions, but contains none. You need to clarify what main point you wish to ask about.

You need to provide enough information to allow us to understand your design, and enough information about measurements that you (should) have made that will allow you and us to understand what is happening.

Saying "Used AA batteries" is similar to you saying "some 4 seater cars" or "some short people" and then you asking us for performance and resource information about them. AA is a size - that's a start. What chemistry (Alkaline, Nimh, ...) what brand and model and mAh capacity? Please provide a data sheet or at least enough specifications to allow battery capability to be determined.

VERY importantly, how many batteries?

A 3V3 LDO regulator requires more than 3V3 input at all times.
So you need >= 4 x NimH or Alkaline AA cells.

If using AA Alkaline batteries. Battery capacity is say 3000 mAh. Initial voltage is 1.6V, falling rapidly to 1.5V, then more slowly to an exhausted voltage of 1V then very rapidly to 0.9V. So -

If 2 x AA alkaline are used then Vcell = 2.25V when Vbattery = 2.5V. Cells have some capacity remaining. Regulator is supplied with well under Vin_min.
To ensure proper regulator action for the whole of the battery capacity with a 3V3 Vout regulator then at least 4 x AA Alkaline cells are needed.
Vbattery_new = 4 x 1.6V+ = 6.4V+.
This rapidly drops to 4 x 1.5V = 6V then more slowly to 4 x 0.9V = 3.6V.
At that stage the battery is fully exhausted BUT the regulator has had enough voltage throughout to supply 3.3V to the system.
At the 2 hour rate a 3000 mAh cell may provide say 2000 - 2500 mAh.
To exhaust such a battery in 2 hours requires an average current of about 1000 to 1250 mA. This is far higher than you would expect the NodeMCU to draw on average when operated as you indicate it is.

You say:

The issue was I was using ld33cv for voltage regulation which took 5ma quiescent current

5 mA x 2 hours = 10 mA-hours = under 1% of AA battery capacity (Alkaline or Nimh). That is NOT the reason for the problem that you described.


These - and many similar videos - may be of assistance.

12 minute video Power Saving with ESP8266 (Sleep Mode) Tutorial with some Tricks

9 minute video tutorial How to use the RTC Memory in ESP8266 and reduce power consumption by factor of 10

This video suggests a modification may be required to enable deep sleep.

Russell McMahon
  • 213
  • 1
  • 6
  • The issue was I was using ld33cv for voltage regulation which took 5ma quiescent current – a-c-sreedhar-reddy Aug 04 '18 at 14:04
  • @ACSreedharReddy 5 mA will not "flatten" and sensible AA based battery. That is NOT the reason for the problem that you described. If changing the regulator to another type fixed the problem then it was either faulty or connected incorrectly. – Russell McMahon Aug 04 '18 at 14:24
3

LD33CV quiescent current is 5mA. This is the problem because even in deep sleep mode voltage regulator consumes power.