This How To covers how to configure deep sleep on an ESP8266 NodeMCU board. This guide is part of the Soil Moisture Exporter series.
Deep Sleep
The ESP8266 has the ability to do what is referred to as DeepSleep, this reduces what the board is doing to run nothing but the real time clock (RTC) which allows it to track the time it’s been asleep. This guide is part of the Soil Moisture Exporter series.
To wake it up either:
- It will wake itself up after a predefined period of time; or
- You press the RST button to restart the ESP8266
Prerequisites
- An ESP8266
- A sketch you can deploy to your ESP8266
Timed Wakeup
- Add the following to the sketch for the deep sleep:
ESP.deepSleep(3.6e9); //30m
- Once the sketch has been written to the ESP8266 - connect the
RSTandD0pins. - You should see you sketch's setup output on the serial monitor each time the board wakes.
⏰ The ESP8266 has a maximum time it can deep sleep for, about 3.5 hours, beyond that it’s not likely to wake up. In practice, durations over about an hour became unreliable - see the Soil Moisture Exporter build post for why 30 minutes is what's actually used.
Manual Wakeup
Once you have put the ESP8266 to sleep the other alternative to wake it up is to press the RST button on the board. This will reboot the board and your sketch will run from the beginning again.
FairlyUsefulCode