BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

The device goes offline after a certain time and then does not work again without a reset

Hello I installed a garden irrigation system with 2 relays. The codes are below.
The system goes offline after a while and does not work again without a reset.
Thank you for your help.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "xxxxxxxxx";
char ssid[] = "xxxxx";
char pass[] = "xxxxxxxx";

BlynkTimer timer;
boolean stateled = 0;
boolean prevStateled = 0;

void myTimerEvent()
{
  Blynk.virtualWrite(V0,millis() / 1000);
  Blynk.virtualWrite(V1,millis() / 1000);
}

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT); // NODEMCU PIN D7
  pinMode(12, OUTPUT); // NODEMCU PIN D6

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(3000L, checkledstate);

}
BLYNK_WRITE(V0)
{
  if (param.asInt()) {
    digitalWrite(13, HIGH); Blynk.virtualWrite(V13, 255); Blynk.notify("led ACTIVADO");
  } else
  {
    digitalWrite(13, LOW);  Blynk.virtualWrite(V13, 0);
  }
}
BLYNK_WRITE(V1)
{
  if (param.asInt()) {
    digitalWrite(13, HIGH); Blynk.virtualWrite(V13, 255); Blynk.notify("led ACTIVADO");
  } else {
    digitalWrite(13, LOW);  Blynk.virtualWrite(V13, 0);
  }
}

BLYNK_WRITE(V2)
{
  if (param.asInt()) {
    digitalWrite(12, HIGH); Blynk.virtualWrite(V12, 255); Blynk.notify("led ACTIVADO");
  } else
  {
    digitalWrite(12, LOW);  Blynk.virtualWrite(V12, 0);
  }
}
BLYNK_WRITE(V3)
{
  if (param.asInt()) {
    digitalWrite(12, HIGH); Blynk.virtualWrite(V12, 255); Blynk.notify("led ACTIVADO");
  } else {
    digitalWrite(12, LOW);  Blynk.virtualWrite(V12, 0);
  }
}
void loop()
{
  if (Blynk.connected())
  {
    Blynk.run();
  }
  timer.run();
}
BLYNK_CONNECTED()
{
  Blynk.syncAll();
}
void checkledstate()
{

  **stateled = digitalRead(13);**
**  stateled = digitalRead(12);**
**  if (stateled != prevStateled)**
**  {**
**    if (stateled == 0) Blynk.virtualWrite(V13, 0); Blynk.notify("led ACTIVADO");**
**    if (stateled == 1) Blynk.virtualWrite(V13, 255);**
**    if (stateled == 0) Blynk.virtualWrite(V12, 0); Blynk.notify("led ACTIVADO");**
**    if (stateled == 1) Blynk.virtualWrite(V12, 255);**
**  }**
**  prevStateled = stateled;**
**}**

Hello I installed a garden irrigation system with 2 relays. The codes are below.
The system goes offline after a while and does not work again without a reset.
Thank you for your help.

Cihaz : Nodemcu
IOS


#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "ftpfmubeA9zqQMCt04A0uluFnJ857CNh";
char ssid[] = "994-ALT";
char pass[] = "Ayhan123";

BlynkTimer timer;
boolean stateled = 0;
boolean prevStateled = 0;

void myTimerEvent()
{
  Blynk.virtualWrite(V0,millis() / 1000);
  Blynk.virtualWrite(V1,millis() / 1000);
}

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT); // NODEMCU PIN D7
  pinMode(12, OUTPUT); // NODEMCU PIN D6

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(3000L, checkledstate);

}
BLYNK_WRITE(V0)
{
  if (param.asInt()) {
    digitalWrite(13, HIGH); Blynk.virtualWrite(V13, 255); Blynk.notify("led ACTIVADO");
  } else
  {
    digitalWrite(13, LOW);  Blynk.virtualWrite(V13, 0);
  }
}
BLYNK_WRITE(V1)
{
  if (param.asInt()) {
    digitalWrite(13, HIGH); Blynk.virtualWrite(V13, 255); Blynk.notify("led ACTIVADO");
  } else {
    digitalWrite(13, LOW);  Blynk.virtualWrite(V13, 0);
  }
}

BLYNK_WRITE(V2)
{
  if (param.asInt()) {
    digitalWrite(12, HIGH); Blynk.virtualWrite(V12, 255); Blynk.notify("led ACTIVADO");
  } else
  {
    digitalWrite(12, LOW);  Blynk.virtualWrite(V12, 0);
  }
}
BLYNK_WRITE(V3)
{
  if (param.asInt()) {
    digitalWrite(12, HIGH); Blynk.virtualWrite(V12, 255); Blynk.notify("led ACTIVADO");
  } else {
    digitalWrite(12, LOW);  Blynk.virtualWrite(V12, 0);
  }
}
void loop()
{
  if (Blynk.connected())
  {
    Blynk.run();
  }
  timer.run();
}
BLYNK_CONNECTED()
{
  Blynk.syncAll();
}
void checkledstate()
{

  stateled = digitalRead(13);
  stateled = digitalRead(12);
  if (stateled != prevStateled)
  {
    if (stateled == 0) Blynk.virtualWrite(V13, 0); Blynk.notify("led ACTIVADO");
    if (stateled == 1) Blynk.virtualWrite(V13, 255);
    if (stateled == 0) Blynk.virtualWrite(V12, 0); Blynk.notify("led ACTIVADO");
    if (stateled == 1) Blynk.virtualWrite(V12, 255);
  }
  prevStateled = stateled;
}