We are still shipping! However, order processing may take longer than usual and we cannot guarantee same day shipments due to staffing guidelines from the CDC. Please see all COVID-19 updates here. Thank you for your continued support.
Track My Order
Frequently Asked Questions
International Shipping Info
Mon-Fri, 9am to 12pm and
1pm to 5pm U.S. Mountain Time:
Chat With Us
December 22, 2015
News - Enginursday: Deep Sleep A…
about 5 years ago
Thanks for the post. It is really helpful.
Regarding ESP8266 code: I didnt quite understand the purpose of using the attach function and calling it every 250ms and putting the device to deep sleep for 60secs.
My understanding is: On the first iteration, attach function gets called , led blinks for 20 times, then the uC goes to deep sleep for 60 secs. Then wakes up in default mode which means (as per datasheet) it would run the program from void setup() and reach attach function. Then again it will do the blinking and go back to sleep. Now, where is the role of 250ms in the attach function here? What happens to the interrupt which is generated after 250ms, when the device would be sleeping. Will it be considered dont care or will it wake up the device ?
One other point, the deepsleep function automatically wakes up the device after 60s, so why bother giving an interrupt every 250ms? Any particular reason?
Will the power performance in the following code and your code be the same?
int ledPin = 5; // LED is attached to ESP8266 pin 5.
uint8_t ledStatus = 0; // Flag to keep track of LED on/off status
int counter = 0; // Count how many times we've blinked
pinMode(ledPin, OUTPUT); // Set LED pin (5) as an output
ledStatus = (ledStatus + 1) % 2; // Flip ledStatus
if (counter++ > 20) // If we've blinked 20 times
ESP.deepSleep(60000000, WAKE_RF_DEFAULT); // Sleep for 60 seconds
Please let me know. Thanks!
No public wish lists :(