Esp 01 is not connecting to the WiFi

Some days ago I had successfully connected my esp-01 with my wifi (on 19th of feb)
Even It was showing that
Wifi got IP
Wifi Connected
in the serial monitor
I tested on 20th and 21st of feb it was showing that it is connected to blynk nd wifi nd all.

But now I tried to do a different project with that esp that is the LED one, LED blinking project.
And In serial monitor it is showing that
Failed to connect with WiFi so i thought maybe my connection wasn’t right or esp may have got some problems. For confirming this issue I test with the simple esp-01 to arduino mega 2560 connection i.e,
Esp-01 To Arduino Mega 2560
Tx - Rx (18)
Rx - Tx (19)
CH_PD - 3.3v
Vcc - 3.3v
Gnd - Gnd
And now it is showing nothing on my serial monitor
Not even OK for AT command.

One more thing
If I connect those RX, TX to the RX, TX of 0 and 1 pin of Arduino mega then it is responding to the AT command but still not connecting to the WiFi

Plz help as I have to submit my project next week
(This is my first time on blynk community so plz understand it😉)

This is my program code

#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <Servo.h> 

char auth[] = "*******************************";
char ssid[] = "**********";
char pass[] = "****************";

const int outputpin1 = 52;
const int outputpin2 = 53;
int servoPin1 = 8; 
int servoPin2 = 9; 
int servoPin3 = 12;
int servoPin4 = 11;  
int stop1=4;
int stop2=7;
int back1=2;
int back2=5;
int pwm1=3;
int pwm2=6;
int pos=150;
int pos1=30;
int pos2=150;
int val1;
int val2;
boolean trash;
 
#define EspSerial Serial1
#define ESP8266_BAUD 115200
#define bintrig1 22
#define binecho1 23
#define bintrig2 24
#define binecho2 25
#define lefttrig 26
#define leftecho 27
#define righttrig 28
#define rightecho 29
#define rttrig 30
#define rtecho 31
#define rbtrig 32
#define rbecho 33
#define lttrig 34
#define ltecho 35
#define lbtrig 36
#define lbecho 37

ESP8266 wifi(&EspSerial);

BlynkTimer timer;
Servo myservo1;
Servo myservo2;
Servo mainservo;
Servo binservo; 

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

void setup()
{
  
  Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
  pinMode(outputpin1, INPUT); 
  pinMode(outputpin2, INPUT); 
  myservo1.attach(11);
  myservo2.attach(12);
  mainservo.attach(8);
  binservo.attach(9);
  binservo.write(0);
  myservo1.write(pos1);
  myservo2.write(pos2);
  mainservo.write(pos);
  pinMode(stop1, OUTPUT); 
  pinMode(stop2, OUTPUT); 
  pinMode(back1, OUTPUT); 
  pinMode(back2, OUTPUT); 
  pinMode(pwm1, OUTPUT); 
  pinMode(pwm2, OUTPUT); 
   
  pinMode(bintrig1,OUTPUT);
  pinMode(binecho1,INPUT);
  pinMode(bintrig2,OUTPUT);
  pinMode(binecho2,INPUT);
   pinMode(lefttrig,OUTPUT);
  pinMode(leftecho,INPUT);
   pinMode(righttrig,OUTPUT);
  pinMode(rightecho,INPUT);
   pinMode(rttrig,OUTPUT);
  pinMode(rtecho,INPUT);
   pinMode(rbtrig,OUTPUT);
  pinMode(rbecho,INPUT);
   pinMode(lttrig,OUTPUT);
  pinMode(ltecho,INPUT);
   pinMode(lbtrig,OUTPUT);
  pinMode(lbecho,INPUT);
}
BLYNK_WRITE(1) 
{
  if (param.asInt()==1) {       
        pin1_activated();   
    } 
    
  }
  BLYNK_WRITE(3) 
{
  if (param.asInt()==1) {       
        forward();
        delay(100);
        Stop();   
    } 
   
  }
BLYNK_WRITE(4) 
{
  if (param.asInt()==1) {       
        backward();
        delay(100);
        Stop(); 
        
    } 
    
  }
  BLYNK_WRITE(5) 
{
  if (param.asInt()==1) {       
        left(); 
        delay(100);
        Stop();
    } 
    
  }
   BLYNK_WRITE(6) 
{
  if (param.asInt()==1) {       
        right();
        delay(100);
        Stop();
    } 
  
  }
 BLYNK_WRITE(7) 
{
  if (param.asInt()==1) {       
        Stop(); 
    } 
    
  }
  BLYNK_WRITE(12) 
{
  if (param.asInt()==1) {       
        forward();   
    } 
    
  }
  BLYNK_WRITE(13) 
{
  if (param.asInt()==1) {       
        backward();   
    } 
    
  }
BLYNK_WRITE(2) 
{
  int x = param[0].asInt();
  int y = param[1].asInt();
  if(y>220)
  {forward();}
  else if(y<35)
  {backward();}
  else if(x>220)
  {right();}
  else if(x<35)
  {left();}
  else
  {Stop();}
}

int autostate;
BLYNK_WRITE(11) 
{
  autostate=param.asInt();
while(autostate==1){
  autonomous();}
 
  
  }
  
void autonomous(){
  int ldistance,rdistance,rtdistance,rbdistance,ltdistance,lbdistance,lduration,rduration,rtduration,rbduration,ltduration,lbduration;
   digitalWrite (lefttrig, HIGH);
   delayMicroseconds (1000);
   digitalWrite (lefttrig, LOW);
   lduration = pulseIn (leftecho, HIGH);
   ldistance = (lduration/2) / 29.1;
  
   digitalWrite (righttrig, HIGH);
   delayMicroseconds (1000);
   digitalWrite (righttrig, LOW);
   rduration = pulseIn (rightecho, HIGH);
   rdistance = (rduration/2) / 29.1;

  digitalWrite (rttrig, HIGH);
   delayMicroseconds (1000);
   digitalWrite (rttrig, LOW);
   rtduration = pulseIn (rtecho, HIGH);
   rtdistance = (rtduration/2) / 29.1;

   digitalWrite (rbtrig, HIGH);
   delayMicroseconds (1000);
   digitalWrite (rbtrig, LOW);
   rbduration = pulseIn (rbecho, HIGH);
   rbdistance = (rbduration/2) / 29.1;
  
  digitalWrite (lttrig, HIGH);
   delayMicroseconds (1000);
   digitalWrite (lttrig, LOW);
   ltduration = pulseIn (ltecho, HIGH);
   ltdistance = (ltduration/2) / 29.1;

   digitalWrite (lbtrig, HIGH);
   delayMicroseconds (1000);
   digitalWrite (lbtrig, LOW);
   lbduration = pulseIn (lbecho, HIGH);
   lbdistance = (lbduration/2) / 29.1;
while(ldistance<0){
  ldistance=399;}
  while(rdistance<0){
  rdistance=399;}
  while(rtdistance<0){
  rtdistance=399;}
  while(ltdistance<0){
  ltdistance=399;}
  while(rbdistance<0){
  rbdistance=399;}
  while(lbdistance<0){
  lbdistance=399;}


  aforward();
if(rtdistance<28||ltdistance<28){
    Stop();
    if(rdistance>28&&ldistance>28){
        if(rdistance>=ldistance){
          aright();
          delay(4000);
          Stop();}
          else if(rdistance<ldistance){
            aleft();
            delay(4000);
            Stop();}}
     else if(rdistance<28||ldistance<28){
         if(rdistance<28&&ldistance>28){
          aleft();
          delay(4000);
          Stop();}
          else if(rdistance>28&&ldistance<28){
            aright();
            delay(4000);
            Stop();}
            else if(rdistance<28&&ldistance<28){
              aright();
              delay(8000);
              Stop();}}       
        }
  
 if(lbdistance<20||rbdistance<20&&rtdistance>28&&ltdistance>28){
  Stop();
  delay(100);
  if(lbdistance<20&&rbdistance<20){
    abackward();
    delay(1300);
    Stop();
    pin1_activated();
    delay(1000);}
  else if(lbdistance<20&&rbdistance>20){
    aleft();
    delay(300);
    Stop();
    abackward();
    delay(1300);
    Stop();
    pin1_activated();
    delay(1000);}

   else if(lbdistance>20&&rbdistance<20){
    aright();
    delay(300);
    Stop();
    abackward();
    delay(1300);
    Stop();
   pin1_activated();
    delay(1000);}   
  }
  else {
    aforward();}
  
  
  



}

void Stop()
{
  analogWrite(pwm1, 0);
  analogWrite(pwm2, 0);
}

void left(){
  analogWrite(pwm1, 127);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW); 
  analogWrite(pwm2, 127);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW); 
  }
void aleft(){
  analogWrite(pwm1, 30);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW); 
  analogWrite(pwm2, 30);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW); 
  }
void right(){
  analogWrite(pwm1, 127);
  digitalWrite(back1, HIGH);
  analogWrite(pwm2, 127);
  digitalWrite(back2, HIGH); 
  }
  void aright(){
  analogWrite(pwm1, 30);
  digitalWrite(back1, HIGH);
  analogWrite(pwm2, 30);
  digitalWrite(back2, HIGH); 
  }

void backward(){
  analogWrite(pwm1, 127);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW); 
  analogWrite(pwm2, 127);
  digitalWrite(back2, HIGH); 
  }  
void abackward(){
  analogWrite(pwm1, 30);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW); 
  analogWrite(pwm2, 30);
  digitalWrite(back2, HIGH); 
  }  
  void forward(){
  analogWrite(pwm2, 127);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW); 
  analogWrite(pwm1, 127);
  digitalWrite(back1, HIGH);
  }
void aforward(){
  analogWrite(pwm2, 30);
  digitalWrite(back1, LOW);
  digitalWrite(back2, LOW); 
  analogWrite(pwm1, 30);
  digitalWrite(back1, HIGH);
  }
void pin1_activated(){

 delay(1000);
    
    for (pos = 150; pos >= 45; pos -= 1) {
    mainservo.write(pos);              
    delay(7);                    
  }
    delay(1000);
    for (pos1=30,pos2=150;pos1>=0,pos2<=180;pos1-=1,pos2+=1){
    myservo1.write(pos1);
    myservo2.write(pos2);
    delay(15);}
    
    delay(1000);
    
for (pos = 45; pos <= 105; pos += 1) { 
    // in steps of 1 degree
    mainservo.write(pos);          
    delay(10);                     
  }
    
    delay(3000);
    val1=digitalRead(outputpin1);
   
    val2=digitalRead(outputpin2);
    
    if(val1==LOW||val2==LOW){
      binservo.write(180);
      delay(2000);
      }
      if(val1==HIGH&&val2==HIGH){
        binservo.write(0);
        delay(2000);
        }
       delay(4000); 
    for (pos = 105; pos <= 150; pos += 1) {    
    mainservo.write(pos);              
    delay(10);                       
  }
  delay(1000);
   for(pos1=0,pos2=180;pos1<=30,pos2>=150;pos1+=1,pos2-=1){
    myservo2.write(pos2);
    myservo1.write(pos1);
    delay(15);}
    delay(1000);
   
   }
   
   void Blynk_Delay(int milli)
{
  int end_time = millis() + milli;
  while (millis() < end_time)
  {
if (Blynk.connected())
{
  Blynk.run();
}
yield();
  }
}
void loop()
{
  int bin1duration,bin1distance;
digitalWrite (bintrig1, HIGH);
   delayMicroseconds (1000);
   digitalWrite (bintrig1, LOW);
   bin1duration = pulseIn (binecho1, HIGH);
   bin1distance = (bin1duration/2) / 29.1;
   Blynk.virtualWrite(V8,bin1distance);
   if(bin1distance<20){
   Blynk.virtualWrite(V9,"METALLIC BIN FULL");
   delay(1000);}
   else if(bin1distance>20){
    Blynk.virtualWrite(V9," ");
   delay(1000);}
   int bin2duration,bin2distance;
digitalWrite (bintrig2, HIGH);
   delayMicroseconds (1000);
   digitalWrite (bintrig2, LOW);
   bin2duration = pulseIn (binecho2, HIGH);
   bin2distance = (bin2duration/2) / 29.1;
   Blynk.virtualWrite(V10,bin2distance);
   if(bin2distance<20){
   Blynk.virtualWrite(V9,"NON METALLIC BIN FULL");
   delay(1000);}
   else if(bin2distance>20){
    Blynk.virtualWrite(V9," ");
   delay(1000);}

   
 Blynk.run();
 
  val1=digitalRead(outputpin1);
   delay(10);
    val2=digitalRead(outputpin2);
    delay(10);
 timer.run();

There are tons n tons of delays used throughout the sketch. Should avoid them to make your sketch compatible with Blynk.

https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

@Aakash You appear to have created a second user account on the forum.
As a result, I’ve disabled your other one.
PLEASE DO NOT DO THIS AGAIN!

I’m closing this topic, as you need to continue the discussion in your original topic:

Pete.