EasyManua.ls Logo

sparkfun ESP8266 - Example: Sleep Mode for Power Saving

sparkfun ESP8266
33 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Example Sketch: Goodnight Thing (Sleep Mode)
One of the Thing’s most unique features is the integrated support for LiPo batteries.
Unfortunately, the ESP8266 is still a pretty power hungry device. If you want your project to
run off a battery for more than a few hours, you have two options: get a huge battery or
cleverly put the Thing to sleep.
To use the Thing’s sleep capability, you’ll need to wire the XPD pin up to the ESP8266’s reset
line. RST isn’t broken out, but the DTR pin will work for our application as well.
Wire up from the XPD pin to DTR to set up sleep-ability.
Watch out! The ESP8266 can't be programmed while the XPD pin is connected to DTR.
Make sure you disconnect the two pins before trying to upload a sketch.
After you tell the ESP8266 to sleep, it’ll wait a specified number of microseconds, then trigger
the XPD pin to toggle the reset line. When the ESP8266 wakes up, it’ll begin back at the start
of the sketch.
Let’s riff off the first example in this tutorial – posting to Phant – but take advantage of
sleeping to greatly increase the battery life. Here’s some example code (or click here to
download):
Once again, make sure you modify the WiFiSSID and WiFiPSK variables near the top of the
sketch.
COPY CODE
// Include the ESP8266 WiFi library. (Works a lot like the// Arduino WiFi library.)#include <ESP8266WiFi.h>//
Include the SparkFun Phant library.#include <Phant.h>

Other manuals for sparkfun ESP8266