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

Monitoring and control system for hydroponic garden in greenhouse using IoT technology

I have timed my water pump program. when pin v5 is on the system will pump for 10 minutes. but I assume that if the system is out of power, it has pumped for 5 minutes and when it has power, it will pump for the remaining 5 minutes, what should I do?
thank you
this is my program.

#define BLYNK_TEMPLATE_ID "TMPLCJizVSSV"
#define BLYNK_DEVICE_NAME "DO AN"
#define BLYNK_FIRMWARE_VERSION        "0.1.4"
#define BLYNK_PRINT Serial 

#include <Arduino.h>
#include "BlynkEdgent.h"
#include <WiFi.h>
#include <DHT.h>
//#include <BlynkSimpleEsp32.h>

#include <SPI.h>
#include <Ethernet.h>
#include <TimeLib.h>
#include <WidgetRTC.h>
#include "Adafruit_Sensor.h"
#include "Wire.h"
#include "BH1750.h"  
#include <EEPROM.h>


#define DHTPIN 14      // Chân DATA nối với chân IO14
#define DHTTYPE DHT22   // DHT 11
#define PS 19
#define Quat 18
#define Bom 5
#define TIME_PUMP_ON 15


//TIMER
#define READ_LUX_TM  10L //Đọc cảm biến ánh sáng
#define READ_AIR_DATA_TM  2L  //Đọc DHT
#define DISPLAY_DATA_TM   10L //Gửi dữ liệu lên terminal 
#define SEND_UP_DATA_TM   10L
//blynk&wifi
//char auth[] = "Qttg34ssA83i8Stt790skcqPl2RVvz2o";
//char ssid[] = "ESP";
//char password[] = "06092000";

BH1750 lightMeter;
DHT dht(DHTPIN, DHTTYPE); // Khởi tạo cảm biến


float t=0;
float h=0;
float lux=0;

// Biến lưu trạng thái bơm
boolean PSStatus = 0;
boolean QUATStatus = 0;
boolean BOMStatus = 0;


String currentDate;
String currentTime;
int count = 0;


SimpleTimer timer;

WidgetRTC rtc;
WidgetLED led1(V0);       // đèn báo kết nối 
WidgetLED SP(V2);       // Đèn trạng thái phun sương
WidgetLED FAN(V3);       // Đèn trạng thái quạt
WidgetLED BUMP(V4);       // Đèn trạng thái bơm




void readsensor();
void printData();
void startTimers();
void sendUptime();
void clockDisplay();
void turnPumpOn();


void setup() {
  // Khởi tạo cổng serial baud 115200
  Serial.begin(115200);
   EEPROM.begin(512);
   count = EEPROM.read(0);
  pinMode(5, OUTPUT);
  pinMode(18, OUTPUT);
  pinMode(19, OUTPUT);
  //Blynk.begin(auth, ssid, password);
  BlynkEdgent.begin();
  setSyncInterval(10 * 60);
  WiFi.mode(WIFI_STA);
  Serial.println("hello!");
  delay(2000);
  // Bắt đầu đọc dữ liệu
  Wire.begin();
  dht.begin();
  lightMeter.begin();
  readsensor();
  startTimers();
  sendUptime();
  clockDisplay();
  turnPumpOn();
  SP.off();
  FAN.off();
  BUMP.off();
}

 void loop() {
   timer.run();
   //Blynk.run();
   BlynkEdgent.run();
   if(currentTime[hour()] == '9')
   { count =0;
  
  }
 }
  BLYNK_CONNECTED() {
  // Synchronize time on connection
  Blynk.syncVirtual(V5); 
  Blynk.syncVirtual(V6); 
  Blynk.syncVirtual(V101); 
  Blynk.syncVirtual(V100); 
  rtc.begin();

}
   
   BLYNK_WRITE(5)              // khai báo phím ảo trên app blynk
{
  int i = param.asInt();
  if (i == 1)
  {   
    count++;
    EEPROM.write(0, count);
    EEPROM.commit();
    Serial.println("State saved in flash memory");
    Blynk.virtualWrite(V101,count);
    if (count>=3){
    Blynk. logEvent("canhbao","Bạn đang tưới cây quá 2 lần");
    }
     SP.on();
     digitalWrite(PS, HIGH);
    timer.setTimeout( TIME_PUMP_ON * 1000, turnPumpOn);
 
 
    
   }
  else {
    SP.off();
    digitalWrite(PS, LOW);
    
  }
}

    BLYNK_WRITE(6) // Điều khiển đèn
{
  int i = param.asInt();
  if (i == 1)
  { 
    FAN.on();
    digitalWrite(Quat, HIGH);
    Blynk.virtualWrite(V8,"ON FAN");
  }
  else {
    FAN.off();
    digitalWrite(Quat, LOW);
    Blynk.virtualWrite(V8,"OFF FAN");
    }
}
BLYNK_WRITE(V100){
  int i = param.asInt();
    if (i == 1){
      
      count=0;
      EEPROM.write(0, count);
      EEPROM.commit();
      Serial.println("State saved in flash memory");
      Blynk.virtualWrite(V101,count);
      Blynk.virtualWrite(V8,"RESET DONE");
    }
    
     
  }
   

 void readsensor(){
     h = dht.readHumidity(); // Đọc giá trị nhiệt độ C (mặc định)
  
     t = dht.readTemperature(); // Đọc giá trị nhiệt độ F(isFahrenheit = true)

     lux = lightMeter.readLightLevel(); // đọc giá trị ánh sáng
  }
  void printData(){
     // IN thông tin ra màn hình
    
   Serial.print("Do am: ");
   Serial.print(h);
   Serial.print(" %\t");
   Serial.print("Nhiet do: ");
   Serial.print(t);
   Serial.print(" *C ");
   Serial.print("Ánh sáng: ");
   Serial.print(lux);
   Serial.println("lx");
   
  }
  void clockDisplay()
  { currentTime = String(hour()) + ":" + minute() + ":" + second();
    currentDate = String(day()) + " " + month() + " " + year();
    Serial.print("Current time: ");
    Serial.print(currentTime);
    Serial.print(" ");
    Serial.print(currentDate);
    Serial.println();
  
  }
  void startTimers()
{
 
  timer.setInterval(READ_AIR_DATA_TM * 1000, readsensor);
  timer.setInterval(READ_LUX_TM * 1000, readsensor);
  timer.setInterval(DISPLAY_DATA_TM*1000, printData);
  timer.setInterval(SEND_UP_DATA_TM * 1000, sendUptime);
  timer.setInterval(10000L, clockDisplay);
}
  void sendUptime()
{
  Blynk.virtualWrite(10, t); //Nhiệt độ với pin V10
  Blynk.virtualWrite(11, h); // Độ ẩm với pin V11
  Blynk.virtualWrite(12, lux); // ánh sáng với V12
  Blynk.virtualWrite(V9,"INDIVIDUAL PROJECT");
  if (led1.getValue()) {
    led1.off();
  } else {
    led1.on();
  }
  
}
void turnPumpOn()
{     
      digitalWrite(PS, LOW);
      SP.off();
      Blynk.virtualWrite(V5, LOW);
      Blynk. logEvent("canhbao","Bạn đã tưới cây trong vòng 10 phút");
}

@dell2000 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:
```

Pete.

done help mee

But not done correctly.
I gave you triple backticks to copy/paste, but you chose to use different characters instead.

Please fix the formatting correctly.

Pete.

oke thks you