-->
Page 1 of 5

Deep Sleep example

PostPosted: Mon Apr 13, 2015 3:10 pm
by AcmeUK
In this Post [url]http://www.esp8266.com/viewtopic.php?f=29&t=2228[/url] Bygerardwr shows the way to make esp8266SDK calls from the ESP8266 Arduino IDE environment.
Following his example I have produced the sketch below which shows how the Deep_Sleep function can be called from an Arduino sketch.
[code]
/*
Based on the example of how to call an ESP8266 SDK routine from Arduino code, posted by Bygerardwr here :-
viewtopic.php?f=29&t=2228
*/

// SDK headers are in C, include them extern or else they will throw an error compiling/linking
// all SDK .c files required can be added between the { }
extern "C" {
#include "user_interface.h"
}

void setup(){
Serial.begin(74880);

}

void loop()
{
Serial.println("Hello world!");
for (int i=10; i > 0; i--){
Serial.println(i);
delay(1000);
}

Serial.println("Time to sleep");
system_deep_sleep(10000000); //sleep time in usecs. 10000000 = 10 secs.
delay(1000); // a short delay to keep in loop while Deep Sleep is being implemented.
}
[/code]
You will see that I run my terminal at 74880 baud. This enables me to see the boot room startup messages. 74880 is plenty fast enough for most applications.

To get your esp8266 to wake from Deep Sleep mode you need to connect GPIO16 and RESET together, so you cannot do this with an ESP-01 without modifying it; very fiddly!

The code has been tested on Win7 64 bit, using v1.6.3

Re: Deep Sleep example

PostPosted: Tue Apr 14, 2015 2:05 am
by uhrheber
Nice!
Did you try the same while connected to an AP?
Does waking up the WiFi and reconnecting work?
What's the power consumption in deep sleep?

Re: Deep Sleep example

PostPosted: Tue Apr 14, 2015 2:14 am
by reaper7
now we have a special command for this:
https://github.com/esp8266/Arduino#esp-specific-apis

Re: Deep Sleep example

PostPosted: Tue Apr 14, 2015 2:32 am
by uhrheber
Already in the release, or only in the github source?