- Fri Dec 23, 2016 9:02 am
#59869
jumpjack wrote:I don't catch why you upload data in Setup() rather than in Loop() , but maybe it's because I don't know how "sleep mode" works.
There isn't any repeating code when using deep sleep so the
loop() code doesn't exist. After each boot the code exectutes only
once and then ESP turns off until the signal change on GPIO16 pin (which I connected to RST input) restarts the ESP8266.
After deep sleep mode is activated ESP turns off everything except a counter circuit which draws only negligible current which means deep sleep is extremely low-power-mode in which ESP could work for months just on a small battery from a watch.
During deep sleep there is only a counter working and when it counts for the preset number of ticks it generates low pulse on GPIO16.
To wake up ESP8266 from deep sleep the low pulse on RST input which will reset the processor has to be generated.
From the above it is clear if you connect GPIO16 to RST, ESP will be able to wake up by itself (without need of an external circuit).
jumpjack wrote:Is there any tutorial, or a ready-made library, to build a sleep-enabled logger?
The code I wrote in the question is what you are looking for. Noone can write the code to read the sensors and to post the results on some server in advance. You first have to decide what your device is going to do and only then you can write the code.
Chupo_cro