Water Level Sensor System

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

WATER LEVEL SENSOR SYSTEM

Abstract

This report presents a water level sensor system utilizing an Arduino Uno microcontroller board, an
ultrasound sensor, a buzzer for alarms, an LCD display for real-time information, and a relay to control a
water pump. The system is designed to monitor water levels and provide alerts when the water level
reaches critical points, ensuring efficient water management and preventing overflow or shortage
situations.

Introduction

Effective water level monitoring plays a crucial role in various applications, such as tanks, reservoirs, or
industrial processes. The purpose of this system is to provide accurate and real-time water level
information, trigger alarms for critical levels, and automate water pumping using an Arduino-based
solution.

Hardware Components

The water level sensor system consists of the following components:

a) Arduino Uno: The Arduino Uno microcontroller board serves as the brain of the system, processing
sensor data, controlling the display and buzzer, and managing the water pump through a relay.

b) Ultrasound Sensor: An ultrasound sensor, such as the HC-SR04, is used to measure the distance
between the sensor and the water surface. By calculating the time taken for the ultrasonic signal to
travel and return, the sensor provides accurate water level measurements.
c) Buzzer: The buzzer is employed to alert users when the water level reaches critical points. It emits
audible signals to indicate high or low water levels, prompting necessary actions.

d) LCD Display: A Liquid Crystal Display (LCD) module is used to present real-time information about the
water level. It can display the current water level, status messages, and alarms.

e) Relay: A relay is utilized to control the water pump. When the water level drops below a specific
threshold, the Arduino triggers the relay, activating the water pump to refill the tank or reservoir.

System Workflow

The system operates as follows:

• The ultrasound sensor continuously measures the distance to the water surface.

• The Arduino Uno reads the sensor data and calculates the corresponding water level.

• The LCD display shows the current water level, along with any status messages or alarms.

• If the water level exceeds predetermined upper or lower thresholds, the buzzer emits an alarm
sound.

• When the water level drops below a specific threshold, the Arduino activates the relay, turning
on the water pump to refill the tank or reservoir.

• The system continues monitoring and adjusting the water level until it reaches the desired level,
after which the water pump is turned off.

Flow Chart

Ultrasound sensor Alarm LCD

Pump Relay Arduino

Implementation and Programming

The Arduino Uno is programmed using the Arduino IDE. The programming code includes libraries for the
ultrasound sensor, LCD display, and buzzer. The code reads sensor data, performs necessary
calculations, displays information on the LCD, triggers alarms, and controls the relay to manage the
water pump.

The ultrasound sensor is connected to the Arduino Uno using digital input/output pins, and the readings
are obtained by measuring the time taken for the ultrasonic waves to travel to the water surface and
back.
The LCD display is connected to the Arduino Uno via digital input/output pins or using an I2C module,
depending on the specific LCD model. The Arduino code sends commands to the display to update the
water level information and display status messages.

The buzzer is connected to a digital output pin, and the Arduino code controls it by toggling the pin to
generate the desired

Circuit Diagram

Program
// INCLUDE NECESSARY LIBRARIES

#INCLUDE <LIQUIDCRYSTAL_I2C.H>

// CONSTANTS

CONST INT TRIGPIN = 2; // ULTRASOUND SENSOR TRIG PIN CONNECTED TO ARDUINO DIGITAL PIN 2

CONST INT ECHOPIN = 3; // ULTRASOUND SENSOR ECHO PIN CONNECTED TO ARDUINO DIGITAL PIN 3

CONST INT BUZZERPIN = 4; // BUZZER PIN CONNECTED TO ARDUINO DIGITAL PIN 4

CONST INT PUMPPIN = 5; // RELAY PIN CONNECTED TO ARDUINO DIGITAL PIN 5

// VARIABLES

LIQUIDCRYSTAL_I2C LCD(0X27, 16, 2); // INITIALIZE THE LCD OBJECT


VOID SETUP() {

// INITIALIZE SERIAL COMMUNICATION

SERIAL.BEGIN(9600);

// SET THE ULTRASOUND SENSOR PINS AS INPUT AND BUZZER AND RELAY PINS AS OUTPUT

PINMODE(TRIGPIN, OUTPUT);

PINMODE(ECHOPIN, INPUT);

PINMODE(BUZZERPIN, OUTPUT);

PINMODE(PUMPPIN, OUTPUT);

// INITIALIZE THE LCD

LCD.BEGIN(16, 2);

LCD.PRINT("WATER LEVEL:");

// TURN OFF THE WATER PUMP INITIALLY

DIGITALWRITE(PUMPPIN, LOW);

VOID LOOP() {

// MEASURE WATER LEVEL USING THE ULTRASOUND SENSOR

FLOAT DISTANCE = MEASUREDISTANCE();

// DISPLAY THE WATER LEVEL ON THE LCD

LCD.SETCURSOR(0, 1);

LCD.PRINT("LEVEL: " + STRING(DISTANCE) + " CM ");

// CHECK WATER LEVEL AND TRIGGER ALARMS IF NECESSARY

CHECKWATERLEVEL(DISTANCE);

// DELAY BETWEEN READINGS


DELAY(1000);

FLOAT MEASUREDISTANCE() {

// SEND ULTRASONIC PULSE

DIGITALWRITE(TRIGPIN, LOW);

DELAYMICROSECONDS(2);

DIGITALWRITE(TRIGPIN, HIGH);

DELAYMICROSECONDS(10);

DIGITALWRITE(TRIGPIN, LOW);

// READ THE ECHO DURATION

FLOAT DURATION = PULSEIN(ECHOPIN, HIGH);

// CALCULATE DISTANCE IN CENTIMETERS

FLOAT DISTANCE = DURATION * 0.034 / 2;

RETURN DISTANCE;

VOID CHECKWATERLEVEL(FLOAT DISTANCE) {

// DEFINE THE UPPER AND LOWER THRESHOLDS FOR WATER LEVEL

FLOAT UPPERTHRESHOLD = 20.0; // ADJUST THIS VALUE BASED ON YOUR SPECIFIC SETUP

FLOAT LOWERTHRESHOLD = 5.0; // ADJUST THIS VALUE BASED ON YOUR SPECIFIC SETUP

// CHECK IF THE WATER LEVEL IS ABOVE THE UPPER THRESHOLD

IF (DISTANCE > UPPERTHRESHOLD) {

DIGITALWRITE(BUZZERPIN, HIGH); // SOUND THE ALARM

// CHECK IF THE WATER LEVEL IS BELOW THE LOWER THRESHOLD

ELSE IF (DISTANCE < LOWERTHRESHOLD) {


DIGITALWRITE(BUZZERPIN, HIGH); // SOUND THE ALARM

DIGITALWRITE(PUMPPIN, HIGH); // TURN ON THE WATER PUMP

ELSE {

DIGITALWRITE(BUZZERPIN, LOW); // SILENCE THE ALARM

DIGITALWRITE(PUMPPIN, LOW); // TURN OFF THE WATER PUMP

CONCLUSION:

In conclusion, the water level sensor system utilizing an Arduino Uno, an ultrasound sensor, a buzzer for
alarms, an LCD display for real-time information, and a relay for water pump control offers an effective
solution for monitoring and managing water levels. The system provides accurate and timely water level
information, ensuring efficient water utilization and preventing overflow or shortage situations.

By using the ultrasound sensor to measure the distance between the sensor and the water surface, the
system can accurately calculate the water level. The LCD display presents real-time water level
information, allowing users to monitor the status at a glance. Additionally, the buzzer emits audible
alarms when the water level reaches critical points, alerting users to take necessary actions.

The integration of the relay enables the system to automate water pumping. When the water level
drops below a specific threshold, the Arduino triggers the relay, activating the water pump to refill the
tank or reservoir. This automation ensures a consistent water supply and eliminates the need for
manual intervention.

Through the combination of these components and the Arduino programming, the water level sensor
system provides a reliable and user-friendly solution for water management. It can be implemented in
various settings, such as domestic water tanks, agricultural irrigation systems, or industrial processes,
where accurate monitoring and control of water levels are essential.

However, it is important to note that the system presented in this report is a basic implementation.
Depending on the specific requirements of your application, you may need to further customize and
enhance the system. Considerations such as power management, calibration, data logging, and
additional safety features should be addressed to meet your specific needs.

In summary, the water level sensor system using an Arduino Uno and the aforementioned components
offers an accessible and cost-effective solution for water level monitoring and management. With
further refinement and customization, this system can be adapted to a wide range of water-related
applications, contributing to efficient water usage and resource conservation.

You might also like