Professional Documents
Culture Documents
Monitoring and Forecasting Water Consumption and Detecting Leakage Using An IOT System
Monitoring and Forecasting Water Consumption and Detecting Leakage Using An IOT System
3 | 2020
ABSTRACT
Water is an important resource for life and its existence and, unfortunately, large quantities of water Jyoti Gautam (corresponding author)
CSE Department, JSS Academy of Technical
are being wasted on a daily basis. Monitoring the consumption of water can control water usage, and Education,
NOIDA, Uttar Pradesh 201301,
smart technologies can play a useful role. In this paper, a smart system based on Internet of Things India
E-mail: jyotijssaten@gmail.com
(IoT) has been proposed to monitor the water consumption in an urban housing complex. An
ultrasonic sensor, together with Arduino, continuously monitors the water level of water tanks on Amlan Chakrabarti
AKCSIT, University of Calcutta,
rooftops and sends these data to a server through a Wi-Fi module. Using the data collected from the Kolkata 700106,
India
IoT system, the daily and weekly average water requirement of households can be calculated.
Shruti Agarwal
Support vector machines (SVM) are used to forecast water consumption. The observed readings are
Indiamart Intermesh Ltd, Assotech Business
divided into training and testing datasets. Water consumption is predicted for each day for a user. Cresterra,
Noida 201305,
Error is recorded as the difference between the actual consumption and the predicted value, and it India
decreases as the number of days increase. An algorithm to monitor leakage of water in the tanks has Anushka Singh
Tata Consultancy Services,
also been proposed. A web interface allows the user to visualize the water usage, monitor their
Haryana,
consumption, and detect any leakage and leakage rate in the system. India
Key words | IoT, leakage detection, machine learning, smart water management, SVM, water Shweta Gupta
Robert Bosch Engineering and Business Solutions,
consumption chil sez it park, Coimbatore,
India
Jatin Singh
Tata Consultancy Services,
Noida, Uttar Pradesh 201309,
India
INTRODUCTION
Due to rapid urbanization and population increase, the be continuously monitored but the user can also be given
stress on freshwater resources is ever increasing. This will control of their consumption. Real-time modeling and con-
have catastrophic impacts on food security and poverty trol of water distribution in a particular urban/rural region
(Sayre & Taraz ). Proper techniques should therefore is mainly guided by water consumption data in various
be adopted for water conservation, and technology can households or a group of households, and our methodology
play an important role. Water should be used optimally, of estimating the water usage can play a useful role in this
i.e. just for use and no wastage. Water losses, over-use, and activity. Large amounts of water is also wasted through
quality are some of the issues in urban water systems. water leakage in tanks and pipes. Detecting these leakages
Information and communication technology can play a and notifying the user can be a step toward monitoring
significant role through the development of smart water and control of wastage of water. Water consumption of
grids that network and automate monitoring and control users was monitored using electromagnetic meters at an
devices (Mutchek & Williams ). With the help of hourly time step and water losses were assessed with respect
smart technologies, not only can the water consumption to the real case (Alvisi et al. ). Drivers, development, and
doi: 10.2166/ws.2020.035
global deployment of intelligent water metering have been combined with SVM (PSO–SVM) model for daily water
reviewed (Boyle et al. ). Smart metering helps water demand prediction. A proposal for using soft computing
utilities to rapidly identify and take appropriate action methods for forecasting water demands can be found in
on significant volumes of post-meter leakage occurring Ghalehkhondabi et al. (). Gautam et al. () proposed
in cities (Britton et al. ). A framework has been an IoT-based real-time monitoring of water levels in tanks
presented for the classification of residential water using machine learning and an Android app. Analytics
demand modeling studies (Cominola et al. ). Impli- had been performed on Kaggle datasets for 19 households
cations of smart water metering have been discussed for in Venice, Italy.
enhanced water distribution infrastructure planning and The Bureau of Waterworks in the Tokyo Metropolitan
management and can be found in Gurung et al. () and Government () observed when practicing the prevention
Luciani et al. (). Urban water demand management of leakage in Tokyo that the water pipes embedded under-
planning, policy, and practice have also been discussed ground are constantly subject to the danger of leakage, and
(Willis et al. ). when leakage does occurs, these pipes constitute additional
Ishido & Takahashi () proposed a new algorithm risks, including poor water flow, sagging roads, inundation,
that uses a technique for real-time leak detection in a and so on. Thirteen cities, including Tokyo, Seoul, Los
water distribution network using real-time pressure Angeles, and New York, agreed to make efforts to promote
measurements only. A proposal for design and development measures against leakage. A proposal for leakage detection
of a low-cost system for real-time monitoring of the water and an estimation algorithm for loss reduction in water
quality in Internet of Things (IoT) can be found in Vijayaku- piping networks is presented in Adedeji et al. (). Water
mar & Ramya (). A completely data-driven, fully loss through leaking pipes is a major challenge to the oper-
adaptive, self-learning algorithm for water demand forecast- ational service of water utilities. There has been significant
ing in the short-term and also with hourly periodicity is financial loss and environmental pollution caused by leaking
proposed in Candelieri et al. (). Shahanas & Sivakumar pipes. The algorithm helps detect critical segments or pipes in
() discussed in detail the design of IoT systems and the network that are experiencing a higher leakage outflow. A
related analytics in the context of smart city initiatives in summary of common leak detection technologies can be
India. Machine learning techniques and smart city manage- found in El-Zahab & Zayed ().
ment aspects, such as smart water management that By focusing on the above research contributions, an IoT-
includes water demand forecasting, water quality monitor- based smart water management (SWM) has been proposed
ing, and also anomaly detection, have been detailed in that involves an ultraviolet (UV) sensor and Arduino to
Vijai & Sivakumar (). Research suggests that smart detect water level in tanks. SWM includes data collection
water management can be divided into three parts: (1) fore- and integration using an ultrasonic sensor, data distribution
casting demand, (2) water quality monitoring, and (3) using Arduino microcontroller, data analytics, forecasting,
anomaly detection. A proposal for the design of a water and decision support using machine learning techniques.
tank monitoring system based on mobile devices has been The data from the UV sensor are sent to a server by the
presented by Gama-Moreno et al. () called Interface Wi-Fi device in the Arduino board, which can be monitored
for Monitoring Water Tanks (IRMA). Maevsky et al. () by users via a web interface. The data set used here has
studied system analysis of IoT and proposed a hierarchical been collected from water tanks supplying water to 16
architecture of smart systems. households in JSS Academy of Technical Education
Peña-Guzmán et al. () presented a model for fore- (JSSATE) NOIDA (https://jssaten.ac.in/academics/CSE/
casting water demand in residential, commercial, and index.php), staff quarters. The next step after data collection
industrial zones in Bogotá, Colombia, using least-squares– is to apply proper analysis and optimization techniques to
support vector machines (LS–SVM) and they explored the the data using machine learning algorithms to monitor the
effectiveness of this model over long time scales. Jiang collected data. An SVM algorithm has been used to forecast
et al. () studied a particle swarm optimization the water demand.
An algorithm to check water leakage has also been pro- 1. Collecting water level (consumption) data from water
posed. For leakage to be detected, the basic assumption in tanks installed on rooftops at JSSATE NOIDA staff
the algorithm is that the user inputs whether the water is quarters.
in use or not; if it is in use then the leakage cannot be pre- 2. Performing pre-processing steps on the data.
dicted. Leakage has been detected when the water is not 3. Analyzing the data and applying SVM for forecasting
being used and during a period when there is no water water consumption, leakage detection and leakage
supply. The leakage rate can also be calculated. rate.
Key findings are as follows: 4. Designing a web interface for the users for visualization
ing water usage in an urban environment. This research was undertaken on the rooftops at JSSATE
2. Proposal of a machine learning-based technique. NOIDA staff quarters in Uttar Pradesh, India. There were
3. Proposal for water leakage detection based on user input two sets of tanks and both sets contained two tanks that
and water usage data. were interconnected. Set 1 had two tanks containing reserve
4. Development of a visualization tool for users to estimate, osmosis water used for drinking and cooking purposes; set 2
predict, and detect leakage. had two tanks containing water for other household activi-
ties. There were four tanks in total. The setup (Figure 1(c))
was installed on the tanks, which were connected to 16
METHODS households comprising of a total of 24 people. The system
architecture is detailed in the next section. The initial, and
The phases included data acquisition, communication, stor- most essential, part of our project is data acquisition, which
age, pre-processing, analyzing, and web interfaces carried is explained in detail later. Figure 1(a) shows the circuit dia-
out by the following: gram of Arduino with the ultrasonic sensor used for data
Figure 1 | Overall system architecture: (a) interfacing of Arduino with ultrasonic sensor; (b) Pin diagram of Espressif Modules (ESP) (Wi-Fi microchip) module with Arduino; and (c) data
communication of Arduino with the database server.
acquisition; Figure 1(b) shows the ESP module with Arduino • ESP module
used for data communication; and Figure 1(c) shows the • Connecting wires
server where the data are stored. The pre-processing of data,
i.e. intervals of time, the data are taken, and handling of miss- Technical specifications for ultrasonic sensor
ing values, is described later, followed by details of the
analytics part, i.e., the features taken and applying the SVM Power supply þ5 V DC
and leakage detection algorithms. We then discuss the various Quiescent current <2 mA
user interfaces, starting from the login page, OTP verification Working current 15 mA
page, the interface to upload a CSV file for datasets, list of attri- Effectual angle <15
butes, the interface for total water consumption, total number Ranging distance 2–400 cm (1 inch–13 ft)
of users and average consumption per user in a day, and the
user interface for predicted value of water required on the Data acquisition, communication, storage
next day per user on the basis of previously observed water
usage. The purpose of the entire methodology is to enable The data used for the project were collected from a complex of
users to forecast their water usage and also to inform about 16 households. The height of the water tank and the require-
leakage detection through a well-suited web interface. ment of the household plays an important role in
determining the working of the whole process of starting and
System architecture stopping the motor. The water tanks installed were Syntax
1,000 L tanks, with a 109.98-cm radius and a 122.43-cm
The following list details the hardware components provided, height. There was no inflow of water in the tanks at the time
along with the technical specifications for the ultrasonic of monitoring. The tank system is shown in Figure 2.
sensor, data acquisition architecture, and the Wi-Fi.
Working of ultrasonic sensor
Sensor and data acquisition hardware
The Arduino kit, including the UV sensor, was installed on
• 1 × Breadboard the top of one of the two tanks to monitor the water level
• 1 × Arduino Uno R3 every 10 s. This ultrasonic sensor sends UV rays to measure
• 1 × ULTRASONIC Sensor (HC-SR04) the distance of the water level from the top of the tank
• 1 × LCD 16 × 2 using sonar. The sensor sends ultrasonic waves to the
water, which are reflected by the water surface and returned detected from the total height of the water tank (cm)
to the sensor. The sensor uses this time of wave propagation (Equation (1)):
to calculate the distance between the sensor and the water
level. The time taken by the pulse is actually to and fro for
Water height (cm) ¼ total height (cm)
travel of the ultrasonic signals, while only half of this is
– water level detected (cm) (1)
needed. Therefore, the time is time/2.
Distance calculation:
Data description and pre-processing
Distance ¼ speed × time/2
Speed of sound at sea level ¼ 343 m/s or 34,300 cm/s
Time step
Thus the distance measured ¼ 17,150 × time (cm) (Boyle
et al. ).
The time step denotes the time interval for recording the
Using that distance, the water level and hence the
water consumption values, and is dependent on which
volume of water consumed can be calculated because the
model is used. The model can be hourly, daily, or monthly.
height and radius of the tank are fixed.
In our case, the time step is 10 s.
In the data set, the water level detected (W) is the distance The algorithm for leakage detection considered the fol-
between the ultrasonic sensor and the water surface in lowing parameters:
the tank (i.e. the height of the empty space in the tank). (a) Input variables: water level initial, water level final and
The water height (w) is the actual height of water in the in use.
tank (i.e. the height up to which water is filled in the (b) Response variables: leakage detected (yes/No) and leak-
tank), which is calculated by subtracting the water level age rate (cm3/s).
SVM-based classification where k is the kernel function RBF and σ is extension con-
stant of RBF (Equation (4)).
SVM was used for analysis purposes because it is accurate
and is the preferred method for data sets of small sizes
Steps for the training algorithm
(Ray ). SVM is also less prone to over-fitting than
other methods and it facilitates compact models for classifi-
Step 1: The data set is divided into two sets: training data
cation. Kernel function, radial basis function (RBF), is used
and testing data set. As we have data for around 25 days we
because the data are not linearly separable (Ng ) and it
take the initial 7 days’ data, i.e. from 3 February 2019 to 10
is the most commonly used kernel in SVM. Finally, the opti-
February 2019, as training data.
mal hyper-plane is found, which creates maximum empty
Step 2: From the next day, i.e. 11 February 2019, we pre-
space at two sides of the coordinate. The independent vari-
dict the total consumption values using the training data set
ables used for training are shown in Table 1.
by applying the SVM algorithm.
The model parameters used in designing the proposed
Step 3: The predicted value for the 8th day is compared
SVM classifier are described next.
to the actual water consumption value for that day. The
If a set independent variable is !
x i ¼ (xi1 , xi2 , . . . , xin )
error value is calculated by finding the difference between
and water demand is qi, the SVM model equation can be
the actual and the predicted value.
written as Equation (2):
Step 4: For predicting the consumption value for the
1 Xl next day, i.e. for the 9th day, we take the 8th days’ value
~
q ¼ αi k(~
xi , ~
xj ) þ β (2)
2 i,j
in the training data set. This is recursively repeated and we
predict the value for nth day using the previous n 1 day’s
where q is the series of water demand prediction values and value in the training data set.
αi is the undetermined parameters in Equation (3). Step 5: Every time we increase the data set for training
data, the error value shows a significant reduction, i.e. we
α i ¼ Cξi (3)
approach a more accurate prediction.
where C is penalty factor and ξi is slack variable,
optimized to improve solution using Equation (3) for • random forest, bagging, self-organizing maps, k-nearest
convenience neighbors, and so on.
Step 4: Use the Cross-Validation 5 (CV-5) model to
train this model and calculate error E. The data set is Minimizing forecasting deviation
divided into five parts using Xu & Goodacre’s () CV-5
model. Here one part of the data set is taken as the Measuring forecast errors is crucial for the selection of an
test data and the rest is the training data set. Then a accurate and reliable forecasting model.
model is fitted and error E is calculated each time The basic step consists of comparing forecasts with
(Equation (5)). observations, possibly using a wide subset of the available
data to learn/build the forecasting model and the remaining
X
V
1 X
T subset of data to validate it.
E¼ ðy t y 0 t Þ2 (5)
2 t ¼1 The most widely adopted error measures is MAPE
i¼1
(mean absolute percentage error) (Equation (6)).
been detected or not and, if detected, then the rate of leak- The system is highly applicable to urban water management.
age is displayed. It can be used to determine water requirements in a society
or complex; to calculate the supply and demand relation-
RESULTS AND DISCUSSION ship; and to detect leakage and leakage rate, allowing
immediate action to be taken to correct the cause of leakage,
Figure 7 shows both the average calculated values and the and ultimately saving water.
predicted values of water consumption versus the number
Advantages of the system
of days. The result is susceptible to many factors, such as
holidays, temperature, weather, etc. Figure 7 clearly shows
1. It saves water and reduces its loss due to unavailability of
that the predicted values and the calculated average values
proper checks.
tend to coincide as the data value increases.
2. It saves a lot of users’ efforts when checking the level in
The difference between the predicted and the actual
the water tanks.
values, i.e. the error value graph, is as shown in the Figure 8.
3. It allows an equal distribution of water for all (Chatterji
We found a maximum error of 46.75%, which was reported
& Haq ).
at the beginning when the training data set was small. The
average error is around 11.34%. The minimum value of
error is as low as 1.856%. As the training data set ACKNOWLEDGEMENTS
increases, the error value approaches to minimum.
This research work has been supported by JSSATE, NOIDA.
We also thank its staff members for helping us collect the
CONCLUSIONS water data.
First received 5 November 2019; accepted in revised form 24 February 2020. Available online 10 March 2020