Can all switches state be remained when internet connection loss?

I encounter a problem. My room light’s switches are controlled by Blynk App that connected to NodeMCU. i found that all the switches are turn off when the NodeMCU is disconnected to the wifi router due to wifi router power supply cut off. But the NodeMCU is still power ON. Can all the light’s switches remain ON although NodeMCU disconnected with the wifi router while the NodeMCU still power ON ? How to sketch to remain all switches state?

Is it possible that all of your power was interrupted for a short while, causing both your NodeMCU and your router to reboot?
In this scenario, the output pins of your NodeMCU would return to their default state and this may put your lights off.

The solution will depend on your code, which pins you’re using to control your relays, whether your relays respond to an active High or active Low signal, and what re-connection routines you’re using to re-establish a Wi-Fi connection and re-synchronise your lights with the Blynk server.

Pete.

How is the code to remain all Lights state although the wifi router power off. How to sketch the code? If the wifi router power didn’t interrupted, the light’s circuit is working properly. The relay is active LOW.

So you’ve answered one part of one of my questions and you expect me to be able to wave a magic wand and make everything work for you?

If you provide the information that I’ve asked for then I, and other forum members with much more Blynk and coding experience than me, wil take a look at the information and see if we can work-out what’s causing your issue and success some improvements to hopefully overcome the problem.

I won’t be writing your code for you, and I doubt that any other community members will either, but we will share our knowledge and experience if you’re forthcoming with the information that allows us to help you diagnose your problem.

Pete.

1 Like

I do this by storing the state of each relay pin in a virtual pin ie every time I write to a physical pin I also write to a virtual pin whichis stored on server. On a reset or power loss etc I do a syn each virtual pin at start up and do the same to the digital pin therefore reinstating the status of each relay at time of failure

look through this

Cheers

kev