I needed to make a change to an ESP-01 I have running in a project, but after I uploaded the code, I started seeing this (on the serial monitor) repeat every few seconds:
Here is what I've tried to troubleshoot the problem:
I've tried FOUR different programmers
THREE different ESP-01's
Three different USB cables
TWO different USB Hubs
I tried to program them in Mac and Windows (via Virtual Machine)
Minimal sketch - (just a blank Setup and Loop)
NOTHING is working... when they get in this mode, are they not able to be programmed anymore?
I guess I should mention that when I upload a sketch, it uploads just fine ... acts like it always does ... but then after the upload is finished, I get that text repeating over and over.
There is something wrong in your code, triggering a soft watchDogTimer reset. This error occurs when there is a loop that takes longer than 1.5 Seconds to complete and in which the WDT is not reset.
yield(); resets the wdt and executed scheduled tasks.
delay() call yield() and yield is called at the end of loop() as well.
Find the long (or infinite) loop in your sketch and add yield() to that.
Since it is about a ESP-01, there is not much chance that there is something connected to the GPIO pins causing this behavior, so what core are you using and what are the settings ?
OK, I exaggerated a little on the blank sketch, I did have ONLY the Wifi connection code in there just to see if it could come up ... but when Deva_Rishi mentioned the delay issue ... I realized that I have a routine in there that someone told me to use instead of delay ... this is the routine:
void wait(unsigned long time) {
unsigned long start=millis();
while(millis()-start < time);
}
When I removed it and used delay instead, it is now working.
Well, in this case, the only reason for pausing at all is in the code that connects it to the WiFi:
void startWiFi() {
int conn_tries = 0;
WiFi.mode(WIFI_STA);
WiFi.config(localIP,gateway,subnetMask);
WiFi.begin(homeSSID, homePassword);
while ((WiFi.status() != WL_CONNECTED) && (conn_tries++ < WIFI_RETRIES)) {
wait(200);
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println("Wifi Connected");
Udp.begin(port);
}
else {
Serial.println("Wifi NOT Connected");
}
}
Here is the modified wait() method
void wait(unsigned long time) {
unsigned long start=millis();
while(millis()-start < time) {
yield();
};
}
After that, it only really does three things ... when it gets UDP data, it echo's it on the serial port for the attached ATMEGA 328P-U chip which then does stuff and sends back over serial more data that the wifi then sends over UDP .... it's just a relay. It also sends the word 'ping' every 30 seconds so my Java program will know it's online. The 30 seconds in this case is using a non-blocking timer that I wrote.