So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By piga
#87161 Hello, I am using NodeMCU 12E esp 8266, I connect to Wifi, messure temperature on GPIO 2, send it to database and than I go to sleep with this command ESP.deepSleep(1200e6). And power consumption is always around 77mA and datashet said that consumption should be around 20 mikro Ampers. Please help.
The board goes to deep sleep for 20 minutes and wakes up, no problem, but power consumption in deepSleep is problem. Here is the code:
Code: Select all#include <OneWire.h>
#include <DallasTemperature.h>
#include "ESP8266WiFi.h"
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

const char* ssid = "njka Local";
const char* password = "!3bNwjSf9";

const char* serverName = "http://controltemp.online/emmezeta/connect_dako.php";

String sensid = "dse1p2";

const int oneWireBus = 2;

OneWire oneWire(oneWireBus);

DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
     delay(500);
     Serial.print("*");
  }

  sensors.begin();

  sensors.requestTemperatures();
  float temperatureC = sensors.getTempCByIndex(0);

  if(WiFi.status()== WL_CONNECTED){

    HTTPClient http;

    http.begin(serverName);

    http.addHeader("Content-Type", "application/x-www-form-urlencoded");

    String httpRequestData = "&sensid=" + sensid + "&temp1=" +
String(temperatureC) + "";
    Serial.print("httpRequestData: ");
    Serial.println(httpRequestData);

    int httpResponseCode = http.POST(httpRequestData);

    if (httpResponseCode>0) {
      Serial.print("HTTP Response code: ");
      Serial.println(httpResponseCode);
    }
    else {
      Serial.print("Error code: ");
      Serial.println(httpResponseCode);
    }
    // Free resources
    http.end();
  }
  else {
    Serial.println("WiFi Disconnected");
  }
  //Send an HTTP POST request every 20 minutes
  ESP.deepSleep(1200e6, WAKE_RF_DEFAULT);
}

void loop() {

}
User avatar
By piga
#87208 I solved my problem. Now power consuption is around 15 mikro ampers. I was working like Andreas in this video https://www.youtube.com/watch?v=6SdyImetbp8&feature=emb_rel_end, but I didn't use his scheme, I didn't Know that I have to connect GPIO15 to GND, I didn't Know GPIO0 to HIGH 3.3, I didn't Know RST and CH_PD to Vcc, I didn't Know my board NodeMCu 12E Vellemann VMA 107 pin EN is actualy CH_PD pin. Only on one website I saw CH_PD pin is actualy EN pin. So, following Andress excatly 100% I managed to solve my problem. Thanks
User avatar
By piga
#87209 I managed to reduce power consumption around 15 mikro ampers folowing Andreass Spies https://www.youtube.com/watch?v=6SdyImetbp8&feature=emb_rel_end. My problem was I didn't folow his scheme 100%. I knew connect GPIO16 to RST. I didn't Know
    CH_PD pin is EN pin on my board NodeMCU 12E Velleman VMA 107 and that I need to connect it to Vcc
    RST connect Vcc
    GPIO15 to GND
    GPIO0 to HIGH 3.3
So folowing Andreass 100% my problems are solved. Thanks