-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v2.4.0 and Soft WDT reset while WiFi.forceSleepBegin() execution #4082
Comments
perhaps related to |
@essenemari could you please add the definitions of Edit: never mind, figured out their values.
and 15000 and 10000 changed to 2000 and 3000. However, i get hardware WDT reset instead of soft WDT, and it happens after "Sleeping" is printed. |
@essenemari Could you please try with "lwIP Variant" set to "v1.4 Prebuilt" in Tools menu? I'm not getting my variant of the crash with lwIP 1.4. |
Hello igrr, Thank You! Sketch#include "Base64.h" DebbugInitial WiFi connection OK Soft WDT reset ctx: cont
ets Jan 8 2013,rst cause:2, boot mode:(1,0) ets Jan 8 2013,rst cause:4, boot mode:(1,0) wdt reset |
Same problem here... Switched to 2.4.0-rc2 and all works again. Exception was:
Decoded stack trace:
|
Hi, I also reproduced the bug. I have no explanation why it was working with 2.4.0rc2. Normal loop:
With waiting loop otherwise crash happen:
Updated full sketch:
|
@Thelmos @essenemari can you try this fix ? |
@d-a-v Just started the tests off your fix. For now, the 45 second loop works fine. Thanks! //4 hours later |
I tested the WiFiOff(), WiFiOn() -functions above with 2.4.0 code and lwIP v1.4 prebuilt. Their functionality was put into my project involving conencting to an MQTT-broker via "256dpi/arduino-mqtt". My goal was to run ESP on less power by having no WiFi when not needed. |
I ran into same issue with 2.4.2, getting SoftWDT when invoking forceSleepBegin(). My workaround is to add a delay between disconnect and sleep. This code snippet works:
|
I had the same problem.. @ardyesp's workaround seems working so far.. thx a lot for sharing |
As in esp8266/Arduino#4082 "Switched to 2.4.0-rc2 and all works again." https://github.com/platformio/platform- espressif8266/commit/7574b5c4dbf0450087b75c9199a3db86854e6b5b
Similar problem here, I upgraded to IDE 2.4.2 primarily trying to solve the flash problem introduced by manufacturers using the PUYA flash chips - see issue #4061
I tried all the 2.4.* versions and went back to 2.3.0 and suddenly the issue disappeared. (I had to patch in the fix for the PUYA chips each time) |
The issue is not in the core releases, but a change in sleep behavior in newer sdk versions. Among the behavior changes, e.g. you can't do "sleep for max int" anymore. |
Thanks @devyte However I am a little confused here. (Sorry happens a lot) I have upgraded to version 2.2.4 using the boards manager, I would think that was the latest version as per the esp8266/Arduino git. However when I chase through the documentation I see https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/generic-class.html?highlight=sleep section WiFi power management, DTIM I see a reference to esp8266-arduino core v2.5.0 using the last V2 revision of nonos-sdk before V3). Is this the version you are referring to and where do I find it? |
As I said above, the issue is due to changes in newer sdk versions. Latest git, aka master branch, integrates sdk pre-3, which provides an api to set sleep type. Our core was modified to make use of it.That is not released yet, you have to uninstall whatever you installed with board manager and install latest git. |
@devyte I have spent many hours trying to get the latest git version into the Arduino IDE, so please can I get a little help here. Generally all my efforts result in some sort of esptool failure to upload the sketch to the ESP device. Having never actually installed the latest git before I think this would be a useful source for others as there is a lot of confusion out there in search land. Build options changed, rebuilding all
esptool: error: argument operation: invalid choice: 'C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/bootloaders/eboot/eboot.elf' (choose from 'load_ram', 'dump_mem', 'read_mem', 'write_mem', 'write_flash', 'run', 'image_info', 'make_image', 'elf2image', 'read_mac', 'chip_id', 'flash_id', 'read_flash_status', 'write_flash_status', 'read_flash', 'verify_flash', 'erase_flash', 'erase_region', 'version') I think we are close to getting a method but this last error throws me. Obviously esptool is not being called with the appropriate inclusions but this must be a problem with picking them up from the IDE settings (which I have changed several times and they are the correct ones) The section on the main GIT page really needs some filling out for anyone who is trying to do this for the first time. Even some mention of having to unintall previous versions from the IDE would save some hours. |
farther to the last posting, the only way I have been able to get my sketch to upload was to install ver 2.4.2 in the IDE then copy all the files from the clone of the git over the files in .../Arduino15/.../2.4.2/. As soon as the forceSleepBegin is executed the whole thing goes into reset. There is virtually no documentation on the new sleep functions as far as I can find so I am not sure I am doing it right. Any comments there? |
Try ESP.deepSleepInstant() instead |
@devyte But I don't want deep sleep, the process requires light sleep, not deep sleep, reset etc |
@devyte Thanks for your help. I really appreciated everything you can provide. This product is semi commercial and we have been stalled, not able to go back (PUYA chip problem) and not able to go forwared (Light sleep problem) |
Farther to the last post @devyte , what is the solution to the inability to upload a sketch to the device because of the esptool.exe issue I raised above. When I delete 2.4.2 and install the git clone the esptool does not work, see the print out 2 days ago |
Has anyone got an example of light sleep happening successfully with 2.4.2 or the git clone or any other mods, basically hitting my head against a wall here and not getting anywhere. |
@devyte , @igrr Guys, I would really appreciate some help here, I know that you are busy.
|
I can confirm that using the latest git version (master) as of nov 14 has light sleep working. All you need to do is call I have not tried Overall, I'd says that the esp8266 still sucks at low power. It seems Espressif has fixed almost nothing in the past two years. Really disappointing. |
Hello everybody, "wifi_station_get_connect_status" (see suggestion from @d-a-v - thank's for that!) won't work for me. With 2.5.0 (lwIP v1.4 or v2) I use tickers to check, whether the connection is established or not (every 5secs) and also a ticker to force sleep after disconnect (3secs). I also use "setSleepMode" with highest listenInterval. That gives me less than 20mA most of the time. If a connection is tried to be established or is currently used the current is 70mA and if the connection is lost (router's WiFi turned off) 70mA (with bursts up to 250mA) for max. 5secs. Here's the full sketch with a simple WebServer as example: #include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <Ticker.h>
const char* ssid = "...";
const char* password = "...";
ESP8266WebServer webServer (80);
Ticker staTicker;
Ticker offTicker;
bool staOn = true; // true, if WiFi is on
byte requests; // just to let the webServer return something
void setup(void) {
delay(1000); // power up
pinMode (2, OUTPUT); // LED near antenna is on while WiFi is on (just an example)
WiFi.persistent (false); // I just hate the persistent nonsense
WiFi.setSleepMode (WIFI_MODEM_SLEEP, 10); // Save power if connection is established but not used (delay in loop required!)
staTurnOn (); // Try to establish connection
webServer.on("/", []() {
webServer.send (200, "text/plain", "Hello #" + String (++requests));
});
webServer.begin (); // Needs to be started only once even if connection gets lost for a while
}
void staTurnOn () {
WiFi.mode (WIFI_STA); // Set always, because set to WIFI_OFF in offTick
WiFi.begin (ssid, password); // GO!
staTicker.detach (); // Because staTurnOn is called from staTick
staTicker.attach (5.0, staTick); // Check in 5 seconds if we are connected
}
void staTurnOff () {
WiFi.disconnect (); // STOP!
offTicker.attach (3.0, offTick); // After 3 seconds force sleep
staTicker.detach (); // Because staTurnOn is called from staTick
staTicker.attach (180.0, staTick); // Check again in 3 minutes
}
void staTick () {
if (staOn) {
if (WiFi.status () == WL_CONNECTED) return;
staTurnOff ();
staOn = false;
} else {
WiFi.forceSleepWake ();
staTurnOn ();
staOn = true;
}
}
void offTick () {
offTicker.detach (); // only once!
WiFi.mode (WIFI_OFF); // Required to make forceSleepBegin work
WiFi.forceSleepBegin (); // Turns current down permanently to <20mA (needs delay in loop, too)
}
void loop(void) {
if (staOn) { // We don't need to handle if WiFi is off
// Other stuff like DNS can go here, too...
webServer.handleClient();
}
// Your code goes here...
digitalWrite (2, (staOn) ? LOW : HIGH);
delay (10); // Together with setSleepMode in the setup it saves power
} |
Just to confirm, I still had the same issue with WiFi.forceSleepBegin() after upgrading from 2.3 to 2.5. The workaround posted by ardyesp above worked for me, my sketch has been up for over two days down, with a force sleep every 60 seconds. As an aside, I also had a mqtt publish statement directly before the WiFi.forceSleepBegin() statement that worked in 2.3. With 2.5 the message was not published until I added another small sleep(1000) just before WiForceSleepBegin(). It now looks like this
|
Closing as we've got an active discussion of this in #6172 where folks are making some progress, I believe. |
Basic Infos
After board upgrade: "esp8266 by Community" from 2.3.0 to 2.4.0 observed Soft WDT reset on WiFi.forceSleepBegin(); execution.
Hardware
Hardware: ESP-12E, ESP-07
Core Version: 2.4.0
Description
Hi Team,
thanks a lot for your awesome work on ESP8266! Appreciate!
I am using WiFi.forceSleepBegin(); as critical command to turn off WiFi module for 10 minutes then turnning on WiFi module for 15 seconds to execute commands then turn WiFi off again. On 2.3.0 it does work perfect (currently ~10 ESP devices).
Noticed recently, that there is new 2.4.0 ESP8266 board software version, so upgraded and found out that my ESPs are reseting. If you'll take a look for loop it crashes exactly after
Serial.println("Before WiFi.forceSleepBegin()");
and usually on 2nd or 3rd loop.When downgraded to esp v2.3.0 - back to normal.
Settings in IDE
Module: Generic ESP8266 Module
Flash Size: 521K
CPU Frequency: 80Mhz
Flash Mode: dio
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: ck
Sketch
#include "JsonStreamingParser.h"
#include "JsonListener.h"
#include "ExampleParser.h"
#include "Base64.h"
#include <ESP8266WiFi.h>
long int cykl_counter_start = 600000;
void setup() {
}
void loop() {
for (cykl_counter = cykl_counter_start; cykl_counter > 0; cykl_counter--) {
delay(1);
if (cykl_counter == cykl_counter_delay) {
delay(100);
Serial.println("Before WiFi.forceSleepBegin()");
WiFi.forceSleepBegin();
delay(100);
Serial.println("Sleeping");
}
if (cykl_counter == 15000) {
Serial.println("WiFi.forceSleepWake()");
WiFi.forceSleepWake();
Serial.println("Wakeing");
delay(100);
}
if (cykl_counter == 10000) {
Serial.println("Tasks");
delay(100);
}
}
}
Debug Messages
The text was updated successfully, but these errors were encountered: