Sensor that is fluctuating in a large container

Hi, I'm new to this and I really need help.
For my project, I'm doing a monitoring system in a hydroponics setup. I will be using three sensors which are temperature, dissolved oxygen, and pH sensors. The problem that I have been going through is the pH value has a high fluctuation and the value of the pH isn't correct when it is submerged into a 10-liter container filled with water. However, when it is submerged into a pH 7 and pH 4 (buffer solution) it's correct.

The weird thing is that the readings stabilize to within +/-0.2 when I put the probe in a beaker fill with the buffer solution. When the probe is in the container (10 liters of water) itself, the readings aren't in the range of the tap water pH.

I'm using Arduino IDE software to code for the pH sensor. The values will be displayed in Grafana. I'm using a pH sensor from Inesa Scientific Instrument (E-201-C). It has a potentiometer. I don't know if its the code problem

The code that I'm using is

#include <Servo.h>

Servo acid_solution;
Servo alkaline_solution;

#define acid_pump 9
#define alkaline_pump 10

float calibration_value = 11.15;
int phval = 0;
unsigned long int avgval;
int buffer_arr[50], temp;

float value1,
      value2,
      value3,
      value4,
      value5,
      main_value;

float ph_value;

void setup()
{
  Serial.begin(9600);
  pinMode(A0, INPUT);
  acid_solution.attach(acid_pump);
  alkaline_solution.attach(alkaline_pump);
}
void loop() {


  Serial.println(ph_value);
  getting_value();
  value1 = ph_value;
  delay(300);
  getting_value();
  value2 = ph_value;
  delay(300);
  getting_value();
  value3 = ph_value;
  delay(300);
  getting_value();
  value4 = ph_value;
  delay(300);
  getting_value();
  value5 = ph_value;
  main_value = (value1 + value2 + value3 + value4 + value5) / 5;

  if (main_value > 6.5)
  {
    acid_solution.write(0); //Clockwise maximum speed rotation
  }
  else
  {
    acid_solution.write(90);
  }
  if (main_value < 5.5)
  {
    alkaline_solution.write(0);
  }
  else
  {
    alkaline_solution.write(90);
  }
}
void getting_value()
{
  for (int i = 0; i < 50; i++)
  {
    buffer_arr[i] = analogRead(A0);
    delay(30);
  }
  for (int i = 0; i < 49; i++)
  {
    for (int j = i + 1; j < 50; j++)
    {
      if (buffer_arr[i] > buffer_arr[j])
      {
        temp = buffer_arr[i];
        buffer_arr[i] = buffer_arr[j];
        buffer_arr[j] = temp;
      }
    }
  }
  avgval = 0;
  for (int i = 5; i < 45; i++)

    avgval += buffer_arr[i];

  float volt = (float)avgval * 5.0 / 1024 / 40;
  ph_value = -5.70 * volt + calibration_value;
}

What are you using to measure the ph of your tap water? You must have some other, calibrated device or else you are just guessing.
Paul

Not suitable for testing in low-ion concentration solutions (e.g.: deionized water or distilled water), strong base and strong acid solutions, highly corrosive liquid, or for continuous testing in high-temperature solutions (>140°F).

Uh, you say you're testing using a tank of water. Would that water happen to have a low-ion concentration?

I use to check the tap water pH using the Hanna Instrument pH Meter

Well I use tap water at 25 degree Celsius.

Hello
Take a step back and check and analyse each sensor separately to find out how it works.

I already check one by one. for the temperature and dissolved oxygen sensors there wasn't any problem only the pH sensor. I have submerged the other two sensors without the pH sensor yet. As the pH sensor is giving weird values.