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

  
    #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.

“LVGL is the only framework that I've seen as open source Graphics Library for Microcontrollers. It’s easy to customize, adapts to any design, and the build size is tiny.”

Rahul R S
Embedded System Engineer

Recent Posts

Nokia 5110 LCD with a Raspberry Pi using WiringPi

Nokia 5110 LCD with a Raspberry Pi using WiringPi

Nokia 5110 LCD PCD8544 driver with a Raspberry Pi using WiringPi

OLED ssd1306 interface with Raspberry Pi using WiringPi

OLED ssd1306 interface with Raspberry Pi using WiringPi

OLED ssd1306 display interface with Raspberry Pi using WiringPi

ESP32 lvgl touch display control multiple relay

ESP32 lvgl touch display control multiple relay

To control a 4-channel relay using an ESP32 with a touch display (via LVGL library), you can integrate the relay control with a graphical user interface (GUI).

Interface the ADS1115 adc with a Raspberry Pi using WiringPi

Interface the ADS1115 adc with a Raspberry Pi using WiringPi

Interface the ADS1115 analog-to-digital converter (ADC) with a Raspberry Pi using WiringPi

MPU6050 sensor interface with Raspberry Pi using WiringPi

MPU6050 sensor interface with Raspberry Pi using WiringPi

MPU6050 Accelerometer and Gyroscope interface with Raspberry Pi using WiringPi

ESP32 Wifi http get and post method request

ESP32 Wifi http get and post method request

To perform HTTP GET and HTTP POST requests on an ESP32, you can use the WiFi and HTTPClient libraries.