Plant watering project v5

Hi,

unfortunately my old thread got closed. (Plant watering project - problem with two digitalWrite actions - #30 by Jogibaer)
I more or less solved the code issue and it works on my arduino UNO test setup. :sweat_smile:
Then I soldered everything together, but missed the part to test my setup with an external power supply. Please see the connection diagram and the attached code below.
First I didn't connect the GND of the Arduino with the GND of the external power supply, but I did.

  • the Arduino is powered by the external power supply
  • all relay modules are powered as well by the external power supply
  • the (-) pole of the external power supply is also connected to the GND pin on the Arduino board

My problem or question is:

  1. The relay module No. 3 is closed (HIGH) all the time therefore it's LED is light up. Do you think the relay No. 3 is faulty?
  2. When external power is not on, and I connect the Arduino to USB Power only, some relay modules light up slightly or very bright. I checked all connections multiple times, checked for short circuits and so on, but I can't find the mistake or explain it.
  3. What do you think of my connection diagram, do you see any mistakes? :thinking:

Edit: Picture updated

/***************************************************************
  Project: Pflanzenrettung 5.0 a.k.a. "Plant Redeemer" (by Jogibaer)
 ***************************************************************/
#include <Adafruit_GFX.h>           // Include core graphics library for the display
#include <Adafruit_SSD1306.h>       // Include Adafruit_SSD1306 library to drive the display
Adafruit_SSD1306 display(128, 64);  // Create display
#include <Fonts/FreeMono9pt7b.h>    // Add a custom font
#include <Fonts/DejaVu_Sans_11.h>

int Watertank;
int WaterRelay = 9;
int Olive;
int OliveRelay = 10;
int Papyrus;
int PapyrusRelay = 11;
int Bonsai;
int BonsaiRelay = 12;


int OliveLimit = 500;
int PapyrusLimit = 500;
int BonsaiLimit = 500;
int WatertankLimit = 800;

#define soilSensor_Olive A0
#define soilSensor_Papyrus A1
#define soilSensor_Bonsai A2
#define soilSensor_Watertank A3

// 'Plant_Redeemer', 16x20px, Logo/Bild
const unsigned char PlantRedeemer [] PROGMEM = {
  0x06, 0x00, 0x07, 0x80, 0x07, 0x80, 0x07, 0xc0, 0x07, 0xc0, 0x03, 0xc6, 0xfb, 0xdf, 0x7d, 0xbe,
  0x3c, 0x3c, 0x1c, 0x30, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80,
  0x00, 0x80, 0x00, 0x00, 0x07, 0xf0, 0x0f, 0xf0
};



void setup()
{
  Serial.begin(9600);
  pinMode (9, OUTPUT); //Set pin 9 as output for the pump relay
  pinMode (10, OUTPUT); //Set pin 10 as output for the relay
  pinMode (11, OUTPUT); //Set pin 11 as output for the relay
  pinMode (12, OUTPUT); //Set pin 12 as output for the relay
  pinMode (A0, INPUT); //Set pin A0 as analog input for a capacitive soil moisture sensor #0 to Olive
  pinMode (A1, INPUT); //Set pin A1 as analog input for a capacitive soil moisture sensor #1 to Papyrus
  pinMode (A2, INPUT); //Set pin A2 as analog input for a capacitive soil moisture sensor #2 to Bonsai
  pinMode (A3, INPUT); //Set pin A3 as analog input for a capacitive soil moisture sensor #3 to Watertank

  //OLED**************************************************************************************************************
  delay(100);  // This delay is needed to let the display to initialize
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Initialize display with the I2C address of 0x3C
  display.clearDisplay();        // Clear the buffer
  display.setTextColor(WHITE);  // Set color of the text
  display.setRotation(0);      // Set orientation. Goes from 0, 1, 2 or 3
  display.setTextWrap(false);  // By default, long lines of text are set to automatically “wrap” back to the leftmost column.
  // To override this behavior (so text will run off the right side of the display - useful for
  // scrolling marquee effects), use setTextWrap(false). To restore it, replace "false" with "true".
  display.dim(1);  //Set brightness (0 is maximun and 1 is a little dim)
  ////OLED************************************************************************************************************

}


void loop()
{
  Olive = analogRead(soilSensor_Olive);
  Papyrus = analogRead(soilSensor_Papyrus);
  Bonsai = analogRead(soilSensor_Bonsai);
  Watertank = analogRead(soilSensor_Watertank);


  Serial.print("Feuchtigkeitswert Olive:");
  Serial.println(Olive);
  delay(400);
  Serial.print("Feuchtigkeitswert Papyrus:");
  Serial.println(Papyrus);
  delay(400);
  Serial.print("Feuchtigkeitswert Bonsai:");
  Serial.println(Bonsai);
  delay(400);
  Serial.print("Watertank Level:");
  Serial.println(Watertank);
  delay(400);

  //OLED**************************************************************************************************************
  display.clearDisplay();
  display.drawBitmap(1, 1, PlantRedeemer, 16, 20, WHITE);
  display.setFont(&DejaVu_Sans_11);
  display.setTextSize(0);
  display.setCursor(22, 13);
  display.print("Plant Redeemer");
  display.setTextSize(0);
  display.setFont(&FreeMono9pt7b);
  display.setCursor(0, 34);
  display.print("Olive:  ");
  display.println(Olive);
  display.setCursor(0, 48);
  display.print("Papyrus:");
  display.println(Papyrus);
  display.setCursor(0, 62);
  display.print("Bonsai: ");
  display.println(Bonsai);
  display.display();
  ////OLED**************************************************************************************************************

  if ((Olive < OliveLimit) && (Watertank < WatertankLimit))
  {
    digitalWrite(OliveRelay, LOW); //meaning the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, LOW); //the water pump will not run
    delay(200);
  }
  else if ((Olive > OliveLimit) && (Watertank < WatertankLimit))
  {
    digitalWrite(OliveRelay, HIGH); //meaning the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, HIGH); //the water pump will run
  }
  delay(200);
  //**************************************************************************************************************
  if ((Papyrus < PapyrusLimit) && (Watertank < WatertankLimit))
  {
    digitalWrite(PapyrusRelay, LOW); //the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, LOW);   //the water pump will not run
    delay(200);
  }
  else if ((Papyrus > PapyrusLimit) && (Watertank < WatertankLimit))
  {
    digitalWrite(PapyrusRelay, HIGH); //the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, HIGH);   //the water pump will run
  }
  delay(200);
  //**************************************************************************************************************
  if ((Bonsai < BonsaiLimit) && (Watertank < WatertankLimit))
  {
    digitalWrite(BonsaiRelay, LOW); //the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, LOW);  //the water pump will not run
    delay(200);
  }
  else if ((Bonsai > BonsaiLimit) && (Watertank < WatertankLimit))
  {
    digitalWrite(BonsaiRelay, HIGH); //the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, HIGH);  //the water pump will run
  }
  delay(200);
  //**************************************************************************************************************
  if (Watertank > WatertankLimit) //if the water level is too low
  {
    digitalWrite(WaterRelay, LOW);
    digitalWrite(OliveRelay, LOW);
    digitalWrite(PapyrusRelay, LOW);
    digitalWrite(BonsaiRelay, LOW);
  }
  delay(2000);
  //**************************************************************************************************************
}

Hello
Do all power supplys have a common GND?

Yes they do if I connect it the way it was supposed to be.

Edit: I updated the picture, the connection was missing you are right. However it is already the case in reality.

Hello,
check your hardware with a small test sketch.

A real schematic would be much easier to follow!

@paulpaulson Ok I will do that....
@gilshultz Here they are, I hope there will be no shitstorm coming for me. :sweat_smile: I know 230 V on a circuit board are critical, but I took focus on a "good" isolation. Even if somebody should touch the PCB with power on, nothing would happen. The board is normally mounted and protected in a sealed case for electronics.


It is very bad practice to have both AC and DC on the same board.
It is even worse to not have them completly isolated.

It looks like you have AC in multiple areas.

Lift the MICRO and OLED and isolate them with nylon standoffs.

On your fritzrig. Change to schematic view move the parts around to reduce crossing wires. Learn how to rotate and flip parts to make it more readable.

Frankly, I always find connection diagrams confusing to read. I prefer a real schematic. Combined with either a PCB layout, physical access to the device and/or very good photographs, this usually sufficient for troubleshooting. I've never in my life made a connection diagram. I've made thousands of schematics though.

1.change other Relay test
2.

void setup(){
    digitalWrite(WaterRelay, LOW);
    digitalWrite(OliveRelay, LOW);
    digitalWrite(PapyrusRelay, LOW);
    digitalWrite(BonsaiRelay, LOW);
}

can you try the.

The Arduino CANNOT provide power to relays.

You must provide the voltage directly from a power supply.

I finally got some time to proceed with my project. The source of my problem was really a faulty relay. Now after replacing the relay, my electronics work. However, there is still this small optimization problem I need to solve. It might has to do with the delays between the actions, but I'm afraid I'll need to change the whole code.
First I will play around with the delays and try to circumvent the problem, but if somebody has an idea how I can improve the code or make it more efficient, please let me know. :hugs:

The videos show what I mean:

  1. If sensor 1 is too dry and its relay is open, the arduino adds all delays together, so the time the pump is running is sufficient to get some water to the plants.
  1. However, if only sensor 3 is asking for water, the runtime of the pump is too short to get water to the plants. I hope you see what I mean.
/***************************************************************
  Project: Pflanzenrettung 5.0 a.k.a. "Plant Redeemer" (by Jogibaer)
 ***************************************************************/
#include <Adafruit_GFX.h>           // Include core graphics library for the display
#include <Adafruit_SSD1306.h>       // Include Adafruit_SSD1306 library to drive the display
Adafruit_SSD1306 display(128, 64);  // Create display
#include <Fonts/FreeMono9pt7b.h>    // Add a custom font
#include <Fonts/DejaVu_Sans_11.h>

int Watertank;
int WaterRelay = 9;
int S1;
int S1Relay = 10;
int S2;
int S2Relay = 11;
int S3;
int S3Relay = 12;


int S1Limit = 330; //Papyrus 1
int S2Limit = 210; //Bonsai
int S3Limit = 350; //Papyrus 2
int WatertankLimit = 350;

#define soilSensor_S1 A0
#define soilSensor_S2 A1
#define soilSensor_S3 A2
#define soilSensor_Watertank A3

// 'Plant_Redeemer', 16x20px, Logo/Bild
const unsigned char PlantRedeemer [] PROGMEM = {
  0x06, 0x00, 0x07, 0x80, 0x07, 0x80, 0x07, 0xc0, 0x07, 0xc0, 0x03, 0xc6, 0xfb, 0xdf, 0x7d, 0xbe,
  0x3c, 0x3c, 0x1c, 0x30, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80,
  0x00, 0x80, 0x00, 0x00, 0x07, 0xf0, 0x0f, 0xf0
};

// 'water1_34x15', 34x15px
const unsigned char water_symbol [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xc0, 0x60, 0x00, 0x0f, 0x87, 0xe1, 0xf0, 0x00, 0x3d, 
  0xcf, 0x73, 0x99, 0x80, 0xf0, 0x7c, 0x3f, 0x0f, 0x80, 0xe0, 0x30, 0x1c, 0x07, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x80, 
  0x60, 0x00, 0x0f, 0x83, 0xc0, 0xf0, 0x00, 0x1f, 0xcf, 0xe3, 0xf8, 0x80, 0xf8, 0xfc, 0x3f, 0x0f, 
  0x80, 0xe0, 0x78, 0x1e, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};



void setup()
{
  Serial.begin(9600);
  pinMode (9, OUTPUT); //Set pin 9 as output for the pump relay
  pinMode (10, OUTPUT); //Set pin 10 as output for the relay
  pinMode (11, OUTPUT); //Set pin 11 as output for the relay
  pinMode (12, OUTPUT); //Set pin 12 as output for the relay
  pinMode (A0, INPUT); //Set pin A0 as analog input for a capacitive soil moisture sensor #0 to S1
  pinMode (A1, INPUT); //Set pin A1 as analog input for a capacitive soil moisture sensor #1 to S2
  pinMode (A2, INPUT); //Set pin A2 as analog input for a capacitive soil moisture sensor #2 to S3
  pinMode (A3, INPUT); //Set pin A3 as analog input for a capacitive soil moisture sensor #3 to Watertank

  //OLED**************************************************************************************************************
  delay(100);  // This delay is needed to let the display to initialize
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Initialize display with the I2C address of 0x3C
  display.clearDisplay();        // Clear the buffer
  display.setTextColor(WHITE);  // Set color of the text
  display.setRotation(0);      // Set orientation. Goes from 0, 1, 2 or 3
  display.setTextWrap(false);  // By default, long lines of text are set to automatically “wrap” back to the leftmost column.
  // To override this behavior (so text will run off the right side of the display - useful for
  // scrolling marquee effects), use setTextWrap(false). To restore it, replace "false" with "true".
  display.dim(1);  //Set brightness (0 is maximun and 1 is a little dim)
  ////OLED************************************************************************************************************

}


void loop()
{
  S1 = analogRead(soilSensor_S1);
  S2 = analogRead(soilSensor_S2);
  S3 = analogRead(soilSensor_S3);
  Watertank = analogRead(soilSensor_Watertank);


  Serial.print("Feuchtigkeitswert S1:");
  Serial.println(S1);
  delay(400);
  Serial.print("Feuchtigkeitswert S2:");
  Serial.println(S2);
  delay(400);
  Serial.print("Feuchtigkeitswert S3:");
  Serial.println(S3);
  delay(400);
  Serial.print("Watertank Level:");
  Serial.println(Watertank);
  delay(400);

  //OLED**************************************************************************************************************
  display.clearDisplay();
  display.drawBitmap(1, 1, PlantRedeemer, 16, 20, WHITE);
  display.drawBitmap(18, 50, water_symbol, 33, 15, WHITE);
  display.setFont(&DejaVu_Sans_11);
  display.setTextSize(0);
  display.setCursor(22, 13);
  display.print("Plant Redeemer");
  display.setFont(&DejaVu_Sans_11);
  display.setTextSize(0);
  display.setCursor(75, 33);
  display.print("S1: ");
  display.println(S1);
  display.setCursor(75, 48);
  display.print("S2: ");
  display.println(S2);
  display.setCursor(75, 62);
  display.print("S3: ");
  display.println(S3);

  display.setFont(&DejaVu_Sans_11);
  display.setTextSize(0);
  display.setCursor(0, 33);
  display.print("Watertank");
  display.setCursor(0, 46);
  display.print("level: ");
  display.println(Watertank);

  display.drawLine(70, 24, 70, 80, WHITE);




  display.display();
  ////OLED**************************************************************************************************************

  if ((S1 < S1Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S1Relay, LOW); //meaning the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, LOW); //the water pump will not run
    delay(200);
  }
  else if ((S1 > S1Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S1Relay, HIGH); //meaning the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, HIGH); //the water pump will run
  }
  delay(200);
  //**************************************************************************************************************
  if ((S2 < S2Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S2Relay, LOW); //the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, LOW);   //the water pump will not run
    delay(200);
  }
  else if ((S2 > S2Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S2Relay, HIGH); //the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, HIGH);   //the water pump will run
  }
  delay(200);
  //**************************************************************************************************************
  if ((S3 < S3Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S3Relay, LOW); //the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, LOW);  //the water pump will not run
    delay(200);
  }
  else if ((S3 > S3Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S3Relay, HIGH); //the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, HIGH);  //the water pump will run
  }
  delay(200);
  //**************************************************************************************************************
  if (Watertank > WatertankLimit) //if the water level is too low
  {
    digitalWrite(WaterRelay, LOW);
    digitalWrite(S1Relay, LOW);
    digitalWrite(S2Relay, LOW);
    digitalWrite(S3Relay, LOW);
  }
  delay(2000);
  //**************************************************************************************************************
}

You could use a boolean variable to tell you whether any plants need water. Set it false before your ifs and if any plant needs water, set it true.

Keep the code to open the valves for whichever plants need it, but leave the pump relay alone.

After your checks, if you have water and the variable is true, run the pump for 600mS (or whatever). Then plant three will get some.

I'm not sure what you mean. So I define a new boolean for the pump_relay? I don't understand your part where you say "leave the pump relay alone"? I tried to write it down, please see the code below. However, in my opinion I have only replaced the LOW by a defined boolean variable....I don't yet understand the benefit of this. :thinking:


boolean boolean_pump = false;
  
  ////Watering routine**********************************************************************************************
  if ((S1 < S1Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S1Relay, LOW); //meaning the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, boolean_pump); //the water pump will not run
    delay(600);
  }
  else if ((S1 > S1Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S1Relay, HIGH); //meaning the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, boolean_pump); //the water pump will run
    boolean_pump = !boolean_pump;
  }
  delay(600);
  //**************************************************************************************************************
  if ((S2 < S2Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S2Relay, LOW); //the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, boolean_pump); //the water pump will not run
    delay(600);
  }
  else if ((S2 > S2Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S2Relay, HIGH); //the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, boolean_pump); //the water pump will run
    boolean_pump = !boolean_pump;
  }
  delay(600);
  //**************************************************************************************************************
  if ((S3 < S3Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S3Relay, LOW); //the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, boolean_pump); //the water pump will not run
    delay(600);
  }
  else if ((S3 > S3Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S3Relay, HIGH); //the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, boolean_pump); //the water pump will run
    boolean_pump = !boolean_pump;
  }
  delay(600);
  //**************************************************************************************************************
  if (Watertank > WatertankLimit) //if the water level is too low
  {
    digitalWrite(WaterRelay, boolean_pump);
    digitalWrite(S1Relay, LOW);
    digitalWrite(S2Relay, LOW);
    digitalWrite(S3Relay, LOW);
  }
  delay(600);
  //**************************************************************************************************************
}

