Update…
Lots of video reviews lead me to start trying what seemed to be a straightforward set of functions designed to sleep and wake my ESP8285.
None of them would compile …
…
Although I have finally gotten these functions to compile I have not yet verified they actually work.
As you can see they are a mixture of gpio, ESP. class and system functions.
I found these by just typing ESP., gpio and system and watching what the IDE function reference revealed then trying to compile.
Some were also found by disecting “low power demo” programs in the examples for the board core I am using.
For some reason the gpio_xx_xx functions need the ESP8266WIFI.h to compile. I will research this more later but for now I am taking it.
//These only compile with the “#include <ESP8266WiFi.h”>
gpio_pin_wakeup_enable(GPIO_ID_PIN(WAKE_UP_PIN), GPIO_PIN_INTR_LOLEVEL); // GPIO wakeup (optional)
gpio_pin_wakeup_enable(GPIO_ID_PIN(16), GPIO_PIN_INTR_LOLEVEL); // GPIO wakeup (optional)
//Some info suggests that GPIO16 cannot be used as wakeup.
gpio_pin_wakeup_disable();
//These compile without "#include <ESP8266WiFi.h> "
ESP.deepSleep(0); // must have a value (0). Waits for wifi shutdown
ESP.getChipId(); // just interesting nothing to do with sleep
ESP.deepSleepInstant(0); // instantly enters deep sleep, does not wait for wifi shutdown.
system_deep_sleep_instant(0); // same as ESP.deepSleep()?
My plan is to test:
Enter deep sleep when no buttons on the device are pushed for a programmed amount of time.
Then cycle the power switch to reset the device.
------------ MORE ---------------------
What a convoluted challenge this is. The documentation on the ESP8285 and ESP8266 are confusing especially related to “sleep and wakeup”.
I am using a WEMOS DI mini lite which is an ESP8285. I am using this because it fits the cost, power and package size needed for my handheld.
I also have tried a D1 mini which is an ESP-12S [ESP8266EX]
Tons of research suggested that both these ESP derivatives could be put into deep sleep and then wake’t up via a timed value or a predefined I/O transition.
Things that you need to know about your setup:
What processor is actually in your board [especially if you are buying knockoffs; ESP Tool
What board core are you using and what functions are in the associated library:
https://arduino-esp8266.readthedocs.io/en/3.1.2/libraries.html
https://arduino-esp8266.readthedocs.io/en/latest/
The “ESP-specific APIs” section was the most useful.