Skip to content

Instantly share code, notes, and snippets.

@LosantGists
Created March 15, 2017 15:21
Show Gist options
  • Save LosantGists/854c9f0647eea8b3246dad77437b687f to your computer and use it in GitHub Desktop.
Save LosantGists/854c9f0647eea8b3246dad77437b687f to your computer and use it in GitHub Desktop.
An example showing how to put a ESP8266 device into Deep-sleep mode
/**
* An example showing how to put ESP8266 into Deep-sleep mode
*/
void setup() {
Serial.begin(115200);
Serial.setTimeout(2000);
// Wait for serial to initialize.
while(!Serial) { }
Serial.println("I'm awake.");
Serial.println("Going into deep sleep for 20 seconds");
ESP.deepSleep(20e6); // 20e6 is 20 microseconds
}
void loop() {
}
@dunglehome
Copy link

I also think it meant to say 20 seconds, my test seems to show it is 20 seconds.

@jfrmilner
Copy link

As the seconds value (20) is mentioned in the line above I suspect it was meant to say
ESP.deepSleep(20e6); // 20e6 is 20000000 microseconds

Just in case the reader is not familiar with Exponential Notation (It simplifies numbers by getting rid of zeros, and making math easier)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment