pat
Published © LGPL

Water Level Monitoring System

Monitor water levels accurately with an ultrasonic sensor and Arduino. Real-time data displayed on an LCD. Easy to install and operate

BeginnerFull instructions provided365
Water Level Monitoring System

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Arduino 101
Arduino 101
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
PCBWay Stencil
PCBWay Stencil
×1
Contact, SolderTacts
Contact, SolderTacts
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

Assembly components

Water-Level Monitoring

Schematics

Schematics

Code

Code

C/C++
#include <Wire.h>  // Include the Wire library for I2C communication
#include <LiquidCrystal_I2C.h>  // Include the LiquidCrystal_I2C library for I2C LCD communication
#define trigPin 6
#define echoPin 7
LiquidCrystal_I2C lcd(0x27, 20, 4);  // Set the LCD address to 0x27 for a 16x2 display
void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  lcd.init();  // Initialize the LCD
  lcd.backlight();  // Turn on the backlight
}
void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  long duration = pulseIn(echoPin, HIGH);
  float distance = duration * 0.034 / 2;   
  
  float tankHeight = 73.0;  // Set the height of the tank in cm
  float waterLevel = tankHeight - distance;  // Calculate the water level
  if (waterLevel < 0) {
    waterLevel = 0;  // Prevent negative water level values
  }
 // float waterLevelPercent = (waterLevel / tankHeight) * 100.0;  // Convert water level to percentage
  lcd.clear();  // Clear the LCD
  lcd.setCursor(0, 0);  // Set the cursor to the first column of the first row
  lcd.print("Water Level:");  // Print the header
  lcd.setCursor(0, 1);  // Set the cursor to the first column of the second row
  lcd.print(waterLevel, 2);  // Print the water level in centimeter
  delay(1000);
}

Credits

pat
13 projects • 4 followers
AI Convergence Engineering, Software Engineering, ML, deep learning, image processing, computer vision, circuit design, and Edge AI devices.
Contact

Comments

Please log in or sign up to comment.