

A turbidity sensor measures the cloudiness or haziness of a liquid, which is often caused by suspended particles. It is widely used in water quality testing to assess contamination levels, monitor environmental conditions, and ensure compliance with safety standards. Turbidity sensors are essential in industries such as wastewater treatment, aquaculture, beverage production, and environmental monitoring.








Below are the key technical details and pin configuration for a typical turbidity sensor:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (5V DC). |
| 2 | GND | Ground connection. |
| 3 | A0 | Analog output pin. Provides a voltage proportional to the turbidity level. |
| 4 | D0 | Digital output pin. Outputs HIGH or LOW based on a user-defined threshold. |
Below is an example of how to interface a turbidity sensor with an Arduino UNO to read both analog and digital outputs:
// Turbidity Sensor Example Code for Arduino UNO
// Reads analog and digital outputs from the sensor and displays the results
// on the Serial Monitor.
const int analogPin = A0; // Analog output pin connected to A0 on Arduino
const int digitalPin = 2; // Digital output pin connected to D2 on Arduino
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
pinMode(digitalPin, INPUT); // Set digital pin as input
}
void loop() {
// Read the analog value from the sensor
int analogValue = analogRead(analogPin);
// Convert the analog value to voltage (assuming 5V reference)
float voltage = analogValue * (5.0 / 1023.0);
// Read the digital output from the sensor
int digitalValue = digitalRead(digitalPin);
// Print the results to the Serial Monitor
Serial.print("Analog Voltage: ");
Serial.print(voltage);
Serial.println(" V");
Serial.print("Digital Output: ");
if (digitalValue == HIGH) {
Serial.println("HIGH (Turbidity above threshold)");
} else {
Serial.println("LOW (Turbidity below threshold)");
}
delay(1000); // Wait for 1 second before the next reading
}
Inconsistent Readings:
No Output from the Sensor:
Digital Output Always HIGH or LOW:
Analog Output Not Changing:
By following this documentation, users can effectively integrate and operate a turbidity sensor in their projects, ensuring reliable and accurate measurements.