SleepMode

From Let's Control It
Jump to: navigation, search

The ESP8266 can be set to deep sleep. You need to connect GPIO-16 with the RST pin to make this work.

What Sleep mode does when waking up:

  • Make one connection attempt to SSID, and to SSID2 if its defined.
  • If it cant connect, and you enabled the option Sleep on connection failure, it will go back to sleep immediately.
  • It will send all the sensor-readings at once (delays are ignored, except for Message Delay at the advanced settings page)
  • It will power down and sleep for the amount of seconds thats set in the Sleep Delay setting. Deepsleep uses an internal 32 bit counter in uSecs. That means that it is working up to 4294 seconds, longer delays will not work. I.e. the longest sleep time is approx 1 hour and 11 minutes.

This saves lots of power, allowing you to use the ESP8266 on batteries.

Note that its recommended to set the Message Interval to 100 (or less) in the advanced settings page, since you want the unit to broadcast messages asap in order to save precious battery power.

Using Deep Sleep Mode for battery-powered devices see here.

Rules example

Using rules for doing deepsleep will make the wake up procedures not work and you have to code it yourself. So the jumper GPIO16-GND will not work and you could add a switch for it to listen to and if it's pressed do not proceed with deepsleep:

On MQTT#Connected Do //when the broker is connected
 If Switch#State=0
  publish,%sysname%/temperature,[BME#temp] //publish a temperature
  timerSet,1,5
 Else
  pulse,14,1,800 //blink led for 800mSec = you can release the switch and login to the GUI
  publish,%sysname%/status,"Deepsleep Disabled" //publish information
 EndIf
EndOn

On Rules#Timer=1 Do
  deepsleep,600 //go to deepsleep for 600 seconds (even if deepsleep value is not configured in the config menu)
EndOn

Using this approach you should not use the config settings BUT please make sure you should have a button that you press for it to not enter the deepsleep at power on. See example above using "Switch#State". To get it back to deepsleep cycle you just power it on/off.

Wake up manually

If you specify a Sleep Delay of 0, you will have to wake the device yourself by pulling RST to GND.

Look here for an practical example of waking up manually: https://www.letscontrolit.com/wiki/index.php/EasyNotifications

Getting out of deep sleep

When this state is active, you can't connect to the web interface. In fact, the ESP is turned off and only a dedicated timer circuit is still powered to wake up the main ESP core.

There are three ways to get out of sleep mode:

Cold boot

Power off the ESP and reconnect power. You will have 30 seconds to connect to the Web interface and disable the Sleep Mode function. (You will get feedback in the serial interface)

Temporary disable Deep Sleep via jumper setting

If 30 seconds is too short for you, you can use this method.

Disconnect GPIO-16 from RST and connect it to GND. Restart your ESP if neccesary.

Now deep sleep will be disabled and your ESP will function normally, until you connect GPIO-16 to RST again.

This requires ESPEasy v2.0.0-dev6 or newer.

Factory reset

If all else fails, just do a factory reset. You will lose all your settings!

The reset is done by connect the RX and TX pin together while you restart your ESP. Power off the device. Then remove the connector across the RX and TX pins. Restart and then install the ESPEasy firmware again. If this doesn't work, try loading the blank image to match the size of the memory installed on the device. Reboot and wait 5 minutes. Then load on the firmware you are wanting to use. Reboot and wait 5 minutes.