Node Mcu goes offline randomly

It seems like you’ve taken the Edgent example and hacked-out all the important bits, then added-in most of what should be needed to get your device online.

However. You’ve left this…

Instead of using the required Blynk.run(); line of code.

You’re also missing the three lines of firmware configuration from the Device > Device Info screen and when you add that in you should change this…

to this…

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

You can also delete this…

and this…

It’s also a bad idea to use Blynk.syncAll() for the reasons described at the end of this post…

Next time it would be better if you started with a non-Edgent example!

Pete.