ESP8266 wdt reset when tring to control LED strip

Hello,
I’m trying to control an SK6812 RGBW strip with an ESP8266. I’ve copied a few effects from https://www.tweaking4all.com/hardware/arduino/arduino-all-ledstrip-effects-in-one and created a few myself. When using the effects alone I don’t get a watchdog timeout. The web part of the code also works alone. Are the LED effects somehow blocking essential WiFi functions?

The program works by the website sending a query parameter which is then decoded and then changes the color and chosen effect.

I’ve tried with multiple boards even ane ESP32 (I obviously changed the code). I also tried with the ESPAsyncWebServer library, but to no avail.

Another quick question about the forum. Is it better if I post with code integrated into the post or is it ok to give a zip file with the project?

LED_testing_web.zip (11.9 KB)

Hey d-march,

Just a few probing questions...

Do you have any idea where/when you reset? Does it happen without any input? Does it happen when you make a web request to the device? Is it maybe only on a certain effect (e.g. if you fail on boot, maybe try changing the initial effect)?

Also, are you sure this is a watchdog timer issue? Perhaps you could try printing over serial how long each iteration of loop() is taking; That could help with debugging if you think it IS a watchdog timer issue.

Also, on code posting - generally, it seems that integrating it into a post is preferred, but I think in this scenario with multiple files separated like this it might be best to just attach it in a zip. Not sure what others think about that.

d-march:
Another quick question about the forum. Is it better if I post with code integrated into the post or is it ok to give a zip file with the project?

Most people will ignore a zip file. Please read these two posts:

General Guidance and How to use the Forum
and
Read this before posting a programming question ...

Maybe yield(); ? ? ?

binaryfissiongames:
Do you have any idea where/when you reset? Does it happen without any input? Does it happen when you make a web request to the device? Is it maybe only on a certain effect (e.g. if you fail on boot, maybe try changing the initial effect)?

I forgot to mention that it even happens with a simple static effect. It does seem to reset at random, if I leave it overnight and come back it has reset multiple times. However, the chance of it resetting is definitively higher when I make a web request.

The ESPs will reset any time your code ties up the processor for too long. I have no clue what the threshold is, but if there is ANYTHING in your code that is monopolizing the processor for more than a very few milliseconds, you need to do something to return control to the "OS". This can be a simple short delay call, or I believe there is a yield() function that can be called.

Go through your code and find any loops that could potentially run for a long time, and that will probably be your problem.

Regards,
Ray L.

What is the power supply being used?

The issue seems to me that you are using a 'bit-banged' method to send the ledstrip signal.
neopixel.h turns off interrupts for the time it sends this signal due to the timing being critical.
Since the WiFi connection uses interrupts extensively it will impossible to create a stable system that combines wifi & ledstrip using a 'bit-banged' method. You will have to change to using Makuna NeoPixelBus It will be a bit of work, but using the default DMA mode will resolve your issue.
That it occurs mainly in your static color is actually caused by interrupts being turned of nearly all the time,
It loops, and sends, and just a few statements further on it loops again. Adding a 15ms delay

    case 0 : {
                //static
                setAll(RED_CHANNEL, GREEN_CHANNEL, BLUE_CHANNEL, WHITE_CHANNEL);
                break;
             }

here, will already improve your stability, but in the end you will find that your wifi will become non-responsive after some time (minutes/ hours/ days, but it will)
Seeing that all your patterns are delay based, i suppose you should probably use AsyncESPwebserver, though ideally (and i mean, .. really !!) you should make your patterns millis() (or even better millis() & modulo) based.

RayLivingston:
The ESPs will reset any time your code ties up the processor for too long. I have no clue what the threshold is, but if there is ANYTHING in your code that is monopolizing the processor for more than a very few milliseconds, you need to do something to return control to the "OS". This can be a simple short delay call, or I believe there is a yield() function that can be called.

Go through your code and find any loops that could potentially run for a long time, and that will probably be your problem.

Thanks. I will look into it.

ieee488:
What is the power supply being used?

Usually, I just power the ESP8266 and a 60 led strip of a USB port. But it still happens if I connect them to an external 5V30A power supply.

Deva_Rishi:
The issue seems to me that you are using a ‘bit-banged’ method to send the ledstrip signal.
neopixel.h turns off interrupts for the time it sends this signal due to the timing being critical.
Since the WiFi connection uses interrupts extensively it will impossible to create a stable system that combines wifi & ledstrip using a ‘bit-banged’ method. You will have to change to using Makuna NeoPixelBus It will be a bit of work, but using the default DMA mode will resolve your issue.

I’ve looked at the NeoPixelBus library before, but I was a bit too lazy to implement it. I will definitely take a look at it now. Thanks for the help!

Hello d March
Did you solve the problem. i am also on same project with ESP32. Could you share your code.
Thanks

George113355:
Hello d March
Did you solve the problem. i am also on same project with ESP32. Could you share your code.
Thanks

I know this is a bit late, but I ended up changing to the NeoPixelBus library which solved the problem. It was really quite easy. Here is the code, definitely not optimal, it takes quite some time to change effect especially with many LEDs, but it works for my purposes.

NeoPixelBus_webcontrol.zip (10.2 KB)

RayLivingston:
The ESPs will reset any time your code ties up the processor for too long. I have no clue what the threshold is,

It's actually quite generous, 3.2 seconds.

The ESP8266 is a little different than the standard Arduino boards in that it has the watchdog(WDT) turned on by default. If the watchdog timer isn't periodically reset then it will automatically reset your ESP8266. The watchdog is reset every time loop() runs or you call delay() or yield() but if you have blocking code like a while or for loop then the watchdog may time out, resulting in your reset.