-->
Page 2 of 4

Re: Why must I use WiFi.forceSleepWake() after deep sleep?

PostPosted: Tue Dec 20, 2016 9:08 am
by mrburnette
Why?

The ESP8266 WiFi object is patterned after the WiFi Arduino library. In the Arduino world, WiFi.forceSleepWake() invokes low-level code to return the radio to the On state and in the proper sequence.

My assumption, without going to github and looking, is the ESP8266 code does exactly the same functions.

Ray

Re: Why must I use WiFi.forceSleepWake() after deep sleep?

PostPosted: Tue Dec 20, 2016 4:32 pm
by schufti
Bug #2186 is: 'WiFi.begin doesn't connect if connection was already established', but how a connection could already be established upon reset when I am using:

WiFi.persistent(false);


Maybe from some earlier sketch. WiFi.persistent(false) doesn't remove allready stored credentials neither replaces them or prevents reconnect with stored values; it just does not store the actually provided ones in flash on successful connect.

Change the PW on your WiFi and see if it still reconnects at startup.


There isn't v2.3.0 or v.2.2.0 on the list. I selected NodeMCU 1.0 (ESP-12E module) board.

It is not regarding the board you use, it is the Version of ESP-Package (look in board-manager).

Re: Why must I use WiFi.forceSleepWake() after deep sleep?

PostPosted: Fri Dec 23, 2016 9:02 am
by chupo_cro
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.

Re: Why must I use WiFi.forceSleepWake() after deep sleep?

PostPosted: Fri Dec 23, 2016 9:15 am
by chupo_cro
mrburnette wrote:Why?

The ESP8266 WiFi object is patterned after the WiFi Arduino library. In the Arduino world, WiFi.forceSleepWake() invokes low-level code to return the radio to the On state and in the proper sequence.

My assumption, without going to github and looking, is the ESP8266 code does exactly the same functions.

Ray

Thank you for the reply but I did not ask what forceSleepWake() method does, I asked why would I have to use it after wake up.

I know what forceSleepWake() method does but everything should work even without that method. In fact, as I documented, it does work even without forceSleepWake(), but quite unreliable.