Ping Multi without any connection

Full sketch needed.

Pete.

I’ve made thousands of attempts
It turns out that the code works fine when I put it alone, but the problem starts when you put all the loops together in one code.
I am wondering if there is a specific number of episodes allowed or something

Post your full sketch, else we can’t help you

#define BLYNK_TEMPLATE_ID "*****"
#define BLYNK_DEVICE_NAME "*****"
#define BLYNK_AUTH_TOKEN "*****"
#define BLYNK_PRINT Serial
#define ESP8266_BAUD 9600
#define RE 8
#define DE 7
 
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
#include <SoftwareSerial.h>



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

const int trigPin = 12;
const int echoPin = 13;
const int RELAY_PIN = A5;

long cm;
long duration;

int sensorPin = A0;
int soilMoistureValue = 0;
int percentage = 0;


const byte ph[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
byte values[11];
SoftwareSerial mod(2,3); // R0,D1

SoftwareSerial EspSerial(10, 11); // RX, TX

ESP8266 wifi(&EspSerial);


BlynkTimer timer;

WidgetRTC rtc;

void Soilph()
{
  byte val;
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);

  if (mod.write(ph, sizeof(ph)) == 8)
  {
    digitalWrite(DE, LOW);
    digitalWrite(RE, LOW);
    for (byte i = 0; i < 11; i++)
    {
      values[i] = mod.read();
        }
    Serial.println();
  }
  float soil_ph = float(values[4]) / 10;
  Serial.print("Soil Ph: ");
  Serial.println(soil_ph, 1);
   Blynk.virtualWrite(V2, soil_ph);
 Blynk.virtualWrite(V1, "7 is Neutral Soil ,6.5-0 is Acidic Soil ,7.5-14 is Alkaine Soil");
 
}
void Wlevel() 
{
  
  digitalWrite(trigPin, LOW);
  delayMicroseconds(4);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin,HIGH);
  cm = duration / 29 / 2;

  if (cm == 10)
  {
   

     Blynk.logEvent("tank");
     Serial.println("Tank is empty so pump is off");

    digitalWrite(A5,LOW);
  

  }
 
  Blynk.virtualWrite(V3, cm);
  Serial.print ("Water Level: ");
  Serial.print(cm);
}
BLYNK_WRITE(V0)
{

  if(param.asInt()==1){
    digitalWrite(RELAY_PIN, HIGH);
  }
  else{
    digitalWrite(RELAY_PIN, LOW);
  }
}

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0);  
  }

void SoilMoisture()
{

  soilMoistureValue = analogRead(sensorPin);
percentage = map(soilMoistureValue, 490, 1023, 100, 0);
if(percentage <= 60 )  
{
 
     Blynk.logEvent("on");

  digitalWrite(RELAY_PIN,HIGH);


}
else if (percentage >= 61 && percentage <= 79 )
{
  Serial.println("pump Unoutomatic");
 
  }
  else if (percentage >= 80 < 490 )
{
       Blynk.logEvent("off");
    Serial.println("pump off");

    digitalWrite(A5,LOW);
 
      
      
}
  else {
    Serial.println("pump Unoutomatic");
     
  }
 
  
}
void Clockdispla()
{

  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + "/" + month() + "/" + year();
  Serial.print ("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();
  Blynk.virtualWrite(V4, currentTime);
  Blynk.virtualWrite(V5, currentDate);
    Blynk.logEvent("remind");
 
 
  }
  

void setup() {
   Serial.begin(9600);
   mod.begin(4800);

  
  EspSerial.begin(ESP8266_BAUD);
 
  Blynk.begin(auth, wifi, ssid, pass);
   rtc.begin();
  
  setSyncInterval(10 * 60);

    pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);
   pinMode(RELAY_PIN, OUTPUT);
  
    // Waterlevel
  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
  timer.setInterval(20000L, Soilph);
  timer.setInterval(10L, Wlevel);
  timer.setInterval(10000L, Clockdispla);
  timer.setInterval(1000L, SoilMoisture);
}
  void loop()
{
 Blynk.run();      
  timer.run();        
}

You are calling the wlevel() function 100 times per second, increase the time to 1000L for example.

also, I’d suggest using a flags to limit event logging, otherwise you will exceed the daily limit quickly ( the daily limit is 100 events per device per day ).

2 Likes

This test for the water level isn’t very sensible. It requires the water level to be EXACTLY 10cm, not 10.00001 or 9.9999999 but EXACTLY 10.
In reality you could easily miss taking a reading which returns exactly 10, so it’s better to make this <=10

