Esp32 Restarting Automatically If Not Connected To Hotspot

When you use interrupts, there are a couple of things that you should keep in your mind.

  1. You should keep the ISR (interrupt service routine) as short as possible.

  2. Avoid blocking functions, like delays.

  3. Avoid serial prints.

  4. Avoid non-reentrant function calls.

  5. Don’t declare any non-static variables inside the handler.

  6. Avoid operations that involve dynamic memory allocations.

You can search the web for more details.

1 Like

Remove all the blynk related bits from ISR.

Create one more function with the same functionality with added blynk writes and call the same with a timer.

This way when there is no internet your switch will work with ISR and when there is internet connection there will be no more blocking to the timer so you will get real-time feedback.

Try to keep ISR really short. Too much if’s and else will crash your esp.