Relay opens on reset

Hello. I know this is not really blynk related but I tought I could get some help here. I’m using a NodeMCU to control a 2-relay module, one for the garage door and one for the front gate. Works fine until the MCU restarts. When it does, right before connecting to the Blynk server, it sends a short signal that opens the relays. The problem is the one that acts the gate as the one for the garage needs a much longer signal for it to act. The gate relay is connected to the D7 pin of the nodemcu. Ia there any way to stop this?

Do you have a pinMode and digitalWrite set up to counteract this?

Pete.

Nope! I added the gate later and I didn’t edit the code, I just connected the relay to a pin and set it up in the blynk app. Should I add both the pinmode and the digitalwrite function in void setup? Also, will this solve the problem? The way I see it, the relay is open while the nodemcu is initialising.

That’s the first thing I’d try. I’d also ensure that I wasn’t using a pin that oscillates at startup…

I’d then move on to using virtual pins in my app and adjust the code accordingly.

Pete.

Yup, using the digital pin was kind of a lazy solution as I didn’t have my laptop on menat the time. And it did work for a whille, but for the past few weeks the board would keep reseting and each time it did the gate would open. I’ve made the changes you suggested and I also changed the board, I’m hoping it will work