ESP32 and Turbidity Sensor Problems

i'm using ESP32 S2 DevKit M-1 with Gravity: Analog Turbidity Sensor for Arduino on my school project

for the code i'm using chatGPT to alter the base code, and the GPT told me to use 1.8 kOhm and 3.3 kOhm resistor to decrease the voltage of the turbidity sensor, because the ESP32 operates on 3.3 V

for the given code:

const int analogPin = 1; // GPIO1

void setup() {
  Serial.begin(9600);
  analogSetAttenuation(ADC_11db); // Rentang pembacaan hingga ~3,3V
}

void loop() {
  float voltage = readVoltage(analogPin);
  float ntu = calculateNTU(voltage);
  
  Serial.print("Tegangan: ");
  Serial.print(voltage);
  Serial.print(" V, Kekeruhan: ");
  Serial.print(ntu);
  Serial.println(" NTU");
  
  delay(500);
}

float readVoltage(int pin) {
  int sensorValue = analogRead(pin);
  float voltage = sensorValue * (3.3 / 4095.0); // Konversi ke tegangan (0 - 3,3V)
  
  // Koreksi tegangan karena pembagi tegangan
  float actualVoltage = voltage * ((1.8 + 3.3) / 3.3); // Faktor skala
  return actualVoltage;
}

float calculateNTU(float voltage) {
  // Menggunakan persamaan yang diberikan
  float ntu = -1120.4 * voltage * voltage + 5742.3 * voltage - 4352.9;
  return ntu;
}

for the connectivity of the components are like this:

additional information:

  • Sensor Output Signal → First End of R1 (1.8 kΩ)
  • Second End of R1 → Midpoint of Voltage Divider
  • First End of R2 (3.3 kΩ) → Midpoint of Voltage Divider
  • Second End of R2 → GND ESP32
  • Midpoint of Voltage Divider → GPIO1 ESP32
  • VCC Sensor → 5V
  • GND Sensor → GND ESP32

the problem is the sensor read the same value whether i put the probe of the sensor on water or i just put the probe on the ground, showing exact same value

pleasee anybody can help me solve these problems :cold_sweat:

Well let's do some debugging.

Remove Sensor Output Signal from the First End of R1
Connect the First End of R1 to 5V.
What is shown on the serial monitor?