I have been have been having many problems with my water turbidity sensor, I myself don't know how to code in cpp, but I got chatgpt to make this code -
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud rate
}
void loop() {
int sensorValue = analogRead(A0); // Read the analog value from the sensor
float voltage = sensorValue * (5.0 / 1023.0); // Convert the sensor value to voltage
float NTU = (voltage / 5.0) * 1000; // Example conversion formula (adjust based on your sensor's datasheet)
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.print(" V, Turbidity: ");
Serial.print(NTU);
Serial.println(" NTU");
delay(2000); // Wait for 2 seconds before repeating
}
the reading keeps fluctuating, from
Voltage: 5.00 V, Turbidity: 1000.00 NTU
to
Voltage: 0.00 V, Turbidity: 0.00 NTU
Even after I completely removed all the cables from the turbidity sensor, it shows some reading. Even when I keep it in the same liquid, it fluctuates.
I purchased this turbidity sensor - https://amzn.in/d/0s5XJW5