My relays dont work if wifi is bad and ESP32 is offline

That’s a very bold claim!
My stats show that I’ve visited this forum every day for the past 7 years and read over 135,000 posts, but I certainly wouldn’t claim that I’ve read everything.

This piece of code was written to demonstrate the process of connecting to WiFi then Blynk, then attempting to re-connect if either one of these connections fails…

Feel free to take the relevant parts that you need for your purposes, and to adjust the parameters to suit your requirements (bear in mind that this was written to debunk a particular claim regarding a bug in the library, not as a functional piece of code).

You’ll see that BlynkTimer is needed to periodically check the connection status. I’d suggest (once again) that you stop calling the PumpN() function from your void loop and instead call a modified version of that function (without the millis comparison code) with BlynkTimer.

BTW, pumps don’t generally like to be constantly started then stopped, although it does tend to depend on the type of motor they utilise. I have no idea what this pump is for, as you haven’t shared that information, but you may be better using some sort of liquid level sensor.

Pete.

1 Like