As @John93 said, you also need to include a flag variable which sends just one event/alert for each low water level situation, and to reset this flag when the water level is significantly greater than 10 (so that you don’t get false resets of the water level status when the readings are fluctuating around the 10cm level).

More info here…

Also, this…

Is the legacy way of getting the time from the Blynk server. You should read the official documentation on the correct IoT method.

Pete.

1 Like

Where can I read it ?

Click the “Docs” link at the top of this page, and type “RTC” into the search box.

Pete.

1 Like

I corrected everything and the problem is still the same I don’t know why this is happening to me :disappointed_relieved:

#define BLYNK_TEMPLATE_ID "***"
#define BLYNK_DEVICE_NAME "***"
#define BLYNK_AUTH_TOKEN "***"
#define BLYNK_PRINT Serial
#define ESP8266_BAUD 9600
#define RE 8
#define DE 7
 
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
#include <SoftwareSerial.h>



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

const int trigPin = 12;
const int echoPin = 13;
const int RELAY_PIN = A5;

long cm;
long duration;

int sensorPin = A0;
int soilMoistureValue = 0;
int percentage = 0;


const byte ph[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
byte values[11];
SoftwareSerial mod(2,3); // R0,D1

SoftwareSerial EspSerial(10, 11); // RX, TX

ESP8266 wifi(&EspSerial);


BlynkTimer timer;


BLYNK_WRITE(V0)
{

  if(param.asInt()==1){
    digitalWrite(RELAY_PIN, HIGH);
  }
  else{
    digitalWrite(RELAY_PIN, LOW);
  }
}

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0);  
  }

void Soilph()
{
  byte val;
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);

  if (mod.write(ph, sizeof(ph)) == 8)
  {
    digitalWrite(DE, LOW);
    digitalWrite(RE, LOW);
    for (byte i = 0; i < 11; i++)
    {
      values[i] = mod.read();
        }
    Serial.println();
  }
  float soil_ph = float(values[4]) / 10;
  Serial.print("Soil Ph: ");
  Serial.println(soil_ph, 1);
   Blynk.virtualWrite(V2, soil_ph);
 Blynk.virtualWrite(V1, "7 is Neutral Soil ,6.5-0 is Acidic Soil ,7.5-14 is Alkaine Soil");
 
}
void Wlevel() 
{
  
  digitalWrite(trigPin, LOW);
  delayMicroseconds(4);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin,HIGH);
  cm = duration / 29 / 2;

  if (cm >= 10)
  {
   

     Blynk.logEvent("tank");
     Serial.println("Tank is empty so pump is off");

    digitalWrite(A5,LOW);
  

  }
 
  Blynk.virtualWrite(V3, cm);
  Serial.print ("Water Level: ");
  Serial.print(cm);
}

void SoilMoisture()
{

  soilMoistureValue = analogRead(sensorPin);
percentage = map(soilMoistureValue, 490, 1023, 100, 0);
if(percentage <= 60 )  
{
 
     Blynk.logEvent("on");

  digitalWrite(RELAY_PIN,HIGH);


}
else if (percentage >= 61 && percentage <= 79 )
{
  Serial.println("pump Unoutomatic");
 
  }
  else if (percentage >= 80 < 490 )
{
       Blynk.logEvent("off");
    Serial.println("pump off");

    digitalWrite(A5,LOW);
 
      
      
}
  else {
    Serial.println("pump Unoutomatic");
     
  }
 
  
}
void Clockdispla()
{

  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + "/" + month() + "/" + year();
  Serial.print ("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();
  Blynk.virtualWrite(V4, currentTime);
  Blynk.virtualWrite(V5, currentDate);
    Blynk.logEvent("remind");
}
 


void setup() {
   Serial.begin(9600);
   mod.begin(4800);
  EspSerial.begin(ESP8266_BAUD);
 
  Blynk.begin(auth, wifi, ssid, pass);
   Blynk.sendInternal("rtc", "sync");

     pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);
   pinMode(RELAY_PIN, OUTPUT);
  
    // Waterlevel
  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
  timer.setInterval(20000L, Soilph);
  timer.setInterval(1000L, Wlevel);
  timer.setInterval(10000L, Clockdispla);
  timer.setInterval(1000L, SoilMoisture);
}
  void loop()
{
 Blynk.run();      
  timer.run();        
}

In that case, think you’ve posted the wrong version of your sketch.

Pete.

Of course it is not

I read the article about RTC but I still don’t understand
In which loop should I put

  Blynk.sendInternal("rtc", "sync");

And do I need to include any libraries?

