EC and PH sensing issue

OK so I’m setting up a system that is able to distinguish between clean and dirty water, and would be able to open and close either the clean or dirty solenoid valve, there is also a third solenoid at the very start of the system that regulates the flow of water toward the sensors. So my problem is this, my if else statement in my loop does not seem to be working. And I need some way of adding in a delay between the EC and pH sensors, but everything I have tried has failed to work. I have attached the code and would really love your input.

//Libraries
#include <DHT.h>
#include <U8glib.h>
#include <stdio.h>
#include <OneWire.h>
#include <Wire.h>
#include <Arduino.h>
#include <Adafruit_Sensor.h>

//PINS
#define DHT_PIN        5          // DHT pin
#define DHTTYPE        DHT22      // DHT 22  (AM2302)
#define PH_PIN         2          //pH meter pin
#define CO2_PIN        3          //ORP meter pin
#define EC_PIN         1          //EC meter pin
#define DS18B20_PIN    6          //EC solution temperature pin
int solenoidPin = 1;
int Cleanvalve = 2;
int Sewegevalve = 3;

// AVERAGING VALUES
#define MEDIAN_SAMPLE 8
#define MEASUREMENTS_TAKEN 100

// EC - solution temperature variables
#define StartConvert 0
#define ReadTemperature 1

// EC values // CHANGE THESE PARAMETERS FOR EC PROBE CALIBRATION
#define EC_PARAM_A 0.00754256

//pH values // CHANGE THESE PARAMETERS FOR PH PROBE CALIBRATION
#define PH_PARAM_A 2.3622
#define PH_PARAM_B 1.16535

#define XCOL_SET 55
#define XCOL_SET2 65
#define XCOL_SET_UNITS 85

//--------------------------

DHT dht(DHT_PIN, DHTTYPE);
U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);
unsigned long int avgValue;
float b, phValue;
int buf[MEASUREMENTS_TAKEN], tmp;
int chk;
float hum;
float temp;
unsigned int AnalogAverage = 0, averageVoltage = 0;
float solution_temp, ECcurrent;
unsigned int levelAverage;
float co2;
OneWire ds(DS18B20_PIN);

//--------------------------

void draw() {
  u8g.setFont(u8g_font_04b_03);

  u8g.drawStr( 0, 11, "Temp:");
  u8g.setPrintPos(XCOL_SET, 11);
  u8g.print(temp);
  u8g.drawStr( XCOL_SET_UNITS, 11, "C" );

  u8g.drawStr(0, 21, "Humidity:");
  u8g.setPrintPos(XCOL_SET, 21);
  u8g.print(hum);
  u8g.drawStr( XCOL_SET_UNITS, 21, "%" );

  u8g.drawStr(0, 31, "pH:");
  u8g.setPrintPos(XCOL_SET, 31);
  u8g.print(phValue);

  u8g.drawStr(0, 41, "EC:");
  u8g.setPrintPos(XCOL_SET, 41);
  u8g.print(ECcurrent);
  u8g.drawStr( XCOL_SET_UNITS, 41, "mS/cm" );

  u8g.drawStr(0, 51, "Sol.Temp:");
  u8g.setPrintPos(XCOL_SET, 51);
  u8g.print(solution_temp);
  u8g.drawStr( XCOL_SET_UNITS, 51, "C" );

  u8g.drawStr(0, 61, "CO2:");
  u8g.setPrintPos(XCOL_SET, 61);
  u8g.print(co2);
  u8g.drawStr( XCOL_SET_UNITS, 61, "ppm" );

}

float TempProcess(bool ch)
{
  static byte data[12];
  static byte addr[8];
  static float TemperatureSum;
  if (!ch) {
    if ( !ds.search(addr)) {
      ds.reset_search();
      return 0;
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
      return 0;
    }
    if ( addr[0] != 0x10 && addr[0] != 0x28) {
      return 0;
    }
    ds.reset();
    ds.select(addr);
    ds.write(0x44, 1);
  }
  else {
    byte present = ds.reset();
    ds.select(addr);
    ds.write(0xBE);
    for (int i = 0; i < 9; i++) {
      data[i] = ds.read();
    }
    ds.reset_search();
    byte MSB = data[1];
    byte LSB = data[0];
    float tempRead = ((MSB << 8) | LSB);
    TemperatureSum = tempRead / 16;
  }
  return TemperatureSum;
}

void calculateAnalogAverage(int pin) {
  AnalogAverage = 0;

  for (int i = 0; i < MEASUREMENTS_TAKEN; i++)
  {
    buf[i] = analogRead(pin);
    delay(10);
  }
  for (int i = 0; i < MEASUREMENTS_TAKEN - 1; i++)
  {
    for (int j = i + 1; j < MEASUREMENTS_TAKEN; j++)
    {
      if (buf[i] > buf[j])
      {
        tmp = buf[i];
        buf[i] = buf[j];
        buf[j] = tmp;
      }
    }
  }

  avgValue = 0;
  for (int i = (MEASUREMENTS_TAKEN / 2) - (MEDIAN_SAMPLE / 2); i < (MEASUREMENTS_TAKEN / 2) + (MEDIAN_SAMPLE / 2); i++) {
    avgValue += buf[i];
  }

  AnalogAverage = avgValue / MEDIAN_SAMPLE ;
}

void read_Sensor() {

  calculateAnalogAverage(EC_PIN);

  solution_temp = TempProcess(ReadTemperature);
  TempProcess(StartConvert);

  averageVoltage = AnalogAverage * (float)5000 / 1024;
  float TempCoefficient = 1.0 + 0.0185 * (solution_temp - 25.0);
  float CoefficientVolatge = (float)averageVoltage * TempCoefficient;

  ECcurrent = EC_PARAM_A * CoefficientVolatge;

  delay(1500);

  calculateAnalogAverage(PH_PIN);
  phValue = (float)AnalogAverage * 5.0 / 1024;
  phValue = PH_PARAM_A * phValue + PH_PARAM_B;
}


void setup()
{
  pinMode(13, OUTPUT);
  Serial.begin(9600);

  dht.begin();
  u8g.setContrast(0);
  u8g.setRot180();
  TempProcess(StartConvert);
   pinMode(solenoidPin, OUTPUT);
  pinMode(Cleanvalve, OUTPUT);
  pinMode(Sewegevalve, OUTPUT);           //Sets the pin as an output

}

void loop()
{
  delay (2000);
  digitalWrite(13, HIGH);
  delay(800);
  digitalWrite(13, LOW);
  digitalWrite(solenoidPin, HIGH);    //Switch Solenoid ON
  delay(8000);                      //Wait 8 Seconds
  digitalWrite(solenoidPin, LOW);     //Switch Solenoid OFF
  delay(3000);                        // Wait 3 Seonds
  read_Sensor();
  if (("phValue" <= "6" && "phValue" >= "8") && ("ECcurrent" <= "1" && "ECcurrent" >= "3" )) //Set Restrictions on Clean and Dirty
  {
    digitalWrite(Cleanvalve, HIGH); // Switch Clean Solenoid ON
    delay(8000); // Wait 8 Seconds
    digitalWrite(Cleanvalve, LOW); // Switch Clean Solenoid OFF
  }
  else
  {
    digitalWrite(Sewegevalve, HIGH); //Switch Sewege Solenoid OFF
    delay(8000); //Wait 8 Seconds
    digitalWrite(Sewegevalve, LOW); //Switch Sewege Solenoid OFF
  }

  u8g.firstPage();
  do  {
    draw();
  }
  while ( u8g.nextPage() );

}

Sesnor_Module.ino (5.08 KB)