Why does using ESP8266 in deep sleep mode still drain the battery quickly?












3















I've made a "weather station" using the ESP8622. To save battery I'm using sleep mode but still the battery is drained after a couple of days. According to this post it should last at least a year.



I haven't done any measurements yet, wanted to know if there's something obvious that I've missed that could explain why the battery is drained so quickly? Attaching code and an image showing the hardware setup.



#include "DHT.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define DHTPIN D2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "xxxx";
const char* password = "xxxx";

const char* host = "xxxx";

void setup() {
Serial.begin(115200);
dht.begin();
delay(10);

Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
readSensorsAndPost();
ESP.deepSleep(18e8); //30 minutes
}

void readSensorsAndPost() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
char charVal[10];
dtostrf(t, 5, 2, charVal);
makeAnHttpRequest(charVal);
}

bool makeAnHttpRequest(String msg) {
//send the value
}

void loop() {

}


esp8622 and DHT22










share|improve this question























  • First do measurments

    – SilvioCro
    Dec 16 '18 at 17:02
















3















I've made a "weather station" using the ESP8622. To save battery I'm using sleep mode but still the battery is drained after a couple of days. According to this post it should last at least a year.



I haven't done any measurements yet, wanted to know if there's something obvious that I've missed that could explain why the battery is drained so quickly? Attaching code and an image showing the hardware setup.



#include "DHT.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define DHTPIN D2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "xxxx";
const char* password = "xxxx";

const char* host = "xxxx";

void setup() {
Serial.begin(115200);
dht.begin();
delay(10);

Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
readSensorsAndPost();
ESP.deepSleep(18e8); //30 minutes
}

void readSensorsAndPost() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
char charVal[10];
dtostrf(t, 5, 2, charVal);
makeAnHttpRequest(charVal);
}

bool makeAnHttpRequest(String msg) {
//send the value
}

void loop() {

}


esp8622 and DHT22










share|improve this question























  • First do measurments

    – SilvioCro
    Dec 16 '18 at 17:02














3












3








3


1






I've made a "weather station" using the ESP8622. To save battery I'm using sleep mode but still the battery is drained after a couple of days. According to this post it should last at least a year.



I haven't done any measurements yet, wanted to know if there's something obvious that I've missed that could explain why the battery is drained so quickly? Attaching code and an image showing the hardware setup.



#include "DHT.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define DHTPIN D2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "xxxx";
const char* password = "xxxx";

const char* host = "xxxx";

void setup() {
Serial.begin(115200);
dht.begin();
delay(10);

Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
readSensorsAndPost();
ESP.deepSleep(18e8); //30 minutes
}

void readSensorsAndPost() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
char charVal[10];
dtostrf(t, 5, 2, charVal);
makeAnHttpRequest(charVal);
}

bool makeAnHttpRequest(String msg) {
//send the value
}

void loop() {

}


esp8622 and DHT22










share|improve this question














I've made a "weather station" using the ESP8622. To save battery I'm using sleep mode but still the battery is drained after a couple of days. According to this post it should last at least a year.



I haven't done any measurements yet, wanted to know if there's something obvious that I've missed that could explain why the battery is drained so quickly? Attaching code and an image showing the hardware setup.



#include "DHT.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#define DHTPIN D2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "xxxx";
const char* password = "xxxx";

const char* host = "xxxx";

void setup() {
Serial.begin(115200);
dht.begin();
delay(10);

Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
readSensorsAndPost();
ESP.deepSleep(18e8); //30 minutes
}

void readSensorsAndPost() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
char charVal[10];
dtostrf(t, 5, 2, charVal);
makeAnHttpRequest(charVal);
}

bool makeAnHttpRequest(String msg) {
//send the value
}

void loop() {

}


esp8622 and DHT22







esp8266 battery sleep






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 15 '18 at 13:16









ChristianChristian

1162




1162













  • First do measurments

    – SilvioCro
    Dec 16 '18 at 17:02



















  • First do measurments

    – SilvioCro
    Dec 16 '18 at 17:02

















