0% found this document useful (0 votes)
23 views48 pages

Alen - For Merge k7

This document contains the table of contents for a project report on an automatic water level control system using an ultrasonic sensor. The table of contents lists 11 sections including an introduction, abstract, block diagram, major components, circuit diagram, program, conclusion, and references. It provides an overview of the project and outlines what will be described in each section of the report.

Uploaded by

parathce2023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views48 pages

Alen - For Merge k7

This document contains the table of contents for a project report on an automatic water level control system using an ultrasonic sensor. The table of contents lists 11 sections including an introduction, abstract, block diagram, major components, circuit diagram, program, conclusion, and references. It provides an overview of the project and outlines what will be described in each section of the report.

Uploaded by

parathce2023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 48

TABLE OF CONTENT

S.NO. DESCRIPTION PAGE NO.

1. INTRODUCTION 2

2. ABSTRACT 3

3. BLOCK DIAGRAM 4

4. MAJOR COMPONENTS 5

5. BLOCK DIAGRAM DESCRIPTION 5

6. CIRCUIT DIAGRAM 34

7. CIRCUIT DIAGRAM DESCRIPTION 35

8. PROGRAM 36

9. CONCLUSION 44

10. REFERENCE 44

11. PROJECT ESTIMATION 45

1
INTRODUCTION:

 One of the Major problems faced by most of the countries is the


issue of water of the country is the issue of water scarcity in the
world.
 The scarcity is mainly due to wastage of water.
 There is need to control the water wastage to save the
environment and water resources.
 We can also save the Electricity bill. By saving the electricity
bill the demand for the electricity can be reduced.
 So the Environmental pollution can be reduced.

ABSTRACT:

2
This project is an automatic process to detect, indicate and control the
level of water in overhead tank or any other storage containers using ultrasonic
sensor. The water level is maintained above a particular percentage which is
adjusted in the Arduino Code. The maximum level also can be adjusted in
Arduino Code.

The water level is maintained above a particular percentage which is


adjusted in the Arduino code. The maximum level also can be adjusted in Arduino
Code.

When the water level goes below the given minimum percentage the
pump starts running automatically. When the water level reaches the preset
maximum percentage, the pump stops automatically.

This project also has dry pump run protection, which turn off the
motor and the buzzer will notify that the sump is empty during motor running. The
motor will not start if the sump is empty.

A 20*4 LCD display is used to display the water level in percentage,


pump status, tank status and sump status.

BLOCK DIAGRAM:

3
4
MOTOR

ULTRASONIC
R
SENSOR

WATER LEVEL
SENSOR ARDUINO UNO

PUSH BUTTON
SWITCH 2
5VOLT POWER
SUPPLY

5
MAJOR COMPONENTS :
 Arduino Uno
 Ultrasonic Sensor
 Water Level Sensor
 Push Button Switch
 Relay Module
 Buzzer
 20*4 LCD Display
 Power Supply Unit.

ARDUINO UNO:

6
ARDUINO INTRODUCTION

 The Arduino Uno is an open-source microcontroller board based on the


Microchip AT mega 328Pmicrocontroller and developed by Arduino.cc.
 The board is equipped with sets of digital and analog input/output (I/O) pins
that may be interfaced to various expansion boards (shields) and other
circuits.
 The board has 14 digital I/O pins (six capable of PWM output) 6analogI/O
pins, and is programmable with the Arduino IDE (Integrated Development
Environment), via a type B USB cable. It can be powered by the USB cable

7
or by an external 9-volt battery, though it accepts voltages between7 and 20
volts.

ARDUINO POWER SUPPLY

 The Arduino Uno power supply can be done with the help of a USB cable
or an external power supply. The external power supplies mainly include AC
to DC adapter otherwise a battery. The adapter can be connected to the
Arduino Uno by plugging into the power jack of the Arduino board.
Similarly, the battery leads can be connected to the Vin pin and the GND pin
of the POWER connector. The suggested voltage range will be 7 volts to 12
volts.

ARDUINO INPUTS &OUTPUTS

8
 The 14 digital pins on the Arduino Uno can be used as input & output with
the help of the functions like pin Mode(), digital Write(), & Digital Read().

 Pin1 (TX) & Pin0 (RX) (Serial): This pin is used to transmit &
receive TTL serial data, and these are connected to the ATmega8U2 USB to
TTL Serial chip equivalent pins.

 Pin 2 & Pin 3 (External Interrupts): External pins can be connected


to activate an interrupt over a low value, change in value.

9
 Pins 3, 5, 6, 9, 10, & 11 (PWM): This pin gives 8-bit PWM o/p by the
function of analog Write ().

 SPI Pins (Pin-10 (SS), Pin-11 (MOSI), Pin-12 (MISO), Pin-13


(SCK): These pins maintain SPI-communication, even though offered by
the fundamental hardware, is not presently included within the Arduino
language.

 Pin-13(LED): The inbuilt LED can be connected to pin-13 (digital pin).


As the HIGH-value pin, the light emitting diode is activated, whenever the
pin is LOW.

 Pin-4 (SDA) & Pin-5 (SCL) (I2C): It supports TWI-communication


with the help of the Wire library.

 AREF (Reference Voltage): The reference voltage is for the analog


i/ps with analog Reference ().

 Reset Pin: This pin is used for reset (RST) the microcontroller

ARDUINO MEMORY

 The memory of this Atmega328 Arduino microcontroller includes flash


memory-32 KB for storing code, SRAM-2 KB EEPROM-1 KB.

ARDUNIOCOMMUNICATION

10
 The Arduino Uno ATmega328 offers UART TTL-serial communication,
and it is accessible on digital pins like TX (1) and RX (0). The software of
an Arduino has a serial monitor that permits easy data. There are two LEDs
on the board like RX & TX which will blink whenever data is being
broadcasted through the USB.

 A Software Serial library permits for serial communication on Arduino Uno


digital pins and the ATmega328P supports TWI (I2C) as well as SPI-
communication. The Arduino software contains a wired library for
simplifying the utilization of the I2C bus.

APPLICATIONS OF ARDUINO

 The applications of Arduino Uno include the following.

 Arduino Uno is used in Do-it-Yourself projects prototyping.

 In developing projects based on code-based control

 Development of Automation System.

 Designing of basic circuit designs.

ULTRASONIC SENSOR:

11
The ultrasonic sensor is an electronic device used to measure
distances. Because, measuring distance is an essential factor in many applications
such as robotic control, vehicle detection etc. Sensors such as optical and sound
are the most helpful

Ultrasonic sensors are used as proximity sensors. They can be found


in parking technology and anti-collision safety systems. Ultrasonic sensors are
also used in robotic obstacle detection systems and manufacturing engineering.
Compared to infrared sensors in proximity sensing applications, ultrasonic sensors
are less susceptible to interference from smoke, gases and other airborne particles.

Ultrasonic sensors are also used as level sensors to detect, monitor and
control liquid levels in closed vessels. Most notably, ultrasound technology has
enabled the medical industry to image internal organs, identify tumours, and ensure
the health of babies in the womb.

The principle of ultrasonic rangefinders is to measure the time it takes


the signal sent by a transmitter and propagated back to the receiver. As the name

12
implies ultrasonic sensor operates on ultrasonic frequencies. Those frequencies are
above 20k Hertz.

They are the all-rounder’s of sensor technology and can be used in


any industrial application. There are several types of objects that can be detected,
including solids, liquids, granules, and powder. They reliably detect transparent or
glossy objects, as well as objects whose colors change.

An ultrasonic sensor is an electronic device that measures the distance


to an object by emitting ultrasonic wave and converting the reflected sound into
electrical signals. Ultrasound travels faster than audible sound. An ultrasonic
sensor consists of two main components: a transmitter and a receiver.

While some sensors use separate sound emitters and receivers, it is


also feasible to merge both functions into a single device by using an ultrasonic
element to switch between sending and receiving signals in a continuous cycle.
The transmitter of the module transmits an ultrasonic sound. This sound will be
reflected if an object is present in front of the ultrasonic sensor. The reflected

13
sound is received by the receiver present in the same module. An ultrasonic signal
is propagated by a wave at an angle of 30 o. The above-depicted figure illustrates
how the ultrasonic signal propagates from the transmitter. Measuring angle should
be at least 15ofor maximum accuracy. In this case, distance to the desired object.

The distance is determined by measuring the travel time of ultrasonic


sound and its speed.

Distance=Time x Speed of sound/2

Reflection of the sensing sound varies with configuration, for example

(A) Flat objects: Liquid, box, Plastic sheet,


(B) Columnar objects: Can, Bottle, the human body,
(C) Granular objects: Ores, Rock, Coal, Coke, Plastic pellet,

To generate the ultrasonic sound, need to trigger the trigger pin as


high for a minimum of 10us. Then the module will start sending 8 sonic
burst ultrasounds from the module at 40Khz. It will receive by the receiver
called Echo pin and it will calculate the output time to measure the distance.

14
To prevent mutual interference between Ultrasonic Sensors, the
synchronous operation can be used by emitting the ultrasonic waves from
each sensors simultaneously.

SPECIFICATIONS:

 Supply voltage +5V


15
 Consumption in silent mode 2 mA
 Consumption at work of 15 mA
 Measurement range 2 to 400cm
 Effective measuring angle 15o
 The dimensions are 45 x 20 x 15 mm.

WATER LEVEL SENSOR:

The water level sensor has a very simple schematic which makes it
up but despite which is rather very interesting to learn, let’s learn further.
The water level sensor is a widely used sensor. you can see this sensor in the
water level detector and many other places. water level sensors can be used in our
daily life usable things.

Water Level Sensor Construction

16
 Above is the schematic of the water level sensor, which I have drawn myself
from a sensor lying around as always. The schematic seems to be quite easy
and simple.
 It consists of only a S8050 SMD transistor, which is an NPN transistor. For
it’s better understanding of it’s working and type of output, visit projects
based on it.
 As in the Soil Moisture sensor article, I have clearly mentioned that due to
long time exposure of sensing area of the sensor, it accumulates a layer of
salt. Similarly, in this also it accumulates a layer of salt so clear the layer
timely for proper reading.
 One of the major drawback of this sensor is that due to its very simple
schematic it’s value cannot be controlled also the signal cannot be boosted
or compared as in other sensors.

How does the Water Level Sensor Works?

 The working of this sensor is similar to its schematic, very simple and easy
to understand. As in the above circuit diagram, you can see that the sensing
area is marked with blue lines.

17
 The S8050 sensor works as a switch in this sensor. The base of the transistor
is connected to the one series of lines of the sensing area.
 The other series is connected to the emitter of the transistor with 1 kΩ
resistor in series. The emitter is connected to GND and Signal pin via a
100 Ω resistor in series.
 The collector pin of the transistor is connected to the VCC of the sensor. The
onboard status LED is also connected to the emitter pi of the sensor with
1 kΩ resistor in series.

Application of water level sensor

 Water level detection in the water tank to measure the level of the water
inside the tank.
 we can use this sensor in the air cooler to prevent the overflow and less
amount problem
 we can use this sensor into the lead-acid battery to measure the level of
acidic water inside the battery
 we can use this awesome sensor into the irrigation in the rural area also we
can monitor the level of the water.
 we can use this water level sensor to measure the water inside the RO
machine of water.

Advantages & Disadvantages

Advantages:

 The main advantage is the simplicity of the sensor that a beginner can also
use it easily and easily to build schematic even on a piece of PerfBoard.
 The working voltage level has an input of 40V, which covers all the popular
Development board and microcontrollers.
 The sensor can also be built on the large scale as required by the user, as the
schematic is so simple and requires only few active and passive components.
 With the help of mounting holes, you can easily mount the sensor anywhere
of the surface or custom-built the PCB for the same.
 More advanced version and different types of water level sensor are also
available which works differently, but the output is same.

Disadvantages:

18
 The main disadvantage of the sensor is the single type of OUTPUT it gives.
The sensor should be modified to give the ANALOG value of the water
level with respect to physical water level, which is much more useful than
DIGITAL values.
 Open traces on the sensor PCB for the sensing of the water is not galvanized,
as a result it deposits a layer of salt over then over a period of continuous use
or time.
 There is no such way to control the logic level of the OUTPUT signal as it
depends on the input voltage, so it needs to be connected with the
microcontroller power pins.

PUSHBUTTON

PUSHBUTTON DESCRIPTIONS
 A push switch (button) is a momentary or non-latching switch which causes
a temporary change in the state of an electrical circuit only while the switch
is physically actuated. An automatic mechanism (i.e. a spring) returns the

19
switch to its default position immediately afterwards, restoring the initial
circuit condition.
 A 'push to make' switch allows electricity to flow between its two contacts
when held in. When the button is released, the circuit is broken. This type of
switch is also known as a Normally Open (NO) Switch. (Examples:
doorbell, computer case power switch, calculator buttons, individual keys on
a keyboard)
 A 'push to break' switch does the opposite, i.e. when the button is not
pressed, electricity can flow, but when it is pressed the circuit is broken.
This type of switch is also known as a Normally Closed (NC) Switch.
(Examples: Fridge Light Switch, Alarm Switches in Fail-Safe circuits)
 Many Push switches are designed to function as both 'push to make' and
'push to break' switches. For these switches, the wiring of the switch
determines whether the switch functions as a 'push to make' or as a 'push to
break' switch.

RELAY MODULE:

20
Relay modules are simply circuit boards that house one or more relays.
They come in a variety of shapes and sizes, but are most commonly
rectangular with 2, 4, or 8 relays mounted on them, sometimes even up
to a 16 relays.
Relay modules contain other components than the relay unit. These
include indicator LEDs, protection diodes, transistors, resistors, and
other parts. But what is the module relay, which makes the bulk of the
device? You may ask. Here are facts to note about it:

 A relay is an electrical switch that can be used to control devices


and systems that use higher voltages. In the case of module relay,
the mechanism is typically an electromagnet.
 The relay module input voltage is usually DC. However, the
electrical load that a relay will control can be either AC or DC, but
essentially within the limit levels that the relay is designed for.

21
 A relay module is available in an array of input voltage ratings: It
can be a 3.2V or 5V relay module for low power switching, or it
can be a 12 or 24V relay module for heavy-duty systems.
 The relay module information is normally printed on the surface of
the device for ready reference. This includes the input voltage
rating, switch voltage, and current limit.

Relay Module Function

What does a relay module do? The relay module function is mainly to
switch electrical devices and systems on or off. It also serves to isolate
the control circuit from the device or system being controlled.
This is important because it allows you the use a microcontroller or
other low-power device to control devices with much higher voltages
and currents.
Another relay module purpose is to amplify the control signal so that it
can switch the higher currents using only a small out of power from
a microcontroller.

Relay Module vs. Relay

It is also important to note the difference between a relay vs. relay


module. A relay is a single device that has an electromagnet and a
switch, or it can be the solid-state type.
A relay module, on the other hand, is a board that has one or multiple
relays on it and several other components to provide isolation and
protection.
Because of its modular construction, this type of switching and control
device can be many different configurations. It can be a single-channel
relay module for a single load or it can be a multi-channel device with
multiple relays to control several circuits.

22
Relay Module Working

How does a relay module work? The relay module working principle is
actually quite simple. It uses an electromagnet to open and close a set of
electrical contacts. Here is the sequential working of relay module
devices for easier understanding:

 The typical relay module connection points include an input side


that consists of 3 or 4 jumper pins, and an output side that has 3
screw terminals.
 When the control signal is applied to the input side of the relay,
it activates the electromagnet, which attracts an armature.

23
 This in turn closes the switch contacts on the output (high voltage)
side, allowing electricity to flow and power the device or system
that is connected to it.
 To prevent flyback voltage from damaging the relay module circuit
and the input device, a diode is often placed in parallel with the
electromagnet coil. This diode is known as a flyback diode. It
allows current to flow in only one direction.
 When a higher level of isolation is required, an optocoupler is
used. An opto-isolated relay module has the photoelectric device
on the input side, which is used to control the electromagnet’s
switching action.

Relay modules are available with either normally open (NO) or normally
closed (NC) switch configurations.

 A NO switch is open when the electromagnet is not activated, and


closed when it is activated.
 An NC relay switch, on the other hand, remains closed by default,
and only opens when the relay is activated.

BUZZER DESCRIPTION:

24
 An audio signaling device like a beeper or buzzer may be electromechanical
or piezoelectric or mechanical type.
 The main function of this is to convert the signal from audio to sound.
Generally, it is powered through DC voltage and used in timers, alarm
devices, printers, alarms, computers, etc.
 Based on the various designs, it can generate different sounds like alarm,
music, bell & siren.
 It includes two pins namely positive and negative.

25
 The positive terminal of this is represented with the ‘+’ symbol or a longer
terminal.
 This terminal is powered through 6Volts whereas the negative terminal is
represented with the ‘-‘symbol or short terminal and it is connected to the
GND terminal.

BUZZER SPECIFICATIONS
The specifications of the buzzer include the following.
 Color is black
 The frequency range is 3,300Hz
 Operating Temperature ranges from – 20° C to +60°C
 Operating voltage ranges from 3V to 24V DC
 The sound pressure level is 85dBA or 10cm
 The supply current is below 15mA

26
POWER SUPPLY UNIT

First, we are using a step-down transformer [Secondary rating 12Volt & 1 Amp]
step down 230V AC supply to 12-Volt AC. Then we rectify the 12V AC to 12 V
DC using a diode bridge rectifier [Full wave rectifier]. After the rectifier, we have
used Capacitors to filter the ripple from the circuit and fed it to the input of the
7812 voltage regulator. 7812 regulates the 12 volt DC to 12 Volt DC and at the
output of 7812 IC, we get constant 12 Volt DC output.

TRANSFORMER
A step down transformer will step down the voltage from the ac mains to the
required voltage level. The turn’s ratio of the transformer is so adjusted such as to
obtain the required voltage value. The output of the transformer is given as an
input to the rectifier circuit.

27
RECTIFICATION
Rectifier is an electronic circuit consisting of diodes which carries out the
rectification process. Rectification is the process of converting an alternating
voltage or current into corresponding direct (DC) quantity. The input to a rectifier
is AC whereas its output is unidirectional pulsating DC. A full wave rectifier or a
bridge rectifier is used to rectify both the half cycles of the ac supply (full wave
rectification). The figure shows a full wave bridge rectifier.
SMOOTHING

In a power supply, whether it is a linear power supply or a switch mode power


supply using an AC power source and diode rectifiers, the raw rectified output is
normally smoothed using a reservoir capacitor before being applied to any
regulators or other similar electronic circuitry.

REGULATION
This is the last block in a regulated DC power supply. The output voltage or
current will change or fluctuate when there is a change in the input from ac mains
or due to change in load current at the output of the regulated power supply or due
to other factors like temperature changes. This problem can be eliminated by using
a regulator. A regulator will maintain the output constant even when changes at the
input or any other changes occur. IC 7812 is used to obtained fixed values of

voltages at the output.

28
20*4 LCD DISPLAY:

 In a 20x4 LCD module, there are four rows in display and in one row twenty
character can be displayed and in one display eighty characters can be shown.

 This liquid crystal module uses HDD44780 (It is a controller used to


display monochrome text displays) parallel interfacing.

 The liquid crystal display interfacing code is easily accessible. We just required
eleven input and output pinouts for the interfacing of the LCD screen.

 The input supply for this module is three volts or five volts, with that module other
components like PIC, Raspberry PI, Arduino.

 Thie electronic device can be used in different embedded systems, industries,


medical devices, and portable devices like mobile, watches, laptops.

 Liquid crystal display works on two types of the signal first one is data and the
second one is for control.

 The existence of these signals can be identified through the on and off condition of
RS pinout. Data can be read by pushing the Read/write pinout.

29
20x4 LCD Pinout

 These are some pinouts of 20x4 LCD modules that are described here with the
detailed.

Pin Pin
No: Name: Parameters

It It is ground pinout
Pin#
denoted potential at this pinout is
1
as Vss zero.

It
Pin# At this pinout, five volts
denoted
2 are provided.
as Vdd

Pin# This This pinout is used to set

30
pinout
3 denoted the contrast of the screen.
as Vo

This
Pin# pin It used to H/L register
4 denoted select signal.
as RS

It
Pin# It used for H/L read/write
denoted
5 signal.
as R/W

This
Pin# pinout It used for H/L enable
6 denoted signal.
as E

The
pinouts
from
seven
Pin# to It used for H/L data bus
7-14 fourtee for 4 bit or 8-bit mode.
n
denoted
as DB0
– DB7.

31
It
Pin# identifi It used to set backlight
15 ed as A anode.
(LED+)

It
recogni
Pin# zed as It used to set backlight
16 K cathode.
(LED-)
.

Features of 20 x 4 LCD

 These are some features of 20 x 4 LCD modules that are described here with the
detailed.

32
 The most important feature of this module is that it can display 80 characters at a
time.

 The cursor of this module has 5x8 (40) dots.

 On this module already assembled the controller of RW1063.

 This module operates on the plus five volts input supply and can also work on the
plus three volts.

 The plus three volts pinout can also be used for the negative supply.

 The duty cycle of this module is one by sixteen (1/16).

 The light-emitting diode of this module can get supply from the pinout one, pinout
two, pinout fifteen, pinout sixteen, or pinout A and K.

Electrical Characteristics of 20 x 4 LCD

 These are some pinouts of 20 x 4 LCD modules that are described here with the
detailed.

Symb
Parameters
ol Conditions

It
Input denote The value of VDD is
Voltage d as plus five volts.
VDD

33
It
Supply denote Its value is ten
Current d as milliamperes.
IDD

LC Driving
Its
Voltage for
symbol
Normal
is Its value is 5.2 volts
Temperatu
VDD
re Version
to V0.
Module

It is
LED
denote
Forward Its value is 4.3V
d as
Voltage
VF.

LED It
Forward denote Its value is 4.6V.
Current d as IF.

This
pinout VEL = 110 VAC,
EL Supply
denote and four hundred
Current
d as frequency.
EL

34
Absolute Maximum Ratings

 Now we discuss the maximum ratings of 20 x 4 LCD.

Symb
Parameters
ol Conditions

It
Working Its value is zero to a
denote
temperatur plus fifty-celsius
d as
e degree.
Top

It
Storage Its value minus
denote
Temperatu twenty Celsius to
d as
re plus seventy celsius.
Tst.

It Its minimum value


Supply
denote Vss and the
Voltage for
d as maximum value is
Logic
Vi. equal to Vdd volts.

Supply It
Voltage for denote Its value is three
liquid d as volts to thirteen
crystal Vdd or volts.
display Vss.

35
CIRCUIT DIAGRAM:

36
CIRCUIT DIAGRAM DESCRIPTION:

37
This project contains Arduino UNO, HCSR 04 Ultrasonic sensor,
Push Button, Water level Sensor, 20*4 LCD Display, Buzzer, and a Relay module.

The +5 V and GND is given to the Arduino UNO. The VCC of


Ultrasonic sensors connected to +5 V and the GND is connected to the GND. The
Echo pin of ultrasonic sensor is connected to the 7 th pin of Arduino. The Trigger
pin is connected to the 6th pin of the Arduino.

The positive pin of Buzzer is connected to the 9 th pin of Arduino


the Negative pin is connected with the GND. The one pin of the Push Button is
connected to the 10th pin of the Arduino. The another pin is connected to the GND.

The VCC of the water level sensor is connected to +5V and the
GND is connected to the GND. The ‘S’ Pin is connected to ht ‘A 0 ‘ the analog
input of the Arduino.

The VCC is connected to the +5V and the GND pin is connected
to the GND of both LCD and Relay Module.

The Vin of the Relay module is connected to 8 th pin of the


Arduino. The SDA pin of the LCD is connected to the A 4 Analog input of the
Arduino. The SCL pin of LCD is connected to the A 5 Analog input of the
Arduino.

For VCC and GND a Common line is kept in the Bread Board
and Taken from the Bread Board and given to the each components.

PROGRAM:

#include <NewPing.h>
38
// include the library code:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars
and 2 line display
#include <NewPing.h> // Include library used for measuring the distance using
HC-SR 06 sonar sensor
#define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic
sensor.
#define ECHO_PIN 7 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 500 // Maximum distance we want to ping for (in
centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing
setup of pins and maximum distance.
#define MOTORPIN 8 // Arduino pin tied to Relaypin of the Relay Circuit
//#define EXTRELAYPIN 13 // Arduino pin tied to vin pin of the External Relay
Circuit
#define BUZZER 9 // Arduino pin tied to +ve terminal of the Buzzer

float val;

#include <EEPROM.h>
int addr = 0;
int addr2 = 1;
int flag;
byte readval;

#define buttonPin 12
int buttonState = LOW; // variable for reading the pushbutton status

float TankHeight, WaterLevelMAX, GapbwSonar, SonarReading, ActualReading,


Temp;

39
int percentage;
int DRYSensorPin = A0; // set A0 as the Spump water sensor pin
int DRYsensorValue = 0; // variable to store the value coming from the sensor

void setup() {

Serial.begin(9600);
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.begin(20, 4); // set up the LCD's number of columns and rows:

pinMode(MOTORPIN,OUTPUT);// Relay pin as output pin


// pinMode(EXTRELAYPIN,OUTPUT);// External Relay pin as output pin
digitalWrite(MOTORPIN,LOW); //Turn off the relay
// digitalWrite(EXTRELAYPIN,HIGH); //Turn off the external relay(External
Relay I used was turning on while giving LOW signal, Check your one while
doing the program)
pinMode(BUZZER,OUTPUT);// Buzzer pin as output pin
digitalWrite(BUZZER,LOW); //Turn off the Buzzer

lcd.setCursor(0,0);
lcd.print("SMART WATER LEVEL ");
lcd.setCursor(0,1);
lcd.print("CONTROL SYSTEM ");
lcd.setCursor(0,2);
lcd.print("USING ULTRASONIC ");
lcd.setCursor(0,3);
lcd.print("SENSOR ");
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Starting ARDUINO, ");
lcd.setCursor(0,1);
40
lcd.print("Press SCAN Button to");
lcd.setCursor(0,2);
lcd.print("Change Tank Height ");
lcd.setCursor(0,3);
lcd.print("If Required ");
delay(4000);

// delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Confirm Tank Must be");
lcd.setCursor(0,1);
lcd.print("Empty To Set Tank ");
lcd.setCursor(0,2);
lcd.print("Height using Sonar ");
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Now Scan to Change ");
lcd.setCursor(0,1);
lcd.print("Tank Height to New ");
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Long Press Button...");
for (int i=0; i<=5; i++)

{
lcd.setCursor(0,1);
lcd.print(" Hold : ");
lcd.print(5-i);
lcd.print(" Seconds ");
buttonState = digitalRead(buttonPin);
41
if (buttonState == LOW)
{
TankHeight =sonar.ping_cm();
EEPROM.write(addr, TankHeight);
}
delay(1000);
}

{TankHeight= EEPROM.read(addr);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Tank New Height Set@");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.print(TankHeight);
lcd.print("cm ");
lcd.setCursor(0,2);
lcd.print("Cheers ");
lcd.setCursor(0,3);
lcd.print("WELCOME ");

delay(2000);
lcd.clear();
lcd.setCursor(0,2);
lcd.print("TANK HEIGHT: ");
//lcd.print("cm ");
lcd.setCursor(12,2);
lcd.print(TankHeight);
lcd.print("cm ");

//WaterLevelMAX=0.9*TankHeight; // 10CM GAP BETWEEN MAX WATER


LEVEL TO SONAR FIX
WaterLevelMAX= TankHeight-5;
GapbwSonar=TankHeight-WaterLevelMAX;}
42
}
void loop() {

// put your main code here, to run repeatedly:

delay(50); // Wait 100ms between pings (about 20 pings/sec). 29ms should be the
shortest delay between pings.
SonarReading=sonar.ping_cm();
DRYsensorValue=analogRead(DRYSensorPin);

//Serial.println(DRYsensorValue);

Temp= SonarReading-GapbwSonar;
ActualReading= WaterLevelMAX-Temp;
percentage=(ActualReading/WaterLevelMAX*100);
Serial.println(percentage);
//Serial.println(TankHeight);
lcd.setCursor(0,0);
lcd.print("WATER LEVEL:");
lcd.print(percentage);
lcd.print("% ");
if(DRYsensorValue>=100)

if(percentage<=20)

{
lcd.setCursor(0,3);
lcd.print("SUMP: WATER FILLED ");
lcd.setCursor(0,1);

43
lcd.print("PUMP STATUS: RUNNING");
digitalWrite(MOTORPIN,HIGH);
// digitalWrite(EXTRELAYPIN,LOW);
flag=1;
EEPROM.write(addr2, flag);
flag= EEPROM.read(addr2);

// ZeroPercentage();

else if(percentage>20 && percentage<=100)

flag= EEPROM.read(addr2);
if(percentage>20 && percentage<=100 && flag ==1)

{
digitalWrite(MOTORPIN,HIGH);
// digitalWrite(EXTRELAYPIN,LOW);
lcd.setCursor(0,1);
lcd.print("PUMP STATUS: RUNNING");
}

else if(percentage>20 && percentage<=100 && flag ==0)

{
digitalWrite(MOTORPIN,LOW);
// digitalWrite(EXTRELAYPIN,HIGH);
lcd.setCursor(0,1);
lcd.print("PUMP STATUS: OFF ");

}
44
}

else if(percentage>100)

delay(500);
lcd.setCursor(0,1);
lcd.print("PUMP STATUS: OFF ");
lcd.setCursor(0,0);
lcd.print("Water Level:");
lcd.print("100");
lcd.print("% ");
digitalWrite(MOTORPIN,LOW);
// digitalWrite(EXTRELAYPIN,HIGH);

flag=0;

EEPROM.write(addr2, flag);
flag= EEPROM.read(addr2);

// HundredPercentage();

else if(DRYsensorValue<=100)

flag= EEPROM.read(addr2);
if(flag==1)
45
{
// lcd.clear();
lcd.setCursor(0,3);
lcd.print("SUMP: WATER FILLED ");
lcd.setCursor(0,1);
lcd.print("PUMP STATUS: DRYRUN!");
digitalWrite(BUZZER,HIGH);
digitalWrite(MOTORPIN, LOW);
// digitalWrite(EXTRELAYPIN, HIGH);
delay(100);
digitalWrite(BUZZER,LOW);
delay(100);
}

else if(flag==0)

{
lcd.setCursor(0,3);
lcd.print("SUMP: NOWATER/CHECK");
}
}

CONCUSION:

46
The designed prototype system has been successfully tested and
verified and the results obtained ensured that the control system designed is
capable three distinct advantages:

1. Efficient utilization of electrical energy.


2. Device/Pump protection by preventing the dry Run
3. Non wastage of Water.

This Whole prototype system will be made out of inexpensive


components and will be cheap to make. Low powered components in this system
will use a very minimal amount of power to run and save electricity. The
automation system will reduce the everyday hassle of the user. The entire system
is designed for a dc motor based pump. It can be designed for an ac motor based
pump with proper driver circuit.

REFERENCE:

 www.create.Arduino.cc
 www.DIY.com
 www. Engineeringprojects.com
 Last minute engineering.com

ESTIMATION:

47
S.NO. DESCRIPTION AMOUNT

1. ARDUINO UNO 900

2. ULTRASONIC SENSOR 150

3. BUZZER 50

4. POWER SUPPLY UNIT 700

5. BOARD AND ETC 3000

6. JUMPER WIRES 300

7. SERVO MOTOR 200

8. PROJECT REPORT 1200

9. MISCELLANEOUS 500

TOTAL 7000

48

You might also like