Smart Water Quality Monitoring System

Introduction :

It is a portable device which measures the quality of drinking water which is integrated with ESP8226 wifi module. It measures the parameters like PH and Turbidity.  If these parameters exceeds the permissible limit buzzer Circuit will be enabled and message will be sent to user using Blynk Software. Later we can add many sensors to this project  like conductivity ,CO2 , temperature ,etc. according to requirements.

Components Required:

1. Arduino Uno

2. Turbidity sensor  + Signal Conditioning Module

3. pH Sensor+ Signal Conditioning Module

4. Breadboard

5.Jumpers

6.LCD Display

7. Buzzer

8. LEDs (optional)

9. ESP8226

10. Blynk App

This Block Diagram shows connections of ph module, 16x2 LCD , ESP8226 and Buzzer With Arduino. Turbidity Sensor and its Module Can be connected in a similar way to A0 pin of Arduino.
This Block Diagram shows connections of PH Sensor module(Ph sensor can be connected directly to its module using BNC connector), 16×2 LCD , ESP8226 and Buzzer With Arduino. Turbidity Sensor and its Module Can be connected in a similar way to A0 pin of Arduino.
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>

char auth[]="            "; // Get and enter Auth Token which is received  from the Blynk App while creating a project
char ssid[]="         "; // Get and enter the 'ssid' and passward i.e., WIFI name and Password 
char pass[]="        ";
#define SensorPin A1
#define Offset 0.00            //deviation compensate
unsigned long int avgValue;     //Store the average value of the sensor feedback
float phValue;
#include <LiquidCrystal.h>
#define buzzer 2
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() 
{
  Serial.begin(9600); //Baud rate: 9600
  Blynk.begin(auth, ssid, pass);
  lcd.begin(16, 2); //initialise lcd with num of columns 16 ,by row 2.
lcd.clear(); //clears lcd 
 pinMode(buzzer, OUTPUT);
 digitalWrite(buzzer, LOW);
}
void loop() 
{
Blynk.run();    // continuously runs with blynk app
  ////////////Turbidity////////////////
   lcd.setCursor(0,0);//set cursor (column by row) indexing from 0
    lcd.print("TAKING READINGS");
  lcd.setCursor(1,1);
  lcd.print("FROM TURBIDITY SENSOR");
  Serial.println("Taking Readings from turbidity Sensor");
  int sensorValue = analogRead(A0);// read the input on analog pin 0:
  float voltage = sensorValue * (5.0 / 1024.0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float turbidity= sensorValue/100; ////// shows turbidity value in terms of NTU
  Serial.print("Voltage");
  Serial.println(voltage);// print out the value you read:
  Serial.print("Turbidity");
  Serial.println(turbidity);
  delay(500);
if(turbidity >6){
    lcd.clear();
     digitalWrite(buzzer, HIGH);
    lcd.setCursor(1,0);//set cursor (column by row) indexing from 0
    lcd.print("Turbidity:");
    lcd.setCursor(10,0);
    lcd.print(turbidity);
      lcd.setCursor(0,1);//set cursor (column by row) indexing from 0
    lcd.print("Turbidity HIGH");
    Serial.println("Water Alkalinity high");
    delay(3000);
   }
  if(turbidity<6){
      digitalWrite(buzzer, LOW);
    lcd.clear();
    lcd.setCursor(1,0);//set cursor (column by row) indexing from 0
    lcd.print("Turbidity");
    lcd.setCursor(10,0);
    lcd.print(turbidity);
    lcd.setCursor(0,1);
     lcd.setCursor(1,1);//set cursor (column by row) indexing from 0
    lcd.print("WATER IS SAFE");
    Serial.println("Water Is  safe");
  }
 //////////PH////////////
  lcd.setCursor(0,0);//set cursor (column by row) indexing from 0
  lcd.print("TAKING READINGS");
  lcd.setCursor(1,1);
  lcd.print("FROM PH SENSOR");
  Serial.println("Taking Readings from PH Sensor");
   int buf[10];                //buffer for read analog
  for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  {
    buf[i]=analogRead(SensorPin);
    delay(10);
  }
avgValue=0;
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
    avgValue+=buf[i];
  float phValue=(float)avgValue*3.8/1030/6; //convert the analog into millivolt
  phValue=3.3*phValue+Offset;                      //convert the millivolt into pH value
  Serial.print("pH:"); 
  Serial.print(phValue,2);
  Serial.println(" ");
  if(phValue >= 7.30){
    lcd.clear();
   digitalWrite(buzzer, HIGH);
    lcd.setCursor(1,0);//set cursor (column by row) indexing from 0
    lcd.print("PH VALUE:");
    lcd.setCursor(10,0);
    lcd.print(phValue);
    lcd.setCursor(0,1);
    Serial.print("PH VALUE: ");
    Serial.println(phValue); 
    lcd.setCursor(0,1);//set cursor (column by row) indexing from 0
    lcd.print("ALKALINITY HIGH");
    Serial.println("Water Alkalinity high");
    delay(3000);   }
   if(phValue >= 6.90 && phValue <= 7.19){
      digitalWrite(buzzer, LOW);
    lcd.clear();
    lcd.setCursor(1,0);//set cursor (column by row) indexing from 0
    lcd.print("PH VALUE:");
    lcd.setCursor(10,0);
    lcd.print(phValue);
    lcd.setCursor(0,1);
    Serial.print("PH VALUE: ");
    Serial.println(phValue); 
    lcd.setCursor(1,1);//set cursor (column by row) indexing from 0
    lcd.print("WATER IS SAFE");
    Serial.println("Water Is  neutral (safe)");
  }
 if(phValue < 6.89){
    lcd.clear();
     digitalWrite(buzzer, HIGH);
    lcd.setCursor(1,0);//set cursor (column by row) indexing from 0
    lcd.print("PH VALUE:");
    lcd.setCursor(10,0);
    lcd.print(phValue);
    lcd.setCursor(0,1);
    Serial.print("PH VALUE: ");
    Serial.println(phValue); 
    lcd.setCursor(2,1);//set cursor (column by row) indexing from 0
    lcd.print("ACIDITY HIGH");
    Serial.println("Water Acidity High");
    delay(3000);
    }
delay(5000);
  }


This is a user friendly , low cost portable device which can be used for measuring drinking water quality in day to day life. Further Control mechanism can be integrated with this device using wifi operated solenoid valve which will be fitted to main water pipeline.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.