Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By perody
#83570 Dear all,


I have been struggling to get deepSleep working.

My plan is to read some data from a serial port and send to an OpenHAB installation with mqtt. However, to keep the power consumption at an acceptable level, deep sleep should be used most of the time.

I use the Wemos D1 mini and have loaded the script below with Arduino IDE version 2.4.0.

Code: Select all#include <ESP8266WiFi.h>

const char* ssid = "<my SSID>";
const char* password = "<my passwd>";
char* outputMessage[500] = {'\0'};


IPAddress ip(192, 168, 1, 217);      // desired IP address
IPAddress gateway(192, 168, 1, 1); // IP address of my router
IPAddress subnet(255, 255, 255, 0);


WiFiClient client;

void setup() {

  Serial.begin(74880);
  Serial.setDebugOutput(true);
  delay(100);

  WiFi.mode(WIFI_STA);
  if (WiFi.status() != WL_CONNECTED) {
    WiFi.begin(ssid, password);
    Serial.print(".");
  }
  WiFi.config(ip, gateway, subnet);

  IPAddress myip = WiFi.localIP();
  sprintf((char*)outputMessage, "Connected to %u.%u.%u.%u after %d ms. Will wait 10s before sleep.\r\n", myip[0], myip[1], myip[2], myip[3], millis());
  Serial.print((char*)outputMessage);

delay(10000);

  // GPIO16 (D0) connected to RST with 1k resistor
  Serial.println("Bedtime. Good night...");
  ESP.deepSleep(5000000);
}

void loop() {
}



Printout is as follows:

Code: Select allStart...
scandone
.STUB: dhcp_stop
Connected to 192.168.1.217 after 5045 ms. Will wait 10s before sleep.
Bedtime. Good night...
scandone
del if0
usl
enter deep sleep⸮
 ets Jan  8 2013,rst cause:5, boot mode:(1,6)

ets_main.c


I then need to push reset to run the script again, and get the following:
Code: Select allets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v4ceabea9
~ld

Start...
scandone
.STUB: dhcp_stop
Connected to 192.168.1.217 after 319 ms. Will wait 10s before sleep.
Bedtime. Good night...
scandone
del if0
usl
enter deep sleep⸮⸮
 ets Jan  8 2013,rst cause:5, boot mode:(3,6)

ets_main.c


How can I get the script repeating itself after deep sleep? It simply stops after writing the exit values and "ets_main.c"

Hope to get some ideas on what I am missing.

Best regards

Per
User avatar
By perody
#83581 Hello,

After performing some tests on the resistor between D0 and RST, I have found that 150 ohm allows new sketches to be uploaded, and also enables RST from D0 so that deepsleep executes properly.

With 1 kohm the deepsleep do not properly start, and with a wire between D0 and RST I was not able to upload new sketches without disconnecting the wire.

With 150 ohm, both functions seems to function as they should.

Thanks to you who have commented and tried to help in this.

Best regards

Per