Back to All Blog Posts
Tutorial EltroNerd Engineering

River Water Quality Monitoring System using ESP32 with pH and turbidity sensors

River Water Quality Monitoring System using ESP32 with pH and turbidity sensors. This project is ideal for IoT-based environmental monitoring.

River Water Quality Monitoring using ESP32, pH, and Turbidity Sensors

Monitoring river water quality is essential for environmental protection and public health.
This project uses ESP32 to measure pH and turbidity of water in real-time, providing data for dashboards, alerts, or cloud storage.


Hardware Requirements

  • ESP32 Development Board
  • pH Sensor Module (analog or I2C)
  • Turbidity Sensor Module (analog)
  • Jumper wires and breadboard
  • USB cable for programming
  • Optional: OLED display for local visualization
  • Waterproof housing for sensors if deployed outdoors

Working Principle

  1. pH Measurement:

    • pH sensor outputs voltage corresponding to water acidity/alkalinity.
    • ESP32 reads voltage via ADC and converts to pH value.
  2. Turbidity Measurement:

    • Turbidity sensor outputs analog voltage proportional to water cloudiness.
    • Higher voltage → higher turbidity → more suspended particles.
  3. Data Logging & Visualization:

    • ESP32 can send readings over Wi-Fi to a dashboard, cloud service, or MQTT broker.
    • Alerts can be triggered if pH or turbidity exceeds safe limits.

Arduino Code Example

c

#define PH_PIN 34
#define TURBIDITY_PIN 35

void setup() {
  Serial.begin(115200);
}

void loop() {
  // Read sensors
  int phValueRaw = analogRead(PH_PIN);
  int turbidityRaw = analogRead(TURBIDITY_PIN);

  // Convert raw readings to real values (calibration required)
  float voltagePH = phValueRaw * (3.3 / 4095.0);
  float ph = 3.5 * voltagePH * 3; // approximate conversion, calibrate with buffer solution

  float voltageTurbidity = turbidityRaw * (3.3 / 4095.0);
  float turbidityNTU = (voltageTurbidity - 0.5) * 300; // approximate NTU, calibrate

  Serial.printf("pH: %.2f, Turbidity: %.2f NTU\n", ph, turbidityNTU);

  delay(2000); // read every 2 seconds
}

How to Use

Connect pH sensor and turbidity sensor to ESP32 analog pins. Upload the code to ESP32 and open Serial Monitor.

Try this project in your browser

Compile code and simulate hardware output with EltroNerd Cloud IDE.

Launch Cloud IDE