Nodemcu problem when electricity cut off and come back

hi dear blynkers, ım new on that platform,
I’m having problems with the apartment door project. I completed the blynk installation on the nodemcu module and completed one channel relay module connection. Normally the system works fine, but when I disconnect the electric current and turn it on again, I saw that the relay is continuosly active till ı press the button on blynk app.
what should ı do to solve this problem,if the system works this way continuously, the door automation keeps running and disturbing neighbors when there is a power failure,

This is a commonly mentioned issue in this forum. You can search for all the various topics for more details… but what it comes down to is you need to synchronize your last vPin settings when the device powers up.

What @GTT said. Additionally its good to know that

  1. relays usually are active when the pin is LOW
  2. esps after reboot usually go up (for 100ms) and then LOW in default.

What I do is initialize all my pins on setup (exactly for those kinds of cases as you describe) so from my setup() function:
pinMode(HEATER_RELAY_PIN_1, OUTPUT); // Set ESP pin to output to the relay
digitalWrite(HEATER_RELAY_PIN_1, HIGH); // activate = LOW, deactivate = HIGH

beyond that you can use e.g. sync with the server as gunner described.

edit: this is also very helpful!

hi gunner, thanks for solving, could you write me full code list.

Sorry, no. This is not a code factory, we help you learn Blynk, not write code on request.

thank you I am working on it ıf ı need I will refer you to your views

dear Gunner
ı’ve solved continuosly working problem with IRFZ 44 N mosfet to trigger the relay
the problem was that the current was constantly going out to the pins when the nodemcu module was disconnected and re-powered.
first if electricity turned off and on, pins which ı selected on blynk to control the relay, was working while internet connection complated
second if electricity turned off and on and if nodemcu couldnt connet to internet , pins are ( any pin on the nodemcu) giving 3,27 v continuosly

all one is solved with mosfet pull down with 5k resistor between gate and source.

thanks all.

1 Like

Hi Husmen,

I am a complete newbie in Blynk and nodemcu. I am also facing the same issue… I could not understand fully the solution.

Where do I need to put the resistor and what else should be done…

Any help in this would be very helpful.

My guess is that you have a relay or sensor connected to one of the ‘special’ pins of the NodeMCU, which is preventing I from booting into ‘run’ mode.

These ‘special’ pins are GPIP0 (D3), GPIO2 (D4) and GPIO15 (D8).
See this post for more info…

The simple solution is to avoid using these pins.


1 Like

Thanks Mr. Pete for responding,

I am using a single output D0 pin, which is not special purpose pin, though as per your suggestion, I checked connecting the output in multiple other pins one by one, but issue is not solved.

But what I observed, after changing the pin in hardware, if I don’t change the pin-out in Blynk app, the power reset don’t have any impact on other pin.

So the only pin which generates the output while power goes off and on , is the pin which I configured in the Blynk, Other pins are not impacted by power on/off .

One roundabout way I found is I can keep configure my Blynk app pin to some random pin, and whenever I have to use the system, I change to the desired pin and use it, post use again put random pin in Blynk app. So that when I am away system is safe and don’t turn on automatically.

But I wanted to solve this via code, so that I don’t way to use this round about way…

What device type did you select in your app?

I’m not clear what this, and your subsequent paragraph actually mean in practice. I’d suggest that you are more specific about the steps you have taken, otherwise it’s impossible to understand what changes you’ve made in the app, the code and the connections to the board.

As far as the solution is concerned, I’d recommend using only virtual pins in your app, and handling the subsequent BLYNK_WRITE(vPin) callbacks to control your relay.