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

Arduino UNO-Based Smart Water Level and Distance Monitoring System with LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Water Level and Distance Monitoring System with LCD Display

Circuit Documentation

Summary

This circuit interfaces an Arduino UNO with an ultrasonic sensor, a water level sensor, an LED, and an I2C LCD screen. The ultrasonic sensor measures distance, the water level sensor detects water levels, and the LED indicates the status. The LCD screen displays the readings from the sensors.

Component List

  1. Arduino UNO

    • Description: A 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
  2. Water Level Sensor

    • Description: A sensor used to detect water levels.
    • Pins: SIG, VCC, GND
  3. HC-SR04 Ultrasonic Sensor

    • Description: An ultrasonic sensor used to measure distance.
    • Pins: VCC, TRIG, ECHO, GND
  4. I2C DISPLAY

    • Description: An I2C LCD screen used to display sensor readings.
    • Pins: GND, VCC, SDL, SCL
  5. LED: Two Pin (red)

    • Description: A red LED used to indicate status.
    • Pins: cathode, anode
  6. Resistor

    • Description: A resistor used to limit current.
    • Properties: Resistance: 200 Ohms
    • Pins: pin1, pin2

Wiring Details

Arduino UNO

Water Level Sensor

HC-SR04 Ultrasonic Sensor

I2C DISPLAY

LED: Two Pin (red)

Resistor

Code Documentation

/*
 * This Arduino sketch interfaces with an ultrasonic sensor, a water level sensor,
 * an LED, and an I2C LCD screen. The ultrasonic sensor measures distance, the
 * water level sensor detects water levels, and the LED indicates the status.
 * The LCD screen displays the readings from the sensors.
 */

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

// Pin definitions
const int trigPin = 9;
const int echoPin = 10;
const int waterSensorPin = A0;
const int ledPin = 7;

// LCD setup
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize pins
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(waterSensorPin, INPUT);
  pinMode(ledPin, OUTPUT);

  // Initialize LCD
  lcd.init();
  lcd.backlight();
}

void loop() {
  // Measure distance using ultrasonic sensor
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;

  // Read water level sensor
  int waterLevel = analogRead(waterSensorPin);

  // Display readings on LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Distance: ");
  lcd.print(distance);
  lcd.print(" cm");
  lcd.setCursor(0, 1);
  lcd.print("Water Level: ");
  lcd.print(waterLevel);

  // Control LED based on water level
  if (waterLevel > 500) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }

  // Print readings to serial monitor
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  Serial.print("Water Level: ");
  Serial.println(waterLevel);

  // Wait before next loop
  delay(1000);
}

This code initializes the pins and the LCD screen, measures the distance using the ultrasonic sensor, reads the water level from the water level sensor, displays the readings on the LCD screen, controls the LED based on the water level, and prints the readings to the serial monitor. The loop runs every second.