unsigned long lastupdate = 0;
bool relay = false;

void setup() {
  Serial.begin(115200);
  pinMode(18, OUTPUT);
  pinMode(26, INPUT);
  pinMode(27, INPUT);
}

void loop() {
  int ph1_v = analogRead(26);
  int ph2_v = analogRead(27);

  int ph1 = map(ph1_v, 0, 4095, 0, 14);
  int ph2 = map(ph2_v, 0, 4095, 0, 14);

  Serial.println(ph1);
  // Serial.println(ph2);

  if (ph1 == ph2) {
    digitalWrite(18, HIGH);
  } else {
    digitalWrite(18, LOW);
  }

  if (ph1 < 6.5 || ph1 > 9) {
    if (relay == false) {
      relay = true;
      Serial.println("Valve On");
    }
  }
  if(relay == true){
    if (millis() - lastupdate > 10000) {
        relay = false;
        Serial.println("Valve Off");
        lastupdate = millis();
      }
  }

  delay(300);
}
esp:0
esp:2
esp:4
esp:5
esp:12
esp:13
esp:14
esp:15
esp:16
esp:17
esp:18
esp:19
esp:21
esp:22
esp:23
esp:25
esp:26
esp:27
esp:32
esp:33
esp:34
esp:35
esp:3V3
esp:EN
esp:VP
esp:VN
esp:GND.1
esp:D2
esp:D3
esp:CMD
esp:5V
esp:GND.2
esp:TX
esp:RX
esp:GND.3
esp:D1
esp:D0
esp:CLK
led1:A
led1:C
pot1:GND
pot1:SIG
pot1:VCC
pot2:GND
pot2:SIG
pot2:VCC