Whole code for the mods. :stuck_out_tongue_winking_eye::

/***************************************************************
  Project: Pflanzenrettung 5.0 a.k.a. "Plant Redeemer" (by Jogibaer)
 ***************************************************************/
#include <Adafruit_GFX.h>           // Include core graphics library for the display
#include <Adafruit_SSD1306.h>       // Include Adafruit_SSD1306 library to drive the display
Adafruit_SSD1306 display(128, 64);  // Create display
#include <Fonts/FreeMono9pt7b.h>    // Add a custom font
#include <Fonts/DejaVu_Sans_11.h>

int Watertank;
int WaterRelay = 9;
int S1;
int S1Relay = 10;
int S2;
int S2Relay = 11;
int S3;
int S3Relay = 12;



int S1Limit = 330; //Papyrus 1
int S2Limit = 210; //Bonsai
int S3Limit = 350; //Papyrus 2
int WatertankLimit = 350;

#define soilSensor_S1 A0
#define soilSensor_S2 A1
#define soilSensor_S3 A2
#define soilSensor_Watertank A3

// 'Plant_Redeemer', 16x20px, Logo/Bild
const unsigned char PlantRedeemer [] PROGMEM = {
  0x06, 0x00, 0x07, 0x80, 0x07, 0x80, 0x07, 0xc0, 0x07, 0xc0, 0x03, 0xc6, 0xfb, 0xdf, 0x7d, 0xbe,
  0x3c, 0x3c, 0x1c, 0x30, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80,
  0x00, 0x80, 0x00, 0x00, 0x07, 0xf0, 0x0f, 0xf0
};

