ESP32 not connecting to the WIFI network

//Include the library files
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#define LED1 2
#define LED2 4
#define LED3 5
#define LED4 18
#define trig 12
#define echo 13
#define relay 14

//Enter your tank max value(CM)
int MaxLevel = 13;

int Level1 = (MaxLevel * 75) / 100;
int Level2 = (MaxLevel * 65) / 100;
int Level3 = (MaxLevel * 55) / 100;
int Level4 = (MaxLevel * 35) / 100;

//Initialize the LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2);

BlynkTimer timer;

// Enter your Auth token
char auth[] = "**********************";

//Enter your WIFI SSID and password
char ssid[] = "**********";
char pass[] = "**********";

void setup() {
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass,"blynk.cloud", 80);
  lcd.init();
  lcd.backlight();
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);
  
  lcd.setCursor(0, 0);
  lcd.print("System");
  lcd.setCursor(4, 1);
  lcd.print("Loading..");
  delay(4000);
  lcd.clear();
}

//Get the ultrasonic sensor values
void ultrasonic() {
  digitalWrite(trig, LOW);
  delayMicroseconds(4);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  long t = pulseIn(echo, HIGH);
  int distance = t / 29 / 2;

  Serial.println(distance);

  int blynkDistance = (distance - MaxLevel) * -1;
  if (distance <= MaxLevel) {
    Blynk.virtualWrite(V0, blynkDistance);
  } else {
    Blynk.virtualWrite(V0, 0);
  }
  lcd.setCursor(0, 0);
  lcd.print("WLevel:");

  if (Level1 <= distance) {
    lcd.setCursor(8, 0);
    lcd.print("Very Low");
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, LOW);
    digitalWrite(LED4, LOW);
  } else if (Level2 <= distance && Level1 > distance) {
    lcd.setCursor(8, 0);
    lcd.print("Low");
    lcd.print("      ");
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
    digitalWrite(LED3, LOW);
    digitalWrite(LED4, LOW);
  } else if (Level3 <= distance && Level2 > distance) {
    lcd.setCursor(8, 0);
    lcd.print("Medium");
    lcd.print("      ");
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
    digitalWrite(LED3, HIGH);
    digitalWrite(LED4, LOW);
  } else if (Level4 <= distance && Level3 > distance) {
    lcd.setCursor(8, 0);
    lcd.print("Full");
    lcd.print("      ");
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
    digitalWrite(LED3, HIGH);
    digitalWrite(LED4, HIGH);
  }
}

//Get the button value
BLYNK_WRITE(V1) {
  bool Relay = param.asInt();
  if (Relay == 1) {
    digitalWrite(relay, LOW);
    lcd.setCursor(0, 1);
    lcd.print("Motor is ON ");
  } else {
    digitalWrite(relay, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Motor is OFF");
  }
}

void loop() {
  ultrasonic();
  Blynk.run();//Run the Blynk library
}

First of all, you need to remove this line of code from your void loop, because if you do get your device connected it will flood the Blynk server…

You need to properly use the BlynkTimer object that you’ve defined, by adding timer.run(); to your void loop and defining a BlynkTimer interval timer that calls your ultrasonic function at a sensible interval.

On to your lack of connection.
You’re missing two lines of firmware configuration from the top of your code.

GPIO12 is a poor pin choice as it can prevent your board from booting if it’s being pulled HIGH…

Read this for more info…

How are you powering your LCD? The backlight draws quite a bit of current, and if you’re powering it from the 3.3v pin of your ESP32 you could be creating a situation where the board doesn’t have enough power to allow the WiFi module to function correctly.

It’s always a good idea to have #define BLYNK_PRINT Serial in your sketch, neat tye top, as you’ll get much more info in your serial monitor from the Blynk library about what’s happening during the connection process.

Finally, are you using a 2.4GHz WiFi network? The ESP32 doesn’t support 5GHz WiFi.

Pete.

[Unformatted code removed by moderator]

This code is not letting me connet to the esp32 ,it tells that no serial data received.
i almost tried all the possible ways to solve it,i mean like holding the boot button while loading and all other stuff.
yesterday night it got connected once and the device came online but AFTER 30-40 SECONDS IT WENT BACK OFFLINE AND that is when this " no serial data received." error started to popup.
its not letting me do anything else.
so please do help me out as it is my college project.

@Pavan1 Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

First , try to connect your ESP32 to your home WiFi network