automatic watering system

i make automatic watering system using 2 pumps, but now i use 2 relays for indicator. i use 2 soil moisture sensors for 2 plant, if first plant need water, the first relay will active (HIGH), and if the second plant need water, second relay will active (HIGH). but when all plants need water at the same time, my program if else read first condition and then the second, so the relays will not active together. here is my program

if (humidity<80 && temperature<34 && soil<50) {
digitalWrite(relay, HIGH);
delay(1000);
digitalWrite(relay, LOW);
}
else {
digitalWrite(relay,LOW);
}

if (humidity<80 && temperature<34 && soil1<50) {
digitalWrite(relay2, HIGH);
delay(1000);
digitalWrite(relay2,LOW);
}
else {
digitalWrite(relay2,LOW);
}

thank you for your help :slight_smile:

i mean i use 2 relays for activate pumps

If you have all relays going on together you will run the risk of drawing to much power from the power supply and frying it.

It is safer to have the relays turn on sequentially rather than all together.

P.S. I hope you aren't powering the solenoid valves directly from the Arduino, i.e. you have a standalone power supply that powers both the arduino and the solenoids.

try moving the delay() outside the if statements

 if (humidity<80 && temperature<34 && soil<50) {
 digitalWrite(relay, HIGH);
 //delay(1000);
 digitalWrite(relay, LOW);
 }
  else {
    digitalWrite(relay,LOW);
  }
  //   << should you read new temperature etc here???
  if (humidity<80 && temperature<34 && soil1<50) {
 digitalWrite(relay2, HIGH);
 //delay(1000);
 digitalWrite(relay2,LOW);
  }
  else {
    digitalWrite(relay2,LOW);
  }
 delay(1000);

also in between the if() statements should you read new temperature etc
and as @boylesg says be careful with power supplies