Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based Water Quality Monitoring System with Ultrasonic, pH, and Temperature Sensors

View and Edit Project In Cirkit DesignerImage of Arduino-Based Water Quality Monitoring System with Ultrasonic, pH, and Temperature Sensors

Circuit Documentation

Summary

This circuit is designed to monitor the water level, pH, and temperature of a water tank. It uses an Arduino UNO microcontroller to read data from an ultrasonic sensor, a pH meter, and a temperature sensor. The data is displayed on a 20x4 I2C LCD. The system alerts the user if the water level is high or low.

Component List

  1. Lcd 20x4 i2c

    • Description: 20x4 character LCD with I2C interface.
    • Pins: GND, 5V, SCA, SCL
  2. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  3. Ultrasonic Sensor

    • Description: Sensor to measure distance using ultrasonic waves.
    • Pins: +VCC, Trigger, Echo, GND
  4. PH Meter

    • Description: Sensor to measure the pH level of a solution.
    • Pins: Signal, VCC, GND
  5. Temperature Sensor

    • Description: Sensor to measure temperature.
    • Pins: Temp GND Black, Temp VDD Red, Temp DQ Data Yellow

Wiring Details

Lcd 20x4 i2c

Arduino UNO

Ultrasonic Sensor

PH Meter

Temperature Sensor

Documented Code

Arduino UNO Code

/*
 * This Arduino Sketch reads data from an ultrasonic sensor, pH meter, and
 * temperature sensor to monitor the water level, pH, and temperature of a
 * water tank. The data is displayed on a 20x4 I2C LCD. The system alerts
 * the user if the water level is high or low.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define TRIGGER_PIN 9
#define ECHO_PIN 8
#define PH_PIN 11
#define TEMP_PIN 10

LiquidCrystal_I2C lcd(0x27, 20, 4);
OneWire oneWire(TEMP_PIN);
DallasTemperature sensors(&oneWire);

void setup() {
  lcd.begin();
  lcd.backlight();
  pinMode(TRIGGER_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  sensors.begin();
  Serial.begin(9600);
}

void loop() {
  // Measure water level
  digitalWrite(TRIGGER_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIGGER_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIGGER_PIN, LOW);
  long duration = pulseIn(ECHO_PIN, HIGH);
  float distance = (duration / 2.0) * 0.0343;

  // Read pH value
  int phValue = analogRead(PH_PIN);
  float voltage = phValue * (5.0 / 1023.0);
  float ph = 3.5 * voltage;

  // Read temperature
  sensors.requestTemperatures();
  float temperature = sensors.getTempCByIndex(0);

  // Display data on LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Water Level: ");
  if (distance < 10) {
    lcd.print("High");
  } else {
    lcd.print("Low");
  }
  lcd.setCursor(0, 1);
  lcd.print("pH: ");
  lcd.print(ph);
  lcd.setCursor(0, 2);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print(" C");

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

Lcd 20x4 i2c Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}