Chat freely about anything...

User avatar
By schufti
#77328 unfortunately the 0x7FFFFFFF that would translate to ~35,79min only gives a little more than 33 min because the timer is not that accurate.
edit:
hmmm, tested it with 0x80000000 and it woke up correctly, so it shouldn't be a "value" problem.
will test with 60min later on...

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

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


# Connecting to WiFi.
# WiFi connected
# IP address: 192.168.22.136
# after 466ms sntp ok
# Setup done

Sun Jul 22 11:23:23 2018
########################################

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

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


# Connecting to WiFi..........
# WiFi connected
# IP address: 192.168.22.136
# after 2240ms sntp ok
# Setup done

Sun Jul 22 11:57:45 2018
########################################


I'm testing on core 2.4.1 with lwip V2(lower memory)

Code: Select all#include <ESP8266WiFi.h>
#include <time.h>

//WIFI credentials go here
#define ssid "yourSSID"
#define wpwd "yourPASSWORD"
#define TZ "CET-1CEST,M3.5.0,M10.5.0/3"

time_t t=0;
uint64_t  sleepTime = 0xD693A400; // sleep for x min

void setup() {
  configTime(0, 0, "at.pool.ntp.org");  // with lwIP2
  setenv("TZ", TZ, 3);
  tzset();

  // Serial setup
  Serial.begin(74880);
  Serial.print(F("\n\n# Connecting to "));
  Serial.print(ssid);
  //Wifi Setup
  WiFi.persistent(true);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, wpwd);
  while (WiFi.status() != WL_CONNECTED) {   // could be endless
    Serial.print(".");
    delay(200);
  }
  Serial.println(F("\n# WiFi connected"));
  Serial.print(F("# IP address: "));
  Serial.println(WiFi.localIP());
  while (t < 50000) {
    t=time(nullptr);
    delay(10);
  }
  Serial.print("# Setup done\n# sntp ok after ");
  Serial.print(String(millis()) + " ms\n# ");
  Serial.print(ctime(&t));
  Serial.println(F("########################################"));
}

void loop() {
  ESP.deepSleep(sleepTime);
  delay(100);
}
Last edited by schufti on Sun Jul 22, 2018 3:43 pm, edited 1 time in total.
User avatar
By panoss
#77330
schufti wrote:'// could be endless'


This is why I 've done it like this (it 'll be battery operated):
(ALLOWED_CONNECT_CYCLES equals 20, sleepTimeWhenNoWiFi equals to 15*60*1000000)
(try to connect for 20 times. If still no connection, sleep for 15 minutes)
Code: Select all    uint8_t counter = 0;
    while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
      counter++;
      if (counter > ALLOWED_CONNECT_CYCLES) {
        // sleep for 15 minutes
        ESP.deepSleep(sleepTimeWhenNoWiFi);
      }
    }
User avatar
By schufti
#77335 ok, so I checked with
Code: Select alluint64_t  sleepTime = 0xD693A400; // sleep for x min

and got perfect wake-up after ~58min

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

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


# Connecting to WiFi.
# WiFi connected
# IP address: 192.168.22.136
# Setup done
# sntp ok after 460 ms
# Sun Jul 22 21:39:36 2018
########################################

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

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


# Connecting to WiFi..........
# WiFi connected
# IP address: 192.168.22.136
# Setup done
# sntp ok after 17369 ms
# Sun Jul 22 22:37:28 2018
########################################
User avatar
By panoss
#77342
schufti wrote:ok, so I checked with
Code: Select alluint64_t  sleepTime = 0xD693A400; // sleep for x min

and got perfect wake-up after ~58min


0xD693A400 is hex for decimal 3600000000, right?
I 'll try it.

schufti wrote:I'm testing on core 2.4.1 with lwip V2(lower memory)

My Esp.h is at dir:
C:\Users\Panagiotis\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266

This means I also use core 2.4.1?
What is ' lwip V2(lower memory)'?