0% found this document useful (0 votes)
14 views54 pages

Adjusted Project

Final year Project on liquid level monitoring

Uploaded by

Ovo Jacob
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)
14 views54 pages

Adjusted Project

Final year Project on liquid level monitoring

Uploaded by

Ovo Jacob
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/ 54

CHAPTER ONE

INTRODUCTION

1.0 BACKGROUD WORK


It is necessary and important to have knowledge of the level of liquids in any storage medium
from time to time. This storage medium could be tanks, well, reservoir, drums etc. The
information gotten is very useful both for economical, planning and managing purposes. It
would enable the user of the liquid to have prior knowledge of liquid left and make necessary
arrangements to top up the liquid, also the user can know on time without being taken
unawares as to when the liquid would get finished. Hence unnecessary dry-out, uneconomical
usage, inadequate preparation would be avoided this is beneficial whether for organization,
company or individual users of the liquid.

Over the years variety of means have been used or employed for the measurement of liquid
level. As far back as ancient civilization of Egypt where crude methods where used down to
the middle ages. These times where before the advent of modern science and technology and
majority of the method employed was crude. Instrument where dipped into liquids, these
instruments contains marks which determine the measurement on the liquid level.

As science and technology emerged, the method of liquid measurement evolved. Liquid
measurement method evolved from the use of crude instrument to the use of sophisticated
device. These measurement methods, could be broadly classified into sensor based and non-
sensor based. Sensor based measurement method have the advantage that they can measure
the volume of the liquid, without having direct contact with the liquid. Hence the device
would not corrode or develop some fault easily. Also, over the years due to the advent of
science and technology and the concept called internet of things (IOT) (which describes
physical objects that are embedded with sensors, processing ability, software, and other
technologies, and that connect and exchange data with other devices and systems over the
internet or other communications networks). It has become very easy to get information about
certain physical element from a remote location enabling relevant data to be collected and
used for different purpose. Hence it has become possible to get data about water humidity,
water ph, soil texture, e.t.c from a remote location. Employing such technologies in the
measurement of liquid level has become imperative, to ensure effective management of
liquids and not continue with the crude methods.

1
Therefore, a remote diesel management system can be developed which could make use of
this technologies to ensure that there is effective management of the diesel.

1.1 PROBLEM STATEMENT

Monitoring of liquid levels in fuel tanks for generators, which are used majorly in developing
countries as alternative source of power is usually done by physically monitoring the liquid
level. This physical monitoring involves the person in charge, whether technician, supervisor
going to the location or place where the generator and tank is stationed and then open the
tank to see the level of the liquid or probably use a dipstick inserted into the tank to take
measurement of liquid level. Also when the generators is not working there is possibility that
there is a fuel leakage or fuel theft which would reduce the level of fuel in the tank. But due
to the method employed in monitoring the liquid level in the fuel tank these leakages and
theft cannot be accounted for. The person monitoring the liquid might make incorrect
assumptions and conclusions. This would affect finances committed to the purchases of fuel.
Also, the planning and management of the fuel would be affected. So whether it is a private
or public firm or organization these losses cannot be accounted for hence mismanagement.

Therefore there is a need for the development of an efficient remote monitoring system.
Where the level of the liquid in the tank can be monitored from anywhere without necessarily
going to the location of the tank. And this monitoring could be taken from time to time. Also
the information gotten from this timely remote monitoring system can be used to detect
whether there is a leakage or fuel theft by logging the information retrieved at interval. This
provides a means of calculating the volume of fuel consumed over a period of time.
Therefore knowing the volume of fuel/diesel consumed over a period helps in managerial
decisions as the data can be analyzed.

1.2 SCOPE OF STUDY


This project covers the design and construction of a linear power system which supplies a
regulated voltage of 5V and current of 0.5A, and also the use of SMPS (Switch mode power
supply) which supplies voltage of 5V and current of 2A.

A control system is also designed and constructed. The control system designed is the PIC
microcontroller PIC18F45K22. This acts as the central processing unit of the system.

2
A communication system, using 2g communication technologies was built using the SIM
800L GPRS/GSM module. This enables communication with the internet and the
microcontroller.

Inorder to get the relevant data about the level and hence volume of the diesel the ultrasonic
sensor SONAR 1 was used. A web application was also developed which could display; data
on a computer and mobile phone.

1.3 AIM AND OBJECTIVES

1.3.1 AIM

The aim of this project work is to design and construct a remote sensing system for fuel and
diesel application.

1.3.2 OBJECTIVES

 To develop a power unit


 To model Generator off and on status with power supply circuit
 To develop a control system
 To develop a simple communication system
 To develop a web application with easy to use interface

1.3.3 METHODOLOGY

To develop the power unit, the portability of the system was taken into consideration. Inorder
to avoid the use of very large transformers, two separate power supplies were used to supply
power to the circuit which is; a linear power supply supplying voltage of 5v and current of
0.5A and an SMPS (switch mode power supply) supplying voltage of 5V and current of 2A.
The GSM module which is the communication medium takes the highest power of 2A, the
linear power is not able to supply this hence the separate power that would deliver such
current without compromising the portability of the system is used, which is the (SMPS)
switch mode power supply mentioned.

In order to model the generator status, a switch is attached to the power supply and is passed
through an ADC (analog to digital converter) circuit to the microcontroller. When the switch
buttons is closed, the switch circuit is closed, and hence signal is sent to the microcontroller.
The microcontroller senses this signal as voltage and an led light indicator displays showing

3
the Gen is turned on. When the switch button is turned off, the circuit is opened hence signal
is no longer sent to the microcontroller, hence the led light turns off showing that generator is
turned off.

For the development of a control system the PIC microcontroller is used. The PIC
microcontroller PIC (PIC18F4522), coordinates the entire system like enabling the GSM
module to communicate with the web application inorder that the data gotten from volume
measurement is displayed on a mobile device or computer device in a remote location from
the diesel tank. This data is gotten from ultrasonic sensor’s measurement of the height of the
diesel. The ultrasonic sensor has a transmitter and receiver connected to microcontroller. The
receiver is what receives the height sensed by the sensor then the transmitter transmit the data
via GSM module to web app. Also when the gen is turned on, a tap connected to the base of
the tank which is modelled using a bucket is turned on to show that volume of diesel is
leaving the tank. To also show that volume of diesel is leaving the tank, as gen is turned off,
the gen switch is turned off and the tap is turned off then a bowl or bottle is used to remove
the diesel from the bucket (tank) .The PIC microcontroller, also communicates with the GSM
module.

In the development of the communication system, the GSM module (SIM 800L) which is a
2g communication system is used. It is attached to the microcontroller port via a GSM
connector. A mobile sim is placed in the module which ensures that it can communicate with
the web application via a webserver the GSM module gets the volume from the sensor, then
sends to a webserver which stores it, and is retrieved by an authorized user of the web
application.

4
CHAPTER TWO

LITRETURE REVIEW

2.0 AN OVERVIEW OF LIQUID MEASUREMENT METHOD


Liquid level measurement is an important aspect when it comes to monitoring the volume of
a liquid contained in a tank or a storage vessel. Liquid level measurement entails calculating
the height of liquid in a tank, either at discrete levels (different points) or at continuous level
(real time). Discrete liquid level measurement involves using sensors alongside metal probes,
which are placed at different positions such as 20%, 40%, 60%, 80% and 100% to detect the
level of liquid at a particular point or the metal probes could be placed in such a way that it
detects the level of liquid when the liquid is not available, when the liquid is at the middle
level or when the liquid is full [Ahmed et al, 2015]. While continuous liquid level
measurement involves the use of evanescent wave interaction by using D-shaped optical fiber
[Antonio-Lopez et al, 2011] or the use of microcontroller interfaced with either an ultrasonic
sensor or etape sensor.

Also internet of things concept has made possible the connectivity between certain things and
the internet with this, useful information can be gotten which could help in the study of what
is measured [Ahmed et all 2017]. The goal of the internet of things is to enable things to be
connected anytime, anyplace, with anything and anyone ideally using path/network and any
service [Vermesen, 2013]. Hence it has become possible to collect data about the volume of
liquid measured and store the data to be retrieved real time over the internet. And such
information could be viewed on a mobile application.

5
2.1 DIFFERENT TECHNIQUES FOR MEASURING THE LEVEL OF LIQUID
There are different techniques for measuring the level of liquid in a tank or storage vessel
such as the optical method, mechanical method and electrical method [Antonio-Lopez et al,
2011]. Optical method involves the use of fiber optics level sensors based on multimode
interference(MMI) that can be used for either discrete or continuous liquid level measurement
[Antonio-Lopez et al, 2011], but the it increases the complexity of the system . The
mechanical method involves the use of floats, sight gauges, dip sticks and dip rod, weighted
gauge tape, etc to measure the liquid level in a tank or storage vessel, but it increases the
weight of the design and it has a sluggish response. The electrical method involves the use of
ultrasonic sensors, capacitive sensors, microcontrollers, etc to measure liquid level, but it is
not suitable for liquids that are flammable, corrosive or conductive. For this project, electrical
method is employed because it has a faster response and it is easy to design.

[Ahmed et al, 2015], discussed solving the problem of water wasted by full tank. They
employed the method of monitoring the level of water with the aid of a peripheral interface
controller (PIC) interfaced with bilateral switches to indicate the water level through LCD
display. This method discussed, show how the water level is monitored overtime, when water
is not available, when water is at the intermediate level and when the tank is full of water
[Ahmed et al, 2015]. This relates to this project due to the fact that the level of liquid is
measured, but the measurement is done in discrete form which is not suitable for this project
and it also doesn.t provide data about the amount of liquid put into the tank and the amount of
liquid used.

In the journal, fuel monitoring system by [Rajesh et all, 2019], a unique way of measuring the
level of the diesel in the tank using smart device was designed. The objective of the project
was to describe the automatic prevention of fuel theft by the drivers and also able to know
how accurately the petrol bank is filling the fuel for the vehicles. Whenever the liquid level
goes high or low, it will be indicated by an alarm signal. When the flow rate or fuel
consumption rate becomes more than usual the fuel level drops drastically the sensor is
actuated and sends a signal. After receiving the signal, the GSM module sends a message to a
specific number by indicating something unusual has happened.

[Saraswati et al, 2012] also talked about the design and construction of a system that is able
to measure the water level automatically based on a microcontroller and also get the
measurement result via SMS to the user’s cell phone anytime the result is requested. The

6
method used in achieving this, was an AT89S51 microcontroller, an ultrasonic sensor and a
SIM300C GSM modem, which measures the water level and gives the result via SMS when
requested [Saraswati et al, 2012]. This relates to this project due to the fact that the project
requires a means of reporting the result to the user, but an improvement will be made by
using an arduino microcontroller, because Arduino microcontroller has an internet module
embedded in it and also instead of using SMS means of getting result, a mobile application
will be used.

Another method was discussed by Roy et al, which proposed a scheme to increase the
linearity range of capacitance level sensor(CLS) and make the system independent of the
permittivity of the liquid used [ Roy et al, 2011]. This method utilized an Artificial Neutral
Network (ANN), which was cascaded with a sensor and a data conversion circuit [Roy et al,
2011]. This method detects the level of liquid in a tank, which relates to this project(name of
project), but a capacitive sensor is not suitable due to the fact that the capacitance level sensor
has a high nonlinear response characteristics as well as it depends on the permittivity of the
liquid [ Roy et al, 2011].

Takshan et al, utilized sensors metal probes at different levels of a water tank and interfaced
it with an Arduino microcontroller. The sensor was used to detect the water level and the
corresponding level was displayed on a Liquid Crystal Display (LCD) via the
microcontroller. The system was also fitted with a motor driver which stops the water
supplied to the tank, when the water reaches the brim [Takshan et al, 2018].

In a research paper on the American Journal of Engineering Research (AJER), Eiyike et al


designed an ultrasonic sensor and GSM module based water level monitoring system via
internet of things. In this design, an ultrasonic sensor was used to obtain the continuous level
of water in the tanks, an Arduino microcontroller to process the information and send it to a
Graphic User Interface (GUI) via GSM module. The system also controls the pump from a
remote location via GSM. The project actually focuses on the prevention of water wastage
through overflow of water from the tanks and also the saving of human effort in the
management of the water system.

An Internet of Things (IOT) based monitoring of generator fuel and battery level in base
station sites with SMS alert was designed by [Edem et al, 2018].. This system primarily
checks the manual and inefficient monitoring of fuel and battery levels by the cell phone of
the site operators. The system consist of an ultrasonic sensor to obtain the fuel level and the

7
battery sensor to monitor battery level. It also consists of a microcontroller, GSM module,
power supply, LCD for on-site monitoring and cell phone of the site operator, which receives
the result [Edem et al, 2018]. With this system, fuel and battery level can easily be monitored
remotely, resulting in more efficient cell site management.

Mohammad et al designed a prototype of a content aware fuel monitoring system for cellular
sites. The system was designed to report fuel theft to site engineers and maintain fuel log of
the site for budgeting, operation and maintenance. The system is capable of monitoring the
fuel level continuously, informing the site engineer about the current level of fuel, at which
time of the day the generator is filled with fuel, how much amount of fuel is filled, how much
liters it has consumed while running. The system consists of an ultrasonic sensor,
microcontroller which furthers the information to a remote computer server using
GSM/cellular communication module. The fuel level information is logged in a database on
the remote computer server for future use. This information can easily be accessed by the site
manager via his cell phone. The start and stop of the generator can also be controlled through
a cell/Web server.

Sandeep et al 2020 designed a system capable of monitoring the fuel information in real time.
This was done as a result of error in the information of the level from dispensers at filling
stations. In order to get the true value of fuel actually entering the tank the system was
designed the system was also able to designed to account for fuel theft using an alert system.
The system measures volume using the ultrasonic sensor the information of the volume is
sent to owners mobile as well as through cloud network. The system made use of arduino
microcontroller as major controlling unit and a firebase database to collect data using an
android application to display information of the volume

