ESP8266/NodeMCU Deep Sleep
dsleep() function accepts microseconds as its parameter (1,000,000 microseconds = 1 second), and the multiplication performed inline here is just to make it clearer that we’re sleeping for 15 minutes total. With the current 1.5.1 SDK, the maximum value accepted is 4,294,967,295, which is about 71 minutes. Earlier SDK versions had a lower limit, closer to 35 minutes. One common way to extend this is to maintain a counter in NVM (i.e., Flash or RTC Memory), and increment the counter each time that the device wakes up. If it reaches a certain threshold, then do the work, otherwise go back to sleep.
node.dsleep(15 * 60 * 1000000)
In this case, you don’t need to connect GPIO16 to the RESET pin, and you don’t need to specify an alarm value when calling dsleep(). Or, rather, use a value of zero to specify that the ESP should sleep forever (until reset, that is):
This permits very long idle periods (hours, days, or weeks possible) so long as you have a reliable method of waking the device up by triggering the RESET pin.
Deep Sleep for the ESP8266 ESP-01
Because the ESP-01 does not have the necessary pin exposed for Deep Sleep (GPIO 16) we will need to do some surgical soldering on it.
We need to solder a very thin piece of wire from the reset pin to one of those very small pads on the esp chip.
Don’t worry, it’s a lot easier than it looks.
Get the piece of wire, solder it on the reset pin, tin the other end and bend it into position
What I did next is applying head somewhere near the end of the wire, this melted the solder on the wire and on the pad and I got a connection. Easy peasy.
You will also need to remove at least the red LED to lower consumption.
I have also added some hot glue on top of the wire, it’s quite easy to pull it away together with the esp’s pad otherwise.
– try to connect to wifi, if fail start in config mode
– read dht22 data
– post dht22 data to cloud
– go to sleep
– awake and repeat