First do measurments

– SilvioCro
Dec 16 '18 at 17:02





First do measurments

– SilvioCro
Dec 16 '18 at 17:02










1 Answer
1






active

oldest

votes


















3














The example shows a Sparkfun Thing, which the article notes doesn't have extra peripherals. What you show is something different, like a NodeMCU dev board, which typically has a linear regulator, possibly a power LED (which the article notes can be removed).



I see you're using a DHT11 or DHT22, which has a pull-up resistor. The pull-up resistor is constantly using power. Instead of connecting the pull-up to the power rail, you can connect it to a GPIO pin and pull that pin LOW before you go into sleep, which effectively disables the sensor and stops it from drawing power just to keep the data line high.



Safe to say that somewhere there is something drawing power -- have you measured the actual current draw in deep-sleep, or are you only noting that your batteries run low sooner than expected?






share|improve this answer
























  • I haven't done any measurements yet but when I have I will post the result. Will also change the setup as per your suggestion.

    – Christian
    Dec 15 '18 at 14:30






  • 2





    You are also powering the USB interface chip, which never goes to sleep.

    – Majenko
    Dec 15 '18 at 17:20











  • @Majenko is there an easy way to disable powering the USB interface chip?

    – Christian
    Dec 16 '18 at 8:27











  • Migrate to a standalone module without all the extra junk and use an external USB adapter.

    – Majenko
    Dec 16 '18 at 8:58











Your Answer






StackExchange.ifUsing("editor", function () {
return StackExchange.using("schematics", function () {
StackExchange.schematics.init();
});
}, "cicuitlab");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "540"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f58779%2fwhy-does-using-esp8266-in-deep-sleep-mode-still-drain-the-battery-quickly%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














The example shows a Sparkfun Thing, which the article notes doesn't have extra peripherals. What you show is something different, like a NodeMCU dev board, which typically has a linear regulator, possibly a power LED (which the article notes can be removed).



I see you're using a DHT11 or DHT22, which has a pull-up resistor. The pull-up resistor is constantly using power. Instead of connecting the pull-up to the power rail, you can connect it to a GPIO pin and pull that pin LOW before you go into sleep, which effectively disables the sensor and stops it from drawing power just to keep the data line high.



Safe to say that somewhere there is something drawing power -- have you measured the actual current draw in deep-sleep, or are you only noting that your batteries run low sooner than expected?






share|improve this answer
























  • I haven't done any measurements yet but when I have I will post the result. Will also change the setup as per your suggestion.

    – Christian
    Dec 15 '18 at 14:30






  • 2





    You are also powering the USB interface chip, which never goes to sleep.

    – Majenko
    Dec 15 '18 at 17:20











  • @Majenko is there an easy way to disable powering the USB interface chip?

    – Christian
    Dec 16 '18 at 8:27











  • Migrate to a standalone module without all the extra junk and use an external USB adapter.

    – Majenko
    Dec 16 '18 at 8:58
















3














The example shows a Sparkfun Thing, which the article notes doesn't have extra peripherals. What you show is something different, like a NodeMCU dev board, which typically has a linear regulator, possibly a power LED (which the article notes can be removed).



I see you're using a DHT11 or DHT22, which has a pull-up resistor. The pull-up resistor is constantly using power. Instead of connecting the pull-up to the power rail, you can connect it to a GPIO pin and pull that pin LOW before you go into sleep, which effectively disables the sensor and stops it from drawing power just to keep the data line high.



Safe to say that somewhere there is something drawing power -- have you measured the actual current draw in deep-sleep, or are you only noting that your batteries run low sooner than expected?






share|improve this answer
























  • I haven't done any measurements yet but when I have I will post the result. Will also change the setup as per your suggestion.

    – Christian
    Dec 15 '18 at 14:30






  • 2





    You are also powering the USB interface chip, which never goes to sleep.

    – Majenko
    Dec 15 '18 at 17:20











  • @Majenko is there an easy way to disable powering the USB interface chip?

    – Christian
    Dec 16 '18 at 8:27











  • Migrate to a standalone module without all the extra junk and use an external USB adapter.

    – Majenko
    Dec 16 '18 at 8:58














