Press the button I need to relay turn off after 1-2 seconds even if d1 mini disconnects

.Can you able to help me? I just want to control 5v relay with D1 mini (esp8266) so when I press the button I need to relay turn off after 1-2 seconds even if d1 mini disconnects. Sometimes when I constantly press the button D1 mini disconnects from internet and relay stays ON until resets and connects back. How I can solve this problem, is it possible with coding or is it the best on hardware side such as adding 555 timer or Atiny85 chips. Truly I don’t know if it will work wiring extra chips on esp8266. I will appreciate any given info :D.

Hello @speed57 I moved your MSG here as these questions are best in the forum for all to learn.

No need for external timer chips, but you will need code. By using virtual pins, BlynkTimer and other connection management techniques to keep your ESP running, even if not connected to Blynk’s server, you will be able to accomplish what you are looking for.

All of this is already covered in detail throughout this forum and in the documentation. However, there are multiple searches required here… look for these key words/phrases as well… Timed relay, Connection Management, Run sketch without internet, etc.

For example…

1 Like

Thanks Gunner for pointing out :smiley:

BLYNK_WRITE(inputPin) {
  if (param.asInt()) { // act only on the HIGH and not the LOW of the momentary
    digitalWrite(outputPin, !digitalRead(outputPin));  // invert pin state just once
    tripWire.setTimeout(1000L, [](){
      digitalWrite(outputPin, !digitalRead(outputPin));  // then invert it back after 1000ms
    });
  }
}

these is perfect. @Jamin thank you also:D

1 Like