#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD
LiquidCrystal_I2C lcd(0x27, 20, 4);
// Pin definitions
const int pot1Pin = 35; // Pin for potentiometer 1 Tur
const int pot2Pin = 33; // Pin for potentiometer 2 Ph
const int tempPin = 32; // Pin for temperature sensor
void setup() {
// Initialize the LCD
lcd.init();
lcd.backlight();
// Initialize serial communication
Serial.begin(115200);
// Print welcome message
lcd.setCursor(0, 0);
lcd.print("Water Quality");
lcd.setCursor(0, 1);
lcd.print("Monitoring System");
delay(2000);
// Clear the LCD
lcd.clear();
}
void loop() {
// Read values from sensors
int pot1Value = analogRead(pot1Pin);
int pot2Value = analogRead(pot2Pin);
int tempValue = analogRead(tempPin);
// Map potentiometer values to a range (e.g., 0-100)
int pot1Percent = map(pot1Value, 0, 4095, 0, 100);
int pot2Percent = map(pot2Value, 0, 4095, 0, 100);
// Convert temperature sensor value to Celsius (assuming a specific sensor)
float voltage = tempValue * (3.3 / 4095.0);
float temperature = (voltage - 0.5) * 100.0; // Example conversion for TMP36 sensor
// Print values to the LCD
lcd.setCursor(0, 0);
lcd.print("Turbi:");
lcd.setCursor(6, 0);
lcd.print(pot1Percent);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("PH :");
lcd.setCursor(6, 1);
lcd.print(pot2Percent);
lcd.print("%");
lcd.setCursor(0, 2);
lcd.print("Temp :");
lcd.setCursor(6, 2);
lcd.print(temperature);
lcd.print("C");
// Print values to the Serial Monitor
Serial.print("Turbidity value: ");
Serial.print(pot1Percent);
Serial.print("%, ");
Serial.print("PH value: ");
Serial.print(pot2Percent);
Serial.print("%, ");
Serial.print("Temperature value: ");
Serial.print(temperature);
Serial.println("C");
// Delay before next reading
delay(1000);
}