Skip to content

Commit 229be71

Browse files
committed
Avoid random watchdog resets when putting the wifi modem to sleep
esp8266/Arduino#6172
1 parent b8b5cac commit 229be71

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

esp8266-clockradio.ino

+16-2
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,16 @@ void setup() {
131131
localSeconds = epoch + gmtOffset_sec;
132132
}
133133

134+
135+
// XXX: Unfortunately Forcing the wifi to disconnect and then sleep can cause a random watchdog reset
136+
// See https://github.com/esp8266/Arduino/issues/6172
137+
// For skip the disconnect until this bug is fixed.
138+
134139
Serial.println("Modem to sleep!");
135-
WiFi.disconnect();
140+
// WiFi.disconnect();
136141
WiFi.mode(WIFI_OFF);
137142
WiFi.forceSleepBegin();
143+
138144
delay(1);
139145
}
140146

@@ -178,8 +184,16 @@ void loop() {
178184
Serial.print(delaySeconds);
179185
Serial.println(" seconds.");
180186

181-
delay(delaySeconds * 1000);
182187
localSeconds += delaySeconds;
188+
#ifdef DEBUG
189+
while (delaySeconds-- >= 1) {
190+
Serial.print("Waiting: ");
191+
Serial.println(delaySeconds);
192+
delay(1000);
193+
}
194+
#else
195+
delay(delaySeconds * 1000);
196+
#endif
183197
}
184198

185199
// send an NTP request to the time server at the given address

0 commit comments

Comments
 (0)