Low power modes; deep sleep and modem sleep

Daven007
Posts: 5
Joined: Mon Sep 07, 2015 3:47 pm

Low power modes; deep sleep and modem sleep

Postby Daven007 » Sat Jul 29, 2017 9:07 pm

I'm trying to get low power settings working reliably. Most of the time I just want it to wake up for a bit, do some work, record it and go back to sleep. Every so often I want it to connect to WiFI (& MQTT) to report back. I have two problem areas:

a) I use this function to enter deep sleep:

Code: Select all

static void ICACHE_FLASH_ATTR gotoSleep(void) {
   TESTP("Sleep %dS\n", sysCfg.updates);
   system_deep_sleep_set_option(RF_DISABLED); // 4
   system_deep_sleep(sysCfg.updates * 1000 * 1000);
   os_delay_us(100);
}

However WiFi (and RF) still are enabled when the unit restarts. E.g. dhcp & ip address etc are reported. I'd have thought that with RF disabled WiFI wouldn't have been started.

b) I lieu of this I'm using modem sleep to minimise the current while doing the work. I use this code to enter modem sleep mode:

Code: Select all

      wifi_station_disconnect();
      wifi_set_opmode(NULL_MODE);
      wifi_fpm_open();
      wifi_fpm_set_sleep_type(MODEM_SLEEP_T);
      wifi_fpm_open();
      wifi_fpm_set_wakeup_cb(fpm_wakup_cb);
      wifi_fpm_do_sleep(0xFFFFFFF);


This works most of the time but every so often I get an exception when restarting:
scandone
del if0
usl
mode : null
fpm open,type:2 0
force slp enable,type: 2
reconnect
Fatal exception 28(LoadProhibitedCause):
epc1=0x4000df2f, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000033, depc=0x00000000
ÿ
ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 28496, room 16
tail 0
chksum 0x39
load 0x3ffe8000, len 2113, room 8
tail 9
chksum 0x9b
ho 0 tail 9 room 7
load 0x3ffe8850, len 5884, room 15
tail 13
chksum 0x98
csum 0x98

Nb 0x4000df2f is in the memcmp routine

What am I missing? Any ideas please?

pratik

Re: Low power modes; deep sleep and modem sleep

Postby pratik » Mon Jul 31, 2017 2:13 pm

You should try to set sleep option to no RF on wake-up inside rf_pre_init instead of calling it from user_init. That works on my end!
Not sure about the exception. Seems like you are loading data from an address that is not inside an addresseable location.

Daven007
Posts: 5
Joined: Mon Sep 07, 2015 3:47 pm

Re: Low power modes; deep sleep and modem sleep

Postby Daven007 » Wed Aug 02, 2017 2:51 am

Thanks

Who is online

Users browsing this forum: No registered users and 257 guests