Esp8266-01 sometimes unresponsive and restarting

esp8266-01
Android 8.2
Blynk server
Blynk v 0.6.1


BLYNK_WRITE(V1)
{
  int pinValue = param.asInt();

  if ( hour() > 12 ) {
    HOUR = hour() - 12;
    strcpy(APM, "PM");
  } else {
    HOUR = hour();
    strcpy(APM, "AM");
  }
  // String currentTime = String(hour()) + ":" + minute() + ":" + second();

  String Time = String(HOUR) + ":" + minute() + " " + APM + "  " + day() + "/" + month() + "/" + year();



  if (pinValue == 1)
  {
    digitalWrite(Relay_1, HIGH);
    terminal.println(String(Device_Name) + " : On   " + Time);
    terminal.flush();
  }
  else if (pinValue == 0)
  {
    digitalWrite(Relay_1, LOW);
    terminal.println(String(Device_Name) + " : Off  " + Time);
    terminal.flush();
  }
}

Everything works well without connecting light to the relay
When Connecting light to the relay, sometimes unresponsive and restarting

Is the problem electrical or software
Or the problem is in the relay or esp-01

Can not tell by this code. I would need to see complete code.

If it works fine without any load across the relay, but you have problems when a load is applied then I’d say it sounds like electrical.
Having said that, it could be badly written code and just coincidence that you see the disconnections when there is a load applied.

Most relay boards designed for MCUs have optisolation, but I’m not sure that would help in this case, but it might be worth you getting hold of one and trying it.
I’d be tempted to put some suppression on the live side of the relay, in the form of a smoothing capacitor, and see if that helps.

It reminds me of this thread, which might be worth you reading through…

Pete.

1 Like

it works fine without any load across the relay

Probably EMF then.

Pete.

My circuit works well more than one year now , It has 2 relays and works with blynk with high stability … Try to use 2N2222 instead of your Q1 . And yes it sounds like an electrical issue with high load .
best regards