2.2 COMPONENTS REVIEW

2.2.1 GENERATOR

A generator is an electrical device that converts mechanical energy to electrical energy


through the principle of electromagnetic induction invented by Michael Faraday, in the year
1831. Faraday’s law of electromagnetic induction states that an electromotive force is
produced across an electrical conductor in a charging magnetic field. There are two types of
generators synchronous and asynchronous generator. In a synchronous generator, the
8
armature windings are placed on the rotor, while the field winding is placed on the stator. The
armature winding is where the voltage is induced, while the field winding produces the
magnetic field required to excite the generator. It is called synchronous generator because it
runs on a synchronous speed. The asynchronous generators do not run on a synchronous
speed.

2.2.2 ULTRASONIC SENSOR

Ultrasonic sensors transmits ultrasonic waves. Ultrasonic waves are sounds which cannot be
heard by the human ears and are frequencies greater than 20 KHz. The ultrasonic sensor
transmits this ultrasonic waves are into the air and it detects waves reflected by an object. The
ultrasonic wave transmitted by the ultrasonic sensor has some basic characteristics, which are

Presently many liquid level monitoring system uses sensors as measuring instrument apart
from sensors other means of measurement are employed. Some of these system both sensor
based and non-sensor based used presently includes;

2.2.3 THE GLASS LEVEL SENSOR

This is simple device that makes it possible to view the true level of the liquid through a clear
glass. The glass may be calibrated so to obtain specific values of the volume or depth of the
liquid.

2.2.4 CONDUCTIVITY PROBE

The principle used in this system states that “the presence of a product will make a change in
the resistance between the two conductors.”

This system is applicable for level measurement in conductive liquids. The conductivity of
the insulated material can be varied if the probe is covered or not covered within the
conductive product. There are two electrodes: one is used as a metal wall of the tank, and the
other electrode is inserted into the tank. This principle can be explained with a practical
application.

A Conductive probe is used as a liquid level indicator for measuring the level of electrically
conductive products in a metal water tank, or other container, which can be obtained by
means of a probe isolated from the container and a conductivity amplifier. When the product
is not in connection with the probe, the electrical resistance is relatively high or infinite

9
between the probe and the metal tank wall. If the level of the liquid rises completely between
the probe and the tank wall, then the resistance gradually decreases.

This method is Advantageous as it is very simple, low cost and well suited for dual or
multiple point control.

The method is disadvantageous as the probe must not get contaminated with grease or any
other deposits and has limited suitability for products of varying conductivity.

As a practical example of this detection here we have shown figure of intelligent overhead
tank water level indicator with block diagram which uses conducting probes for detecting the
water in tank. This system is built by using priority encoder, BCD-seven segment decoder,
seven segment display and other miscellaneous components.

The probes are connected to +5V and the return or ground terminal is kept at the bottom of
the tank. Nine active-low inputs of priority encoder are converted to active- low BCD output
by internal circuitry and then the water level is indicated in seven segment display in terms of
percentage of water. As the water level is increases probes get shorted and correspondingly
priority encoder gives BCD values and later the information is displayed on seven segment
display through BCD to seven segment decoder IC.

2.2.5 CONTINUOUS LEVEL MEASURING AND MONITORING SYSTEM

A continuous level sensor is most sophisticated and also provides liquid level monitoring of
an entire system. This liquid level sensor is used to measure the fluid level within a specified
range, moderately than at a one point, which produces an analog output and directly
correlates to the level in the vessel. To create a liquid level management system, the output
signal is interconnected to process a control loop and linked as a visual liquid level indicator.
This measurement system consists of variety of sensors such as;

 Ultrasonic Sensor
 Radar level sensor
 Optical Sensor

2.2.5.1 ULTRASONIC SENSOR

10
Ultrasonic level instruments works on the basic time-of-flight principle which states that
sending a sound wave from a peizo electric transducer to the contents of the vessel, which
may contain liquid, solid or slurries level.

This liquid level sensor comprises two elements such as an associated electronic transceiver
and a transducer with relatively high efficiency. In case of a liquid level controller, the fluid
level can be determined by measuring the trip time difference between a transmitted
ultrasonic pulse and a reflected echo.

The frequency range for ultrasonic methods varies from a range of 15-200 kHz for
transmitting and receiving ultrasonic waves. The lower frequency instruments are used for
the measurement of difficult applications such as longer distances and solid-level
measurements, and the instruments with higher frequency are used for shorter liquid level
measurements.

The ultrasonic sensors are advantageous as they are not in direct contact with the product, and
the level measurement is done without involving any physical contact. They do not have any
moving parts.

As a disadvantage, these types of sensors are not suitable for higher pressures in a vacuum
and temperature limits of up to 170 degree centigrade.

2.2.5.2 RADAR LEVEL SENSOR

Radar level measurement system is based on the principle of measuring the time required for
the microwave pulse and its reflected echo to make a complete return trip between the non-
contacting transducer and the sensed liquid level. Then, the transceiver converts this electrical
signal into distance/level and presents it as an analogue and/or digital signal. The transducer’s
signal output can be selected by the user to be directly or inversely proportional to the span.

The working of a radar level sensor is explained here to measure the level of liquid or solid.
The radar signals are transmitted from the antenna placed at the top of the water tank or
vessel as shown in the above figure. The radar signal gets reflected by the liquid surface and
echo is carried out by the antenna.

By varying the signal, the frequency gets varied during the time of echo and the time of the
signal transmission comparison. The difference of frequency is proportional to the distance of
the liquid, and this statement is used to determine the accurate level of the liquid.

11
The advantages of this radar level sensor include high accuracy and least specificity as it can
measure liquid levels in plastic tanks without establishing any contact with the liquid.

The disadvantages of this type of sensor include the cost, which is very high and the price
increases with the increase in accuracy. Moreover, these sensors are very sensitive to the
buildup on the sensor surface.

Radar level sensors are widely used to measure the level of liquids as well as solids in storage
tanks and tank terminals. These liquid level sensors operate at a wide range of temperature,
pressure and various process conditions.

2.2.5.3 OPTICAL SENSOR

The optical sensor consists of an infrared LED and a light receiver. The light emitted from
the LED is directed towards a prism which forms the tip of the level sensor. If there is no
liquid present in the tank, then the light from the LED is reflected within the prism and the
receiver.

When the liquid level raises and immerses the sensing prism, the light gets refracted out into
the liquid, leaving little amount of light or no light to reach the receiver. Sensing this change,
the receiver activates electronic switching within the level unit for operating external alarm or
control circuit.

The advantages of this optical sensor are that they are not in contact with the process, and
perform accurate measurements of small level movements.

The disadvantages of these sensors include limited applicability and sometimes a high-cost of
installation.

2.3 FLOAT SENSOR

