-->
Page 1 of 3

NodeMCU ESP-12F doesn't wake up

PostPosted: Fri Dec 23, 2016 3:43 pm
by nodemcu
Hello. I'm new to this forum, and I came up here because I have a problem with my NodeMCU. The problem is that, when I put it in deep sleep mode, it doesn't wake up. The power consumption gets down (from 80 mA to 10 mA) in deep sleep and then a little up (20 mA), but it does nothing. On Serial Monitor, when it wakes up, appears the following:
Code: Select all{dl��|�d�| � l� c|����{�cl�c��oo�doo���cp��dslsl�{��n�b�nbp�

--- EDIT ---
If I put Serial Monitor to 74880 baud, it prints the following:
Code: Select all ets Jan  8 2013,rst cause:5, boot mode:(1,7)

ets_main.c


My code is:
Code: Select all#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

const char* ssid = "MY_SSID";
const char* password = "MY_PASSWORD";
int totime;
int nowtime;
bool connectedOK;

WiFiServer server(80);

void OTAsetup() {
  WiFi.forceSleepWake();
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.println("Booting");
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, HIGH);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }

  // Port defaults to 8266
  // ArduinoOTA.setPort(8266);

  // Hostname defaults to esp8266-[ChipID]
  // ArduinoOTA.setHostname("myesp8266");

  // No authentication by default
  // ArduinoOTA.setPassword((const char *)"123");

  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loopProcess() {
  ArduinoOTA.handle();
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  while (!client.available()) {
    delay(1);
  }

  // Read the first line of the request
  String req = client.readStringUntil('\r');
  Serial.println(req);
  client.flush();

  // Match the request
  int val;
  int val2;
  if (req.indexOf("/gpio/0") != -1) {
    val = 1;
    val2 = 1;
  } else if (req.indexOf("/gpio/1") != -1) {
    val = 0;
    val2 = 1;
  } else if (req.indexOf("/gpio/2") != -1) {
    val = 1;
    val2 = 0;
  } else if (req.indexOf("/gpio/3") != -1) {
    val = 0;
    val2 = 0;
  }
  else {
    Serial.println("invalid request");
    client.stop();
    return;
  }

  // Set GPIO2 according to the request
  digitalWrite(2, val);
  digitalWrite(D3, val);
  digitalWrite(LED_BUILTIN, val2);

  client.flush();

  // Prepare the response
  String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
  s += (val) ? "low" : "high";
  s += ".<br>GPIO2 is now ";
  s += (val2) ? "low" : "high";
  s += ".</html>\n";

  // Send the response to the client
  client.print(s);
  delay(1);
  Serial.println("Client disonnected");

  // The client will actually be disconnected
  // when the function returns and 'client' object is detroyed
  ESP.deepSleep(1000000, WAKE_RF_DEFAULT);
}

void setup() {
  Serial.begin(115200);
    OTAsetup();
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    Serial.begin(115200);
    delay(10);

    // prepare GPIO2
    pinMode(2, OUTPUT);
    digitalWrite(2, 1);

    // Start the server
    server.begin();
    Serial.println("Server started");

    // Print the IP address
    Serial.println(WiFi.localIP());
    nowtime = micros();
    loopProcess();
    totime = micros() - nowtime;
    connectedOK = true;
}

void loop() {
  loopProcess();
}

Moving code from functions to setup does nothing. And if I try to connect GPIO16 (D0) with RST, it resets constantly. Pulling-up D3 and D4 (GPIO0 and 2) and pulling-down GPIO15 doesn't work, either.

Re: NodeMCU ESP-12F doesn't wake up

PostPosted: Fri Dec 23, 2016 6:18 pm
by mrburnette
And if I try to connect GPIO16 (D0) with RST, it resets constantly. Pull-upping D3 and D4 (GPIO0 and 2) and pull-downing GPIO15 doesn't work, either.


... But, have you tried a 10K pullup from 3.3 VCC to RST? (With D0 connected to RST)

Ray

Re: NodeMCU ESP-12F doesn't wake up

PostPosted: Sat Dec 24, 2016 10:15 am
by nodemcu
mrburnette wrote:... But, have you tried a 10K pullup from 3.3 VCC to RST? (With D0 connected to RST)
Ray


Yes, I tried this morning, but it doesn't work.

Re: NodeMCU ESP-12F doesn't wake up

PostPosted: Mon Dec 26, 2016 11:40 pm
by mrburnette
I personally tried with my NodeMCU V3, test sketch slept for 10 seconds and woke as anticipated.

Code: Select allextern "C" {
#include "user_interface.h"
}

void setup() {
  rst_info *rsti;
  Serial.begin(115200);
  rsti = ESP.getResetInfoPtr();
  Serial.println("\r\nStart...");
  Serial.println(String("ResetInfo.reason = ") + rsti->reason);
}

// the loop function runs over and over again forever
void loop() {
  Serial.println("going to sleep now...");
  system_deep_sleep_set_option(0);
  system_deep_sleep(10000000);            // deep sleep for 10 seconds
  delay(1000);
}

/* 
 *  Sketch uses 225,445 bytes (21%) of program storage space. Maximum is 1,044,464 bytes.
 *  Global variables use 32,152 bytes (39%) of dynamic memory, leaving 49,768 bytes for local variables. Maximum is 81,920 bytes.
 */