// 'water1_34x15', 34x15px
const unsigned char water_symbol [] PROGMEM = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0xc0, 0x60, 0x00, 0x0f, 0x87, 0xe1, 0xf0, 0x00, 0x3d, 
  0xcf, 0x73, 0x99, 0x80, 0xf0, 0x7c, 0x3f, 0x0f, 0x80, 0xe0, 0x30, 0x1c, 0x07, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x80, 
  0x60, 0x00, 0x0f, 0x83, 0xc0, 0xf0, 0x00, 0x1f, 0xcf, 0xe3, 0xf8, 0x80, 0xf8, 0xfc, 0x3f, 0x0f, 
  0x80, 0xe0, 0x78, 0x1e, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};



void setup()
{
  Serial.begin(9600);
  pinMode (9, OUTPUT); //Set pin 9 as output for the pump relay
  pinMode (10, OUTPUT); //Set pin 10 as output for the relay
  pinMode (11, OUTPUT); //Set pin 11 as output for the relay
  pinMode (12, OUTPUT); //Set pin 12 as output for the relay
  pinMode (A0, INPUT); //Set pin A0 as analog input for a capacitive soil moisture sensor #0 to S1
  pinMode (A1, INPUT); //Set pin A1 as analog input for a capacitive soil moisture sensor #1 to S2
  pinMode (A2, INPUT); //Set pin A2 as analog input for a capacitive soil moisture sensor #2 to S3
  pinMode (A3, INPUT); //Set pin A3 as analog input for a capacitive soil moisture sensor #3 to Watertank

  //OLED**************************************************************************************************************
  delay(100);  // This delay is needed to let the display to initialize
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // Initialize display with the I2C address of 0x3C
  display.clearDisplay();        // Clear the buffer
  display.setTextColor(WHITE);  // Set color of the text
  display.setRotation(0);      // Set orientation. Goes from 0, 1, 2 or 3
  display.setTextWrap(false);  // By default, long lines of text are set to automatically “wrap” back to the leftmost column.
  // To override this behavior (so text will run off the right side of the display - useful for
  // scrolling marquee effects), use setTextWrap(false). To restore it, replace "false" with "true".
  display.dim(1);  //Set brightness (0 is maximun and 1 is a little dim)
  ////OLED************************************************************************************************************
}



void loop()
{
  S1 = analogRead(soilSensor_S1);
  S2 = analogRead(soilSensor_S2);
  S3 = analogRead(soilSensor_S3);
  Watertank = analogRead(soilSensor_Watertank);


  Serial.print("Feuchtigkeitswert S1:");
  Serial.println(S1);
  delay(400);
  Serial.print("Feuchtigkeitswert S2:");
  Serial.println(S2);
  delay(400);
  Serial.print("Feuchtigkeitswert S3:");
  Serial.println(S3);
  delay(400);
  Serial.print("Watertank Level:");
  Serial.println(Watertank);
  delay(400);

  //OLED**************************************************************************************************************
  display.clearDisplay();
  display.drawBitmap(1, 1, PlantRedeemer, 16, 20, WHITE);
  display.drawBitmap(18, 50, water_symbol, 33, 15, WHITE);
  display.setFont(&DejaVu_Sans_11);
  display.setTextSize(0);
  display.setCursor(22, 13);
  display.print("Plant Redeemer");
  display.setFont(&DejaVu_Sans_11);
  display.setTextSize(0);
  display.setCursor(75, 33);
  display.print("S1: ");
  display.println(S1);
  display.setCursor(75, 48);
  display.print("S2: ");
  display.println(S2);
  display.setCursor(75, 62);
  display.print("S3: ");
  display.println(S3);

  display.setFont(&DejaVu_Sans_11);
  display.setTextSize(0);
  display.setCursor(0, 33);
  display.print("Watertank");
  display.setCursor(0, 46);
  display.print("level: ");
  display.println(Watertank);

  display.drawLine(70, 24, 70, 80, WHITE);
  display.display();
  ////OLED**************************************************************************************************************


boolean boolean_pump = false;
  
  ////Watering routine**********************************************************************************************
  if ((S1 < S1Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S1Relay, LOW); //meaning the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, boolean_pump); //the water pump will not run
    delay(600);
  }
  else if ((S1 > S1Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S1Relay, HIGH); //meaning the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, boolean_pump); //the water pump will run
    boolean_pump = !boolean_pump;
  }
  delay(600);
  //**************************************************************************************************************
  if ((S2 < S2Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S2Relay, LOW); //the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, boolean_pump); //the water pump will not run
    delay(600);
  }
  else if ((S2 > S2Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S2Relay, HIGH); //the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, boolean_pump); //the water pump will run
    boolean_pump = !boolean_pump;
  }
  delay(600);
  //**************************************************************************************************************
  if ((S3 < S3Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S3Relay, LOW); //the soil is still wet, the relay stays open (NO)
    digitalWrite(WaterRelay, boolean_pump); //the water pump will not run
    delay(600);
  }
  else if ((S3 > S3Limit) && (Watertank < WatertankLimit))
  {
    digitalWrite(S3Relay, HIGH); //the plant needs water, therefore the pump needs to run if there is enough water in the tank.
    digitalWrite(WaterRelay, boolean_pump); //the water pump will run
    boolean_pump = !boolean_pump;
  }
  delay(600);
  //**************************************************************************************************************
  if (Watertank > WatertankLimit) //if the water level is too low
  {
    digitalWrite(WaterRelay, boolean_pump);
    digitalWrite(S1Relay, LOW);
    digitalWrite(S2Relay, LOW);
    digitalWrite(S3Relay, LOW);
  }
  delay(600);
  //**************************************************************************************************************
}

My suggestion was that you separate the logic that checks the need for watering from the code that does it.

Currently, you check plant one and if it needs water, you open the valve, start the pump and have at it. If later plants want water too, plant one gets a bonanza.

Find out who needs water and open the appropriate valves. Then run the pump; don't rely on later plants being thirsty to ensure that they get what they need.

I'll guess though that their water needs differ. It might be better to water each when it needs it for a suitable time.