3












3








3







The example shows a Sparkfun Thing, which the article notes doesn't have extra peripherals. What you show is something different, like a NodeMCU dev board, which typically has a linear regulator, possibly a power LED (which the article notes can be removed).



I see you're using a DHT11 or DHT22, which has a pull-up resistor. The pull-up resistor is constantly using power. Instead of connecting the pull-up to the power rail, you can connect it to a GPIO pin and pull that pin LOW before you go into sleep, which effectively disables the sensor and stops it from drawing power just to keep the data line high.



Safe to say that somewhere there is something drawing power -- have you measured the actual current draw in deep-sleep, or are you only noting that your batteries run low sooner than expected?






share|improve this answer













The example shows a Sparkfun Thing, which the article notes doesn't have extra peripherals. What you show is something different, like a NodeMCU dev board, which typically has a linear regulator, possibly a power LED (which the article notes can be removed).



I see you're using a DHT11 or DHT22, which has a pull-up resistor. The pull-up resistor is constantly using power. Instead of connecting the pull-up to the power rail, you can connect it to a GPIO pin and pull that pin LOW before you go into sleep, which effectively disables the sensor and stops it from drawing power just to keep the data line high.



Safe to say that somewhere there is something drawing power -- have you measured the actual current draw in deep-sleep, or are you only noting that your batteries run low sooner than expected?







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 15 '18 at 14:06









jose can u cjose can u c

5,7952724




5,7952724













  • I haven't done any measurements yet but when I have I will post the result. Will also change the setup as per your suggestion.

    – Christian
    Dec 15 '18 at 14:30






  • 2





    You are also powering the USB interface chip, which never goes to sleep.

    – Majenko
    Dec 15 '18 at 17:20











  • @Majenko is there an easy way to disable powering the USB interface chip?

    – Christian
    Dec 16 '18 at 8:27











  • Migrate to a standalone module without all the extra junk and use an external USB adapter.

    – Majenko
    Dec 16 '18 at 8:58



















  • I haven't done any measurements yet but when I have I will post the result. Will also change the setup as per your suggestion.

    – Christian
    Dec 15 '18 at 14:30






  • 2





    You are also powering the USB interface chip, which never goes to sleep.

    – Majenko
    Dec 15 '18 at 17:20











  • @Majenko is there an easy way to disable powering the USB interface chip?

    – Christian
    Dec 16 '18 at 8:27











  • Migrate to a standalone module without all the extra junk and use an external USB adapter.

    – Majenko
    Dec 16 '18 at 8:58

















I haven't done any measurements yet but when I have I will post the result. Will also change the setup as per your suggestion.

– Christian
Dec 15 '18 at 14:30





I haven't done any measurements yet but when I have I will post the result. Will also change the setup as per your suggestion.

– Christian
Dec 15 '18 at 14:30




2




2





You are also powering the USB interface chip, which never goes to sleep.

– Majenko
Dec 15 '18 at 17:20





You are also powering the USB interface chip, which never goes to sleep.

– Majenko
Dec 15 '18 at 17:20













@Majenko is there an easy way to disable powering the USB interface chip?

– Christian
Dec 16 '18 at 8:27





@Majenko is there an easy way to disable powering the USB interface chip?

– Christian
Dec 16 '18 at 8:27













Migrate to a standalone module without all the extra junk and use an external USB adapter.

– Majenko
Dec 16 '18 at 8:58





Migrate to a standalone module without all the extra junk and use an external USB adapter.

– Majenko
Dec 16 '18 at 8:58


















draft saved

draft discarded




















































Thanks for contributing an answer to Arduino Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f58779%2fwhy-does-using-esp8266-in-deep-sleep-mode-still-drain-the-battery-quickly%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Cabo Verde

Gyllenstierna