This sketch accomplishes the same feat as that in our first example – it posts some data to
a data.sparkfun.com stream every 30 seconds. But there’s one huge difference: sleep.
Notice there’s nothing in the loop(). The program halts when the ESP.deepSleep(30000000) is
called. After 30 seconds, when the ESP8266 wakes up, it’ll start running code back at the
beginning of setup().
If you put a multimeter in-line to measure the current draw, the Thing would pull about 80mA
for the ~5 seconds it takes to connect and post to Phant. Then, while it sleeps for about 30
seconds, the current draw would be around 8mA. An average of about 18mA per second.
In deep sleep mode, the Thing pulls about 8mA (that’s mostly the power LED).
Most of the current draw in sleep mode is from the power LED indicator – if you want to save
even more juice, you may consider removing the LED (or current-limiting resistor) or even
cutting a trace. (Hint: cut the trace running through middle of the ‘R’ in “PWR”.)
Using the Arduino Addon
If you’ve used Arduino in the past, there will be some new programming schemes to get used
to in ESP8266 land.
Pin Mappings
As with any other Arduino, the pin mappings printed on the board match the pin you read or
write to. The SDA and SCL pins can be referenced as 2 and 14 respectively.