A liquid level control system by using a float sensor works on the principle of buoyancy,
which states, “A float immersed in a liquid is buoyed towards upward direction by an applied
equal force to the weight of the displaced liquid”. As a result, the body drives partially and
gets submerged upon the liquid surface and covers the same distance the liquid level moves.
To put simply, floats give a direct readout of liquid level when they are connected to an
indicating instrument through a mechanical linkage.

A level measurement float system consists of a float, a sensor stem, a magnet, a reed switch
and a weight suspended on the outside of the open tank. A scale is fixed on the outside of the

12
tank, and the contents of the tank’s level are indicated by the position of the weight along the
scale.

This type of level sensor comes with many advantages like it is very simple, highly accurate,
and best suitable for various products.

The Disadvantage of this sensor is that it requires mechanical equipment.

Primary Areas of Float Sensor Application: In view of the requirements pertaining to the
increase in usage of sealed tanks, the current industrial systems make use of this type of float
method for precise reading and accuracy, which is a good example of electronics and
mechanical engineering, making it the most accurate level-measuring system for various
applications in very large storage tanks.

2.4 CAPACITIVE LEVEL SENSOR

Capacitance level sensors are made available for wide range of solids, aqueous, organic
liquids and slurries. This technique is frequently stated as the radio-frequency signals applied
to a capacitance circuit. The capacitive sensors are designed to sense material with dielectric
constants as low as 1.1 for coke and fly ash, and as high as 88 for water or other liquids.

The principle of capacitive level measurement is based on the change of capacitance. There
are two plates in capacitive sensor: one plate acts as an insulated electrode and the other plate
acts as a tank wall. The capacitance depends on the liquid level. An empty tank has low
capacitance, while a filled tank has higher capacitance. A simple capacitor consists of two
electrode plates separated by a small thickness of an insulator such as solid, fluid, gas, or
vacuum.

The Value of C depends on dielectric constant used, area of the plate and also on the distance
between the plates.

C=E (KA/d) ………………………………………………………………………………


(1.1)

Where: C = Capacitance in Pico farads (pF)

E = a constant known as the absolute permittivity of free space

13
K = Relative dielectric constant of the insulating material

A = Effective area of the conductors

d = Distance between the conductors

This change in capacitance can be measured by using an AC Bridge.

The measurement of liquid level is done by applying a Radio Frequency signal between the
conductive probe and the vessel wall. The Radio Frequency signal results in a very-low
current which flows through the dielectric process material in the tank from the probe to the
vessel wall. If the liquid level in the tank drops, then the dielectric constant decreases, which
leads to the drop in capacitance reading as well as minute drop in current flow.

This change can be detected by the liquid-level switch’s internal circuitry and translated into
relay state changes of the level switch in case of a point level detection.

The main advantages of these capacitance systems include easy installation, broad application
range, good accuracy suitable for variety of applications and highly recognized and well -
proven technology.

The disadvantages include sensitivity to changes in the measurable properties such as


dielectric constant and conductivity which creates an issue; furthermore, it is an intrusive
system.

Primary Areas of Capacitance Sensor Application: Capacitance level sensor probes are used
for measuring the levels of:

 Fluids
 Liquid metals at very-high temperature range
 Dissolved gases at very-low level of temperature
 Very-high density industrial processes.

2.5 WORKING PRINCIPLES OF AN ULTRASONIC SENSOR

The ultrasonic sensor sends and receive ultrasonic pulses via a transducer, which gives a
feedback on the object location. It works on a very simple principle, the ultrasonic sensor
sends out ultrasonic pulse at a frequency of 40 KHz, which travels through air and if an

14
obstacle is detected along the path, it will bounce back to the sensor and the distance is
calculated by calculating the travel time and the speed of sound.

2.5.1 TYPES OF ULTRASONIC SENSOR CONSTRUCTION

There are three types of ultrasonic sensor construction and they are;

 Open structure type ultrasonic sensors


 Enclosed type ultrasonic sensors
 High frequency ultrasonic sensors
They are explained as follows;

2.5.2 OPEN STRUCTURE TYPE ULTRASONIC SENSORS


This type of ultrasonic sensor consists of a composite oscillating body combining the
oscillator, which joins a piezoelectric ceramics and metal plate with a resonator. The resistor
is shaped like a cone in order to radiate the ultrasonic waves generated by the vibration and
also concentrate the ultrasonic waves at the central part of the vibrator effectively. Below is
the diagram of the construction of open structure type ultrasonic sensor.

Fig 2. 2 Opened structure type ultrasonic sensor constructional diagram

2.5.2.1 ENCLOSED TYPE ULTRASONIC SENSOR

15
This type of sensors are used outdoors, because they are sealed to protect them from dew,
dust and rain. It has a piezoelectric ceramics attached to the top inside of the metal case and
the entrance of the case is covered with resin.

Fig 2. 3 Enclosed type ultrasonic sensor constructional diagram

2.5.2.2 HIGH FREQUENCY ULTRASONIC SENSORS


This type of sensor is used in industrial robots were high accuracy and acute radiation is
needed. The accuracy has a precision of approximately 1mm and narrow directivity.
Conventional bending oscillators cannot deliver practical characteristics at frequencies above
70KHz, that is why vertical thickness vibration mode of piezoelectric ceramics is used for
detecting high frequencies.

16
Fig 2. 4 High frequency ultrasonic sensor constructional diagram

2.6 PARTS OF AN ULTRASONIC SENSOR

From the diagram below it can be seen the the ultrasonic sensor has two main parts which are
the transmitter and the receiver. The transmitter converts electrical energy to sound and
transmits it, while the receiver receives the echo signal and converts the sound waves to
electrical energy. Also from the figure below, it can also be seen that the ultrasonic sensor
consists of four pins, which include the +5V (V cc) pin, Ground (GND) pin, Echo pin and the
trigger pin.

 The Vcc pin powers the sensors with +5V.


 The trigger pin is the input pin, it has to be kept high for 10μs to initialize
measurement by sending ultrasound wave.
 The echo pin is the output pin. It is in the high state for a period of time, which is
equal to the time it takes the ultrasound wave to return back to the sensor.
 The ground pin as the name implies is connected to the ground of the system.

17
Fig 2. 5 HC-SR04 Ultrasonic sensor

2.7 ULTRASONIC RANGING MODULE HC-SR04

This is the ultrasonic sensor used for this project. It provides 2cm-400cm non-contact
measurement function, the ranging accuracy can reach up to 3mm. It works on the following
principle;

 Using Input/output trigger for at least 10μs for high level signal.
 The module automatically sends 8 cycles burst at 40 KHz and detects whether there is
a pulse signal back.
 If the signal back through high level, time of high output IO duration is the time from
sending ultrasound wave to returning.
Test Distance = [high level time x Velocity of sound (344m/s)]/2… (2.3)

2.8 ELECTRICAL PARAMETERS

Table 2. 1 Electrical parameters

18
2.8.1 TIMING DIAGRAM OF HC-SR04

The timing diagram shown below describes the clocking signal of the sensor. A short pulse of
10μs is required to trigger the input to start the ranging and then the module sends out an 8
cycle burst of ultrasound at 40 KHz and raise its echo. Echo is a distance object that is pulse
width and the range in proportion. The range is calculated through the time interval between
sending trigger signal and receiving echo signal, by using uS/58=centimeters or uS/148=inch
or range=[high level time x velocity(340m/s)]/2. In order to prevent the trigger signal and
receive the echo signal, a measurement cycle of 60μs is used.

Fig 2. 6 Timing diagram of HC-SR04

2.9 ADVANTAGES OF ULTRASONIC SENSOR

1. Due to high frequency , high sensitivity and penetrating power, it can detect the external or
deep objects easily

2. Ultrasonic sensors can be easily interfaced with microcontroller or microprocessor.

3. Ultrasonic sensors can easily sense the shape, orientation and nature of an object located
within the area of the ultrasonic sensor.

4. It has a greater accuracy when it comes to measuring the thickness and depth of parallel
surface than other methods.

5. It is easy to use and free from damage during operation for persons, objects, material, etc.

19
2.10 LIMITATIONS OF ULTRASONIC SENSOR

1. A lot of programming is needed when the ultrasonic sensor is interfaced with a


microcontroller.

2. Ultrasonic sensors have as physical limitation, a blocking distance (close to the sensor)
where they cannot measure reliably e.g 0.23meters.

3. Presence of foam or heavy turbulence on the surface of the measured material can cause
unreliable measurement.

4. Vessel pressure where ultrasonic sensor is to be used should be approximately 0.5bar or


less. Higher pressure may introduce uncertainty in the level measurement.

2.11 APPLICATIONS OF ULTRASONIC SENSOR

1. Ultrasonic sensors is used for distance measurement in automotive application according to


Alessio Carullo et al, 2001.

2. Ultrasonic sensor is used for sensing the level of fuel in a tank as described by John W
Crayton et al, 1994.

3. Ultrasonic sensor is used in robotic industry for robot sensing.

4. It is also used in presence detection system.

20
CHAPTER THREE

DESIGN AND CONSTRUCTION

3.0 INTRODUCTION
In order that the system could be properly constructed and implemented, the system has to be
properly designed showing how the major parts of the system communicates with the
microcontroller and the power supply. This system is designed in such a way that control acts
as the coordinating center of the system whilst power is supplied to different part of the
system hence the remote sensing system design and construction consist of a (PIC18F4522)
microcontroller an ultrasonic sensor, a power unit consisting the linear power and the SMPS
(switch mode power supply). A web application is also designed using C programming
language. The circuit design could be divided power supply, control unit, GPRS/GSM unit,
Ultrasonic sensor.

The block diagram below shows a complete assembly of the components of the system

3.1 BLOCK DIAGRAM

Fig 3.1 Block Diagram

21
3.2 POWER SUPPLY

Specification: 5V 0.5A, 4.2V 2Amps

The power supply is a dual voltage power supply with a combined current of 0.5amps, 2amps
and voltage of 5V and 4.2V. The Smps (switch mode power supply) supplies the voltage of
4.2V and 2A, to the GSM/GPRS module. The power supply consist of a 0.5 amps 240/12V
step down transformer for stepping down the voltage, a bridge diode for rectification, a
1000uF 50V capacitors for filtering, and two 5V voltage regulators (LM7805) connected in
parallel for voltage regulation. The power supply is meant to provide power to the rest of the
circuit such as the relay switching circuit, microcontroller, GSM/GPRS module and the
sensors. The power supply convert A.C mains not greater than 250V to a regulated 5V D.C
for the microcontroller, the Lcd, the ultrasonic sensor and the button circuit. While the smps
supplies power to the GSM/GPRS module.

Fig 3.2 Power Supply

3.3 FULL WAVE RECTIFICATION CALCULATION

Output of transformer = 12V 0.5A

Bridge diode input power (Pin) = Iir × Vir = 12 ×0.5 = 6watts…………………………. (3.7)

Output Power (Por) = 4.872 watts (measured with wattmeter)………………………… (3.8)

I or = Iir

Vor = Por / Ior = 4.872 / 0.5 = 9.744V……………………………………………………. (3.9)

22
3.4 FILTERING CAPACITOR

Filtering capacitors after rectifiers, can range from 220uf – 4700uf. But the higher the
capacitance of the filtering capacitor, the greater the filtering [Ramesh k, 2017], thus 1000uf
was chosen.

C2 = 1000uF

Peak Voltage across capacitor = 9.744V (Bridge diode output voltage)

3.5 VOLTAGE REGULATOR (7805)

Peak Input Voltage = 9.744V (Output voltage from bridge diode circuit feed to input of
regulator)

Nominal voltage (output voltage) = 5V (Output voltage of regulator as given by7805


datasheet)

Maximum current handling capacity = 1.5A (From datasheet)

Input Current = 2A (From voltage regulator (7805) datasheet)

3.6 CONTROL UNIT

The control unit comprises the microcontroller (PIC16F887), crystal oscillator circuit and the
master clear reset circuit which in turn consist of a resistor and a capacitor. The
microcontroller is the main control unit which controls the GPRS module, gets data from the
GPRS module and turn on and off the relay based on the data gotten from the GPRS module.
The microcontroller equally takes data from the sensors and send them to the server through
the GPRS module.

The crystal oscillator controls the timing of the microcontroller which means the time at
which the microcontroller execute one instruction. The microcontroller frequency is one-
fourth of the crystal oscillator frequency. The master clear reset circuit prevents the
microcontroller form resetting by connecting the master clear pin of the microcontroller to
power through a resistor (R1) and a capacitor (C6) to ground. Below in fig 3.3 is the circuit
diagram of the control unit. C4 and C5 are meant for stabilization of the crystal oscillator.

23
Fig 3.3 microcontroller unit (PIC16F887)

R1 = 10K (As recommended in PIC16F887 microcontroller datasheet pg 42)

C6 = 100nF (As recommended in PIC16F887 microcontroller datasheet pg 44)

C4 = C5 = 22pF (As recommended in PIC16F887 microcontroller datasheet pg 45)

3.7 GPRS MODULE

The A6 GSM/GPRS (Sim 800l) cellular chip is from Ai-Thinker (Manufacturer of ESP8266
WiFi modules). It communicates with a microcontroller over UART and supports baud rate
from 1200bps to 115200bps with Auto-Baud detection. It is connected to the microcontroller
using just two wires, one for receiving from the microcontroller and one for sending to the
microcontroller. The GPRS module equally powered by the power supply. Below in fig 3.5 is
the circuit diagram of the GPRS module.

Fig 3.4 Gprs module (Sim 800l)

24
3.8 SENSOR

The sensor is solely made up of an ultrasonic sensor for sensing the level of the liquid
(water). The sensor is powered by the power supply. The sensors send the measured data to
the microcontroller through a wired connection. The microcontroller in turn send the data to
the web server through the GPRS module. Below in fig 3.6 are the sensors circuit diagram.

FIg 3.5 Sonar 2 Ultrasonic Sensor

3.9 BUTTON CIRCUIT

The button circuit is a pull-up button circuit which means the buttons are connected to power
directly and connected to ground though a 10K resistor(pull up resistance for effective
biasing condition) a pull up resistor connects unused input pins(or and nor gates) to ground to
keep the given input low. The resistance value for a pull-up resistor is not usually critical but
must maintain the input pin voltage. The use of 10kΩ pull up resistors are common
(electronics tutorial.com). Also the pull button circuit is an active high circuit. On pressing
any of the buttons, the corresponding pin are momentarily connected to power which is
sensed by the microcontroller and an action will be carried based on the button pressed and
according to the program running in the microcontroller. Below in fig 3.7 is the button
circuit.

25
Fig 3.6 Button Circuit

3.10 DISPLAY CIRCUIT

The liquid crystal display is the output unit of the system and it is connected to the
microcontroller in 4-bits mode. This means data pins D4 - D7 are used to receive data. The
LCD can also be used in 8-bits mode in which data pins D0- D7 are used to receive data. The
LCD is driven by the microcontroller using ASCII information of the received byte. The
LCD used is the LCD-020N004L model. It is a 20x4 character screen type. This means the
LCD is capable of displaying maximum of 20 characters per line (Maximum of 4 lines).

Fig 3.7 Display Circuit

26
3.11 DIESEL TANK

In order that the tank of the diesel generator can be modelled a bucket was used. The bucket
contains at the top, the ultrasonic sensor which is used to determine the level of the diesel in
the tank. The diesel in this case is water. Water is used to represent the diesel hence the water
level is actually modelling the diesel level of the tank.

Fig 3.8 Bucket Modelled As Tank

3.12 TANK MEASUREMENT

The bucket is cylindrical in shape, hence to measure the volume effectively the area of the
cylindrical shape is measured and the sensor measures the height of the cylinder hence
multiplying the height times the area, the volume of the tank is gotten.

To get the constant Area of the cylinder which would be multiplied continuously with the
height measured by the sensor, the height of the cylinder is measured by the sensor when the
bucket is empty. Height is gotten as 33cm. After getting the height, radius of cylinder is
measured and gotten as; 9.52cm.

Therefore volume of cylinder can be gotten from the formula shown below;

Volume of cylinder = πr 2h……………………………………………………………… 3.12

27
R=9.52cm

H=33cm

Therefore volume = π× 9.522 ×33 = 9395.88cm3 which is approximately 9400cm3

To get constant Area;

Area × Height=volume ………………………………………………………………... 3.13

volume 9400
Area =
height
= 33
=284 cm
3

This area would continuously be multiplied by the height the ultrasonic sensor measures at
different time to give the volume of the liquid leaving the tank.

3.13 BILL OF ENGINEERING MEASUREMENT AND ESTIMATION

Table 3.1 Bill of Engineering Measurement and Estimation

S/NO PARTICULAR QUANTITY RATE AMOUNT

(Naira)

1 Led 3 10 30.00

2 5V Dc Pump 1 850 850.00

3 Bucket 1 1500 1500.00

4 Hinges 2 50 100.00

5 Hose 1 200 200.00

6 Superglue 1 500 500.00

7 Sim Card 1 500 500.00

10 PIC16F887 1 5000 5000.00

Microcontroller

11 13A plug 1 300 300.00

28
12 Adaptable box 2 600 1200.00

13 Bolt and Nut 24 10 240.00

14 LCD 1 2000 2000.00

15 Crystal Oscillator 1 500 500.00

16 G.S.M Module 1 5000 5000.00

17 Wire 1 800 800.00

18 Resistors 20 5 100.00

19 Capacitors 10 10 100.00

20 9V Battery 2 250 500.00

21 Voltage Regulators 5 100 500.00

22 Bridge diode 2 300 600.00

23 Diode 5 10 50.00

24 Switch 2 100 200.00

25 Ultrasonic Sensor 1 2000 2000.00

26 Buttons 4 10 40.00

27 Transformers 2 500 1000.00

28 Battery Connector 2 50 100.00

29 Vero Board 2 300 600.00

30 Jumper wire 1 350 350.00

31 IC Socket 1 50 50.00

32 Ribbon cable 3 300 900.00

33 Tape 2 200 400.00

29
34 Miscellaneous 5000.00

35 Grand Total 31210.00

Fig 3.9 Experimental Set-Up

30
Fig 3.10 Full Circuit Diagram

Fig 3.11 Circuit Component

31
CHAPTER FOUR

RESULT/ANALYSIS
4.0 INTRODUCTION
After implementation of the device, certain test was carried out to ensure the functionality of
the system and see whether results gotten shows the system’s ability to perform the reason for
which it was constructed which is continuous measurement of volume of liquid leaving the
tank.

The following test were carried out on the system based on this conditions;

 When the generator is turned on. This scenario is modelled by a switch connected to a
circuit which shows generator is on.
 When the generator is turned off. This scenario is modelled by the switch being
turned off and the tap turned on for the case of leakage. And for the case of theft, the
water was removed from the bucket with the aid of a bowl.
The following results was displayed by the web application interface

4.1 WHEN GEN IS TURNED ON

Fig 4.1 Web App Graphical Display of Diesel Usage

32
As can be seen from the diagram above (i.e web app display of the diesel usage) a graph
displays how the volume of the diesel changes over a period of time hence hovering over
the graph would give the actual date and time and volume at that particular period. Also
directly below the graph is the volume of the diesel and the status of the generator
showing it is turned on.

The picture below shows the real life scenario of how generator is turned on and the led
light that displays showing the generator is turned on.

Fig 4.2 picture of experimental setup when gen has been turned on

4.2 WHEN GEN IS TURNED OFF

Fig 4.3 Display of Tank Analysis

33
The web app displays the status of the generator when the gen is turned off as can be seen
in the tank analysis, it shows that a fuel leakage has taken place. In this scenario the
generator is turned off by switching the generator switch of and the tap is turned on to
show leakage is happening.

Fig 4.4 Display of volume of the diesel

It could be seen from the diagram above that the volume of the generator is displayed,
and the led light showing the gen status is off, showing that the generator switch has been
turned off.

Fig 4.5 Display of Generator Status

34
From figure 4.5 above, it is seen that the web application is able to detect at different
intervals of date and time whether the generator is on off to give an idea of the status of
the generator, at a particular point in time to know whether reduction of the diesel level at
the time was as a result of fuel leakage or theft, or generator consuming diesel.

Fig 4.5 Display On The Graph

Looking at the screenshot above, it could be seen that the volume measured at 7/16/2021

3:10:00 Am, Was 1504cm3. Also taking a closer look at the bottom of the graph the gen
status could be seen as (Gen on: false) showing the gen is on. As can be seen in the figure
below the volume showing is 1504cm3.

Fig 4.6 lcd display of volume

35
4.3 VOLUME TEST

Test was carried out on the system in order to know whether the volume of water recorded by
the system is actually the same as that when measured physically this is inorder to get the
deviation of the system measured value and physical measured value. A volume of 600 cm3 of
water was removed thrice at different initial level of water in the bucket (tank) the following
result was gotten.

Fig 4.7 web display of first initial volume

Fig 4.8 web display of first final volume

36
Fig 4.9 web display of Second initial volume

Fig 5.0 web display of Second final volume

Fig 5.1 web display of Third initial volume

37
Fig 5.2 web display of Third Final volume

Table 4. 1: VOLUME DIFFERENCE TEST

Physical measured volume System measured volume(cm3 )


(cm3 )
Volume of water removed Initial (cm3 ) Final (cm3 Volume
) difference
600 5500 4905 595
600 5000 4406 594
600 4500 3905 595

It could be seen from the table 4.1, though the volume difference recorded was not equal
when the final volume of the system measured volume, was subtracted from the initial
volume of the system measured volume, the measured volume difference is near accurate
because it differs from actual volume which is about 600 cm3 with a difference of 5 cm3.

38
Fig 5.3 Graphical Display And Gen Status Display

As can be seen from result the system measured when gen is on as shown by the
screenshoot, when generator is on the web application interface shows true in the Gen on
line below the graph. When the cursor is hovered over the graph the date time and volume
at the that respective time and date could be obtained. As for the web interface a column
shows tank analysis, this tank analysis shows a complete rundown of the data gotten
showing different time intervals and date and also showing whether there is leakage or
theft.

39
CHAPTER FIVE

CONCLUSION/RECOMMENDATIONS
5.0 CONCLUSION
A remote sensing system for fuel and diesel application using ultrasonic sensor, A6
GSM/GPRS (sim 800l) cellular chip from Ai-Thinker (Manufacturer of ESP8266 WiFi) has
been successfully designed and implemented. This system was able to measure the volume of
water, which symbolize diesel leaving the bucket (tank), when the generator is on and when
the generator is off. And the following results where gotten as shown in table 4.1(volume
difference test table). At an initial volume of 5500 cm3 when the tap was opened and gen
turned on, volume of water leaving was measured by the system and the final volume of 4905
3
cm was gotten. When final volume was subtracted from initial it was discovered that a
volume of 595cm3 was gotten. When volume was measured physically, it was discovered to
be 600cm3, hence, the system was able to measure the diesel leaving the tank with a little
deviation of 5cm3.

Similar test was carried out for the second time as shown in table 4.2. Initial volume of 5000
3 3
cm and final volume of 4406cm where measured by the system, and the volume difference
between them was 594cm3. Test was also carried out for the third time which was recorded in
table 4.2 with initial volume measured by the system to be 4500 cm3 and final volume 3905
3 3
cm the difference between them was 595cm . When the difference of both the second and
third test which was 594cm3 and 595cm3 respectively where compared with the manually
measured volume of 600cm3, It could be seen that the deviation was still 5cm3as recorded by
the first test. Also, as can be seen from the app display of fig 4.5-fig 5.3 (web display of
volume), the app was able to capture the volume measured and also the status of the
generator whether it is on or off.

Hence in Comparison with physical measurement, it could be discovered that though the
system volume measurement of liquid leaving the system was not 100% accurate but the
result as compared with physical measurement, was near accurate as shown from the result of
the test with a little deviation of about 5cm3.

Therefore it could be concluded that, the system was able to successfully measure the level
of the diesel when the generator was turned on and hence its volume. And also it was able to

40
measure the volume of the diesel when the generator was turned off showing that there is a
leakage or fuel theft.

5.1 RECOMMENDATIONS
Some of the recommendations that can be taken to further improve this work are as follows:

 Providing alternative source of power supply to system like inverter and solar system
 A 3G module should be used to enhance the network speed
 A unique webserver should be created to prevent server downtime

41
REFERENCES
Abdullah , A., abdullah , b. & abdulllah , c., 2015. water level indicator with alarms using
PIC microcontroller. American journal of engineering reseearch, 4(7), pp. 88-92.

Anon., 2012. A remote home security system based on wireless sensor network and GSM
technology. In: networks security wireless Nithya and M.Hemalatha. ' ed. s.l.:procedia
Engineering, pp. 737-741.

Antonio-lopez, A., Antonio-lopez, B. & Antonio-lopez, c., 2011. Fiber-optic sensor for liquid
level measurement. optic letters , 36(17), pp. 3425-3427.

Edem, D., 2018. IOT based monitoring of generator's fuel and battery levels in base station
cell sites with SMS alert. Global Scientific Journals, Volume 6(2), pp. pp. 36-44.

Eiyike, J. e. a., 2018. An ultrasonic and GSM module based water level monitoring system
via lot. American Journal of Engineering Research, Volume 7(8), pp. pp. 21-25.

Foram, K. & Anubbhay , M., 2013. Display message on notice board using GSM. Advance in
Electronic and Electrial Engineering, Volume 3, pp. 827-832.

Giannoccaro, N. I. & Spedicato, l., 2017. ultrasonic sensors for measurments of liquid level.
In: volume and volumetric flow in a tank. s.l.:s.n., pp. 1-6.

Hachenburg, V., k, k. & m, m., 2019. data signalling functions for a cellular mobile telephone
system vehicular technology. IEEE transactions on, Volume 26, pp. 82-88.

Horan, B., 2013. Practical Raspberry Pi. Technology in Action. Apress. p ed. s.l.:167. ISBN
978-1-4302-4972-6..

ketkar, k., Tayade, A. & kulkami, A., 2013. GSM mobile phone based LED scrolling
message display system. international journal of scientific engineering and technology,
Volume 2, pp. 149-155.

Ketkar, K., Tayade, A. & Tugnayat, R., 2013. Gsm mobile phone based LED Scrolling
message display system. international journal of scientific engineering and technology.,
Volume 2, pp. 149-155.

Mohammad, A., 2017. Context aware fuel monitoring system for cellular sites. International
Journal of Advanced Computer Science and Applications, Volume 8(8), pp. pp.281-285..

Obikoya , G., adakunle, s. & murray , P., 2018. Design, construction and implementation of a
remote fuel-level monitoring system. EURASIP journal on wireless communications and
networking., Volume 26, pp. 82-88.

Pandya, V. & shukla, D., 2013. GSM Modem Based Data Acquisition system. international
journal of computational Engineering Research, Volume 2, p. 1663.

42
Roy, B., 2011. An intelligent instrument for measuring liquid level. In 2011 International
Conference on Process Automation, Control and Computing , July, pp. (pp. 1-5).

Saidip. M. Saikumar k. , 2019. Real Time Fuel Monitoring And Theft Detection System
Using Iot. International Researach Journal of Engineering and Technology (IRJET), 07(03),
pp. 2828-2829.

Takshan, S., 2018. Water level monitoring system. International Research Journal of
Engineering and Technology, pp. pp. 12-14.

Terzic, E., Nagaraih, R. & Alamgir, M., 2017. Capacitive sensing technology. s.l.:s.n.

43
APPENDIX

Code Sample

#define RS RB0_bit

#define EN RB1_bit

#define levelLED RA5_bit

#define GenLED RE0_bit

#define WorkingLED RE1_bit

#define Enter RC5_bit

#define Right RC4_bit

#define Up RD3_bit

#define Back RD2_bit

#define Triger RD6_bit

#define Echo RD7_bit

#define GenSense RD1_bit

#define GenSwitch RC0_bit

char temp;

char menu = 0;

char menu2 = 0;

char *conArea = "0000";

char *conArea2 = "0000";

char *conArea3 = "0000";

char *period = "00";

44
char *period2 = "00";

const char learnLength = 20;

char initLearn = 0;

char initLearn2 = 0;

char check = 0;

long conVol = 0;

char curPos = 0;

char curPos2 = 0;

char timeVal;

char MIn = 12;

char detectCnt = 0;

char dCounter = 0;

long totalDetectDrop = 0;

long helloHeight = 0;

int k;

int pp;

int heightCounter;

char areaStatus = 0;

char lengthStatus = 0;

char learnStatus = 0;

char timeStatus = 0;

char leakageStatus = 0;

char newHeightStatus = 0;

45
char dataStatus = 0;

char sucStatus = 0;

char detectStatus = 0;

char learnInterval = 30;

char learnInterval2 = 30;

char thou;

char hund;

char tens;

char unit;

char cnt = 0;

char cnt2 = 0;

char cnt3 = 0;

char sendCnt = 0;

char sec = 0;

char sec2 = 0;

char sec3 = 0;

char calPeriod;

char sendStatus = 0;

char sendLearn = 48+0;

long chkLearn = 0;

long level;

long level2;

long areaVal;

46
long calVal;

long totalNewHeight = 0;

long time;

long time2;

long time3;

long height;

long height2;

long height2b;

long height3;

long newHeight = 0;

long newHeight2 = 0;

long newHeight3 = 0;

long effHeight = 0;

long effHeight2 = 0;

long mHeight = 0;

long area;

long perCount;

long perCount2;

long perCount3;

long drop1 = 0;

long drop2 = 0;

long dropTotal = 0;

long dropTotal2 = 0;

47
long averageDrop = 0;

long averageDrop2 = 0;

long savedDrop = 0;

long savedHeight = 0;

long savedHeight2 = 0;

long getDrop = 0;

void genStatus();

void saveNewHeight2();

long calHeight2();

long calHeight3();

void eepromWrite2(unsigned short addr,unsigned short Content);

unsigned short eepromRead2(unsigned short addr) ;

void checkLevel();

void showVolume2();

void calculateVol2();

void clearLCD2();

void lcdCmd2(const char CMD);

void LcdData2(const char DATA);

void LCD_WRITE2(char *str);

void saveNewHeight3();

// Added initialization

48
char isSet = 0;long intCnt12 = 0;char count = 0; char cont = 0; char timeOut = 200;

char msgReady = 0; char intCnt = 0;char count2 = 0; char cont2 = 0; char timeOut2 = 30;

char msgReady2 = 0; char intCnt2 = 0;char timeCnt = 0;

char *txt = "00000000000000000000000000000000";

char *txt2 = "000000000000000000000000000000000000000000000000000000000000";

char *testConnect = "CONNECT";

long testPos = 0;

char txt8[300];

long strlength;long strLength2;

char isStrMatch; long i; long j;

char strlen1 = 0; char strLen2 = 0;

long myStrLen = 0;

long charPos = 0;

//GSM module configuration

const char *server = "www.ovoproject.sightdev.net";

char webData[] = "\"0|0000|0000|0000\""; // "Sample of the data sent to the server";

char webData2[] = "\"1|0|0|0000\"";

const char *uri = "/api/tank";

const char *postRequest1 = "POST /api/tank HTTP/1.1\r\nHost:


www.ovoproject.sightdev.net\r\nContent-Length: ";

const char *postRequest2 = "\r\nContent-Type: application/json\r\n\r\n";

char dataLen; char mainDataLen; char iNum = 0;

49
/*

address 0 for learnStatus; address 1 for areaStatus; address 2 for LenghtStatus; address 3-6
for areaValue; address 7-10 for containerHeightValue;

address 11-14 for (waterTopValue to containerTopValue; address 15-16 for timeValue;


address 17 for timeStatus; address 18-19 for average drop;

address 20 for leakageStatus; address 21 for newHeightStatus;

Adjustment

address 18-21 for average drop; address 22 for leakageStatus; address 23 for
newHeightStatus, address 24 for dataStatus; address 25 for sucStatus;

address 26 for detectStatus; address 27 for detectCnt; address 28 for sendLearn;

*/

void interrupt(){

if(PIR2.TMR3IF){

cnt++;

cnt2++;

if(areaStatus-48 == 1 && lengthStatus-48 == 1){

if(menu2 == 0 && menu == 0){

sendCnt++;

cnt3++;

if(sendCnt == 200){

sendStatus = 48+1;

50
genStatus();

else{

genStatus();

if(cnt3 == 20){

checkLevel();

showVolume2();

cnt3 = 0;

if(GenSense){

if(learnStatus-48 == 0){

if(cnt == 10){

if(sec2 == (learnInterval-1)){

drop2 = calHeight2();

newHeight2 = drop2;

saveNewHeight2();

dropTotal = drop2-drop1;

dropTotal2 += dropTotal;

51
initLearn++;

sec2 = 0;

else if(sec2 == 0){

drop1 = calHeight2();

newHeight2 = drop1;

saveNewHeight2();

sec2++;

else{

sec2++;

if(initLearn == learnLength){

averageDrop = dropTotal2/initLearn;

eepromWrite2(18,48+(averageDrop/1000));

eepromWrite2(19,48+((averageDrop/100)%10));

eepromWrite2(20,48+((averageDrop/10)%10));

eepromWrite2(21,48+(averageDrop%10));

learnStatus = 48+1;

sendLearn = 48+1;

dropTotal2 = 0;

eepromWrite2(0,learnStatus);

eepromWrite2(28,sendLearn);

52
initLearn = 0;

cnt = 0;

else{

if(cnt == 10){

if(sec == (learnInterval2-1)){

initLearn2++;

drop2 = calHeight2();

newHeight3 = drop2;

saveNewHeight3();

dropTotal = drop2-drop1;

averageDrop2 = dropTotal;

sec = 0;

else if( sec == 0){

drop1 = calHeight2();

newHeight3 = drop1;

saveNewHeight3();

sec++;

53
else{

sec++;

if(initLearn2 == 1){

savedDrop = (((eepromRead2(18)-48)*1000) + ((eepromRead2(19)-48)*100)


+ ((eepromRead2(20)-48)*10) + (eepromRead2(21)-48))*(learnInterval/learnInterval2);

if(averageDrop2 > (savedDrop)){

detectCnt++;

leakageStatus = 48+1;

eepromWrite2(22,leakageStatus);

initLearn2 = 0;

eepromWrite2(27,detectCnt);

eepromWrite2(26,48+1);

cnt = 0;

else{

if(newHeightStatus-48 == 1){

if(cnt2 == 10){

54

You might also like