Even though you weren’t talking to me but I have the same problem
I’m so upset
I need to fix it today or tomorrow
It’s been a while since I’ve been trying to fix this problem
I hope you can help me :disappointed_relieved:

#define BLYNK_TEMPLATE_ID "***"
#define BLYNK_DEVICE_NAME "***"
#define BLYNK_AUTH_TOKEN "***"
#define BLYNK_PRINT Serial
#define ESP8266_BAUD 9600
#define RE 8
#define DE 7
 
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
#include <SoftwareSerial.h>



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

const int trigPin = 12;
const int echoPin = 13;
const int RELAY_PIN = A5;

long cm;
long duration;

int sensorPin = A0;
int soilMoistureValue = 0;
int percentage = 0;


const byte ph[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
byte values[11];
SoftwareSerial mod(2,3); // R0,D1

SoftwareSerial EspSerial(10, 11); // RX, TX

ESP8266 wifi(&EspSerial);


BlynkTimer timer;


BLYNK_WRITE(V0)
{

  if(param.asInt()==1){
    digitalWrite(RELAY_PIN, HIGH);
  }
  else{
    digitalWrite(RELAY_PIN, LOW);
  }
}

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0);  
  }

void Soilph()
{
  byte val;
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);

  if (mod.write(ph, sizeof(ph)) == 8)
  {
    digitalWrite(DE, LOW);
    digitalWrite(RE, LOW);
    for (byte i = 0; i < 11; i++)
    {
      values[i] = mod.read();
        }
    Serial.println();
  }
  float soil_ph = float(values[4]) / 10;
  Serial.print("Soil Ph: ");
  Serial.println(soil_ph, 1);
   Blynk.virtualWrite(V2, soil_ph);
 Blynk.virtualWrite(V1, "7 is Neutral Soil ,6.5-0 is Acidic Soil ,7.5-14 is Alkaine Soil");
 
}
void Wlevel() 
{
  
  digitalWrite(trigPin, LOW);
  delayMicroseconds(4);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin,HIGH);
  cm = duration / 29 / 2;

  if (cm >= 10)
  {
   

     Blynk.logEvent("tank");
     Serial.println("Tank is empty so pump is off");

    digitalWrite(A5,LOW);
  

  }
 
  Blynk.virtualWrite(V3, cm);
  Serial.print ("Water Level: ");
  Serial.print(cm);
}

void SoilMoisture()
{

  soilMoistureValue = analogRead(sensorPin);
percentage = map(soilMoistureValue, 490, 1023, 100, 0);
if(percentage <= 60 )  
{
 
     Blynk.logEvent("on");

  digitalWrite(RELAY_PIN,HIGH);


}
else if (percentage >= 61 && percentage <= 79 )
{
  Serial.println("pump Unoutomatic");
 
  }
  else if (percentage >= 80 < 490 )
{
       Blynk.logEvent("off");
    Serial.println("pump off");

    digitalWrite(A5,LOW);
 
      
      
}
  else {
    Serial.println("pump Unoutomatic");
     
  }
 
  
}
void Clockdispla()
{

  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + "/" + month() + "/" + year();
  Serial.print ("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();
  Blynk.virtualWrite(V4, currentTime);
  Blynk.virtualWrite(V5, currentDate);
    Blynk.logEvent("remind");
}
 


void setup() {
   Serial.begin(9600);
   mod.begin(4800);
  EspSerial.begin(ESP8266_BAUD);
 
  Blynk.begin(auth, wifi, ssid, pass);
   Blynk.sendInternal("rtc", "sync");

     pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);
   pinMode(RELAY_PIN, OUTPUT);
  
    // Waterlevel
  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
  timer.setInterval(20000L, Soilph);
  timer.setInterval(1000L, Wlevel);
  timer.setInterval(10000L, Clockdispla);
  timer.setInterval(1000L, SoilMoisture);
}
  void loop()
{
 Blynk.run();      
  timer.run();        
}

@shmukh I’ve moved your latest post into this topic. Please don’t spam the forum by posting the same thing in multiple places, especially when the topic is about a Legacy issue not a Blynk IoT issue.

You’d be far better spending your time re-reading what has already been posted in this topic, as you haven’t taken on board most of the guidance that you’ve been given.
You’re not likely to get any further assistance until you’ve done that.

Pete.

Thank you
But I’m looking for related topics
I also took all instructions into consideration
If there is an error, please guide me
Thanks for everything

You haven’t added flag variables to the logEvent commands to prevent multiple event logging and you haven’t removed the legacy RTC code.

If you’d bothered to re-read the posts in this topic and compare the advice you’ve been given to the changes you’ve made then you would have realised this - but clearly you haven’t taken that piece of advice onboard either.

Maybe that’s your problem. More time spent looking at the advice given in this topic would be a better approach.

Pete.

Can you take a look at this please ?
I’ve never used this RTC and flag variables before so I’m not sure if this is true or not

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "***"
#define BLYNK_DEVICE_NAME "***"
#define BLYNK_AUTH_TOKEN "***"

#define ESP8266_BAUD 9600
#define RE 8
#define DE 7
 
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
#include <SoftwareSerial.h>


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


const int trigPin = 12;
const int echoPin = 13;
const int RELAY_PIN = A5;

long cm;
long duration;

int sensorPin = A0;
int soilMoistureValue = 0;
int percentage = 0;

bool alert_sent1 = false;
bool alert_sent2 = false;
bool alert_sent3 = false; 

const byte ph[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
byte values[11];
SoftwareSerial mod(2,3); // R0,D1

SoftwareSerial EspSerial(10, 11); // RX, TX

ESP8266 wifi(&EspSerial);


BlynkTimer timer;


BLYNK_WRITE(V0)
{

  if(param.asInt()==1){
    digitalWrite(RELAY_PIN, HIGH);
  }
  else{
    digitalWrite(RELAY_PIN, LOW);
  }
}

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0); 
  Blynk.sendInternal("rtc", "sync"); 
  }

void Soilph()
{
  byte val;
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);

  if (mod.write(ph, sizeof(ph)) == 8)
  {
    digitalWrite(DE, LOW);
    digitalWrite(RE, LOW);
    for (byte i = 0; i < 11; i++)
    {
      values[i] = mod.read();
        }
    Serial.println();
  }
  float soil_ph = float(values[4]) / 10;
  Serial.print("Soil Ph: ");
  Serial.println(soil_ph, 1);
   Blynk.virtualWrite(V2, soil_ph);
 Blynk.virtualWrite(V1, "7 is Neutral Soil ,6.5-0 is Acidic Soil ,7.5-14 is Alkaine Soil");
 
}
void Wlevel() 
{
  
  digitalWrite(trigPin, LOW);
  delayMicroseconds(4);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin,HIGH);
  cm = duration / 29 / 2;

   if (cm >= 10 && alert_sent1 == false )
  {
   

     Blynk.logEvent("tank");
     alert_sent1 = true;
     Serial.println("Tank is empty so pump is off");

    digitalWrite(A5,LOW);
  }
    else if(cm <= 10 && alert_sent1 == true) 
  {
  alert_sent1 = false;
  }
 
  Blynk.virtualWrite(V3, cm);
  Serial.print ("Water Level: ");
  Serial.print(cm);
}

void SoilMoisture()
{

  soilMoistureValue = analogRead(sensorPin);
percentage = map(soilMoistureValue, 490, 1023, 100, 0);
if(percentage <= 60 && alert_sent2 == false )  
{
 
     Blynk.logEvent("on");
     alert_sent2 = true;
    digitalWrite(RELAY_PIN,HIGH);
}
else if(percentage >= 61 && percentage <= 79 && alert_sent2 == true) 
  {
  alert_sent2 = false;
  }

 else if (percentage >= 80  && percentage && alert_sent3 == false )
{

     Blynk.logEvent("off");
     alert_sent3 = true;
    Serial.println("pump off");
    digitalWrite(A5,LOW);
}
    else if(percentage >= 61 && percentage <= 79 && alert_sent3 == true) 
  {
  alert_sent3 = false;
  }
}       
void Clockdispla()
{

  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + "/" + month() + "/" + year();
  Serial.print ("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();
  Blynk.virtualWrite(V4, currentTime);
  Blynk.virtualWrite(V5, currentDate);
}
 


void setup() {
   Serial.begin(9600);
   mod.begin(4800);
  EspSerial.begin(ESP8266_BAUD);
 
  Blynk.begin(auth, wifi, ssid, pass);

     pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);
   pinMode(RELAY_PIN, OUTPUT);
  
    // Waterlevel
  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
  timer.setInterval(20000L, Soilph);
  timer.setInterval(1000L, Wlevel);
  timer.setInterval(10000L, Clockdispla);
  timer.setInterval(1000L, SoilMoisture);
}
  void loop()
{
 Blynk.run();      
  timer.run();        
}

It’s unlikely that this will work. Why have you chosen to do it this way rather than placing the RTC command here…

as the example in the official documentation suggests?

And why do you have this…

Despite me saying…

Pete.

1 Like

Well I corrected it
What about the flag variables please
This is the latest version of the code
I hope you work
I’m so desperate
And thank you too

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "***"
#define BLYNK_DEVICE_NAME "***"
#define BLYNK_AUTH_TOKEN "***"
#define ESP8266_BAUD 9600
#define RE 8
#define DE 7
 
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <SoftwareSerial.h>


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



const int trigPin = 12;
const int echoPin = 13;
const int RELAY_PIN = A5;

long cm;
long duration;

int sensorPin = A0;
int soilMoistureValue = 0;
int percentage = 0;

bool alert_sent1 = false;
bool alert_sent2 = false;
bool alert_sent3 = false; 

const byte ph[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
byte values[11];
SoftwareSerial mod(2,3); // R0,D1

SoftwareSerial EspSerial(10, 11); // RX, TX

ESP8266 wifi(&EspSerial);


BlynkTimer timer;


BLYNK_WRITE(V0)
{

  if(param.asInt()==1){
    digitalWrite(RELAY_PIN, HIGH);
  }
  else{
    digitalWrite(RELAY_PIN, LOW);
  }
}

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0); 
  Blynk.sendInternal("rtc", "sync"); 
  }

void Soilph()
{
  byte val;
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);

  if (mod.write(ph, sizeof(ph)) == 8)
  {
    digitalWrite(DE, LOW);
    digitalWrite(RE, LOW);
    for (byte i = 0; i < 11; i++)
    {
      values[i] = mod.read();
        }
    Serial.println();
  }
  float soil_ph = float(values[4]) / 10;
  Serial.print("Soil Ph: ");
  Serial.println(soil_ph, 1);
   Blynk.virtualWrite(V2, soil_ph);
 Blynk.virtualWrite(V1, "7 is Neutral Soil ,6.5-0 is Acidic Soil ,7.5-14 is Alkaine Soil");
 
}
void Wlevel() 
{
  
  digitalWrite(trigPin, LOW);
  delayMicroseconds(4);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin,HIGH);
  cm = duration / 29 / 2;

   if (cm >= 10 && alert_sent1 == false )
  {
   

     Blynk.logEvent("tank");
     alert_sent1 = true;
     Serial.println("Tank is empty so pump is off");

    digitalWrite(A5,LOW);
  }
    else if(cm <= 10 && alert_sent1 == true) 
  {
  alert_sent1 = false;
  }
 
  Blynk.virtualWrite(V3, cm);
  Serial.print ("Water Level: ");
  Serial.print(cm);
}

void SoilMoisture()
{

  soilMoistureValue = analogRead(sensorPin);
percentage = map(soilMoistureValue, 490, 1023, 100, 0);
if(percentage <= 60 && alert_sent2 == false )  
{
      Blynk.logEvent("on");
     alert_sent2 = true;
    digitalWrite(RELAY_PIN,HIGH);
}
else if(percentage >= 61 && percentage <= 79 && alert_sent2 == true) 
  {
  alert_sent2 = false;
  }

 else if (percentage >= 80  && percentage <= 490 && alert_sent3 == false )
{

     Blynk.logEvent("off");
     alert_sent3 = true;
    Serial.println("pump off");
    digitalWrite(A5,LOW);
}
    else if(percentage >= 61 && percentage <= 79 && alert_sent3 == true) 
  {
  alert_sent3 = false;
  }
  else {
    Serial.println("pump Unoutomatic");
  }
}       
void Clockdispla()
{

  // You can call hour(), minute(), ... at any time
  // Please see Time library examples for details
  String currentTime = String(hour()) + ":" + minute() + ":" + second();
  String currentDate = String(day()) + "/" + month() + "/" + year();
  Serial.print ("Current time: ");
  Serial.print(currentTime);
  Serial.print(" ");
  Serial.print(currentDate);
  Serial.println();
  Blynk.virtualWrite(V4, currentTime);
  Blynk.virtualWrite(V5, currentDate);
}
 


void setup() {
   Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
 
  Blynk.begin(auth, wifi, ssid, pass);
  mod.begin(4800);
  pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);
   pinMode(RELAY_PIN, OUTPUT);
  
    // Waterlevel
  
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
  timer.setInterval(20000L, Soilph);
  timer.setInterval(1000L, Wlevel);
  timer.setInterval(10000L, Clockdispla);
  timer.setInterval(1000L, SoilMoisture);
}
  void loop()
{
 Blynk.run();      
  timer.run();        
}

It’s difficult to follow the code, because of the way that your if statements aren’t indented properly, but it looks okay.

Does it work?

If not, then you need to focus on what you’re seeing in your serial monitor, and how you are powering your board and the peripherals.

Pete.