A Smart Water Management System for Detecting Household Water Wastage

. Water scarcity in Kenya is a significant issue that cannot be overlooked. Despite numerous efforts by Water Service Providers to deliver water services to Kenyan residents, the high demand for accessible water across the country remains unmet. In addition, the service provider’s ability to meet this demand is further impeded by various obstacles including inadequate control over water usage, insufficient resources to manage and conserve water, and the dilapidated water infrastructure within the nation. While attempts have been made to try and address these concerns, they ’ ve been largely manual and expensive hence lacking the potential for scalability. Globally, water resources continue to decline rapidly due to the impact of climate change and water overuse, therefore action must be taken to conserve this resource. This study investigates the development of a smart water management system using water flow sensors connected directly to the water appliances that integrate with the existing water system, Node MCU microcontrollers and a cloud-based application. The solution focuses on monitoring household water usage frequency to inform users of their consumption and alert them via mobile notifications of potential water leaks to reduce wastage. Management and control of household water consumption is a positive contribution towards water conservation efforts.


Background
Kenya, known for its scarcity of water, faces significant challenges as the water demand exceeds its renewable freshwater supply.This precious resource is declining, and its importance in various sectors, including agriculture and households, cannot be overstated.In response, the water sector has undergone changes, including the implementation of the Water Act 2016, which aims to align water management with the Constitution and ensure sustainable water services.By devolving services to the counties, Kenya strives to achieve the objectives outlined in Vision 2030, emphasizing improved water accessibility, sanitation, and reduced wastage.Effective water management requires both behavioural and technological changes, with Public-Private Partnerships (PPPs) playing a crucial role in managing water resources.The introduction of smart water sensors represents a significant technological advancement with the potential to accurately monitor water usage.The present research addresses the gap in detecting household water wastage at the appliance level, introducing a cost-friendly and innovative smart water management system that encourages water conservation.The system's primary objective is to raise awareness of water consumption and provide real-time alerts for detecting and addressing water wastage.

Related Literature
All living beings depend on water for survival and how we use it affects us all.Scientific studies have shown that about 70% of the earth's surface is covered with water, while this may seem abundant the reality is that only 1% is available for human consumption [1].This situation leaves the entire planet fending for this limited resource.
To avoid complete depletion or severe scarcity of any limited resource, it is necessary to utilize it efficiently and effectively.Arid and semi-arid lands (ASALs) face this adverse effect of water scarcity."The annual rainfall in arid areas ranges between 150 mm and 550 mm and in semi-arid areas between 550 mm and 850 mm per year" [2].Kenya falls into the category of ASALs. Figure 1 shows the trend in Kenya's renewable water resources over a span of fifty-five years.The trend is only getting worse.In a recent study on Emotions toward water consumption, conservation and wastage, it was found that people's perceptions of water consumption were based on social externalities.When consumers realize that water is being conserved in their environment then they were likely to conserve it and use it efficiently.On the other hand when an individual observes that the people in the environment are wasting water, then they are more likely to waste the water as well [4].

Water wastage identification
Household water wastage refers to the excessive and inefficient use of water in homes, which can result from actions like leaving taps running unnecessarily, taking long showers, using drinking water for non-potable purposes, and over-watering plants or lawns.These practices strain the local water supply and treatment systems.In Kenya, the average household consumes 100-200 litres of water daily, exceeding the recommended usage of 70 E3S Web of Conferences 469, 00017 (2023) ICEGC'2023 https://doi.org/10.1051/e3sconf/202346900017litres.Common causes of water wastage include a lack of efficient modern plumbing, faulty plumbing systems, inefficient fixtures, poor irrigation practices, and a lack of rainwater harvesting [5].
The Kenyan Ministry of Water and Sanitation, along with the Water Resources Management Authority, have identified various water conservation measures that households can adopt to reduce their water consumption, such as the use of water-efficient fixtures and grey-water harvesting, although full implementation is lacking [6].

Behavioural change techniques in water management
Based on literature [7]- [11], behavioural change techniques revolve around three pillars: awareness and familiarity, adoption, and persistence.The first pillar emphasizes increasing awareness through public campaigns about water conservation measures.The second pillar addresses factors influencing the adoption of conservation practices, such as water price, household characteristics, convenience, and social norms.The third pillar seeks to comprehend the motivations behind persisting with water conservation, primarily observed during water shortages, particularly in drought situations.

Empirical literature
An innovative water management system in India automated water collection, monitored levels, and analysed usage on a campus.Sensors collected tank water levels, transmitting data to a central server through Arduino and Raspberry Pi.The data was visualized via a cloud-hosted web interface using Ubidots Cloud Platform, with added SMS and email alerts.Scaling to residential homes was hindered by limited financial support to evaluate social acceptance and technology impact.Additional resources were required for analytics, consumption forecasting, and water leakage detection to improve decision-making and assess water wastage reduction [12] Similarly, a research project was carried out in the UK, Poland, and Greece using IoT technologies to monitor domestic water consumption.The study wirelessly recorded and stored appliance-level water consumption data in a central database.A mobile application provided real-time awareness, water-saving tips, and behaviour classification to encourage mindful water usage and reduce wastage.Nonetheless, the main challenge was the insufficient integration with the current infrastructure, hindering scalability to other regions or countries due to the lack of universal system inter-networking and management standards [13], [14].
In many African countries, including South Africa, manual analogue water-metering systems are prevalent, resulting in labour-intensive and inaccurate readings.To tackle this issue, an office building adopted a smart water management system, offering real-time data and visual graphs through a web-based application for leak and unattended tap detection.Nevertheless, the system faced challenges in monitoring battery charging status and interface node operation, as well as the absence of a centralized module to manage nodes.Additionally, the system lacked a localized algorithm to detect unusual water consumption in designated areas, hindering real-time identification of specific localized leaks [15].
A study conducted in Nairobi, Kenya to examine the effectiveness of water conservation systems installed in two hundred households found that piped water storage, water recycling, and rainwater harvesting were the three major systems that promoted the collection and reuse of household water.This was key in demonstrating the importance of effective water conservation systems to promote sustainable water use in urban areas.The findings suggested that implementation of these systems had the potential to reduce water wastage and ensure a reliable supply of potable water during periods of water scarcity.The major limitation of this study was that it was largely manual, and no system automation E3S Web of Conferences 469, 00017 (2023) ICEGC'2023 https://doi.org/10.1051/e3sconf/202346900017when measuring results was implemented.The main recommendation after the study was the use of automation to aid in water monitoring and water wastage detection [16].
As a progressive step towards detecting water leaks and overuse in residential properties, a system was developed by the Abu Dhabi University and the Khalifa University in the United Arab Emirates.This system used machine learning to examine the issue of residential water leaks and consumption which often go unnoticed for a long time, leading to significant water wastage.The system encompassed a leakage detection model that utilized sensor technologies and machine learning algorithms to detect leaks early and minimize water wastage.The model faced difficulties in achieving high precision, which was crucial for correctly identifying true leakage cases while minimizing false positives.Since the majority of the dataset consisted of non-leakage cases, the model primarily focused on accurately predicting those, potentially leading to missed leakage instances or incorrect classification of rare leakage cases as non-leakage [17].

Internet of Things (IoT) and IoT Architecture
IoT has emerged as a pivotal technology in our daily lives, enabling the interaction between humans and smart devices.It involves a vast network of computer devices, including sensors, that rapidly exchange large amounts of data [18].This interconnectivity is achieved through Machine-to-Machine communication (M2M), a standardized approach for various machines to communicate and share information on a global scale without human intervention.
IoT architecture refers to the structure that outlines how various components of an IoT system and its design aim to be adaptable, scalable, and secure to support diverse devices and applications while ensuring consistent operation across various environments [19].Figure 2 gives an illustration of the IoT architecture and the various layers.

Fig. 2. Internet of Things Architecture [19]
The perception layer comprises various components like sensors and actuators that collect data and execute tasks.The transport layer facilitates the transfer of sensor data between the perception layer and the processing layer using various network options such as wireless, Local Area Networks, Bluetooth, Radio waves and Near Field Communication in both directions.The middleware layer, commonly referred to as the processing layer, is responsible for storing, analysing, and processing vast volumes of data received from the transport layer.It can manage and offer an array of services to the lower layers.Various technologies, including databases, cloud computing, and big data processing modules, are utilized by the processing layer.The business layer oversees the complete IoT system, covering applications, business and profit models, and safeguarding users' privacy [19].

Wireless Technologies in IoTs
A comparative analysis of commonly used wireless technologies and the preferred option chosen for the study are as described [20].
General Packet Radio Service (GPRS) is a wireless communication standard that enables the transmission of data over a cellular network.It is commonly used for applications that require low-to-medium data rates.GPRS is based on the GSM (Global System for Mobile Communication) cellular network and allows for the transfer of small packets of data between devices.
Sigfox is a low-power, long-range wireless communication technology that operates on unlicensed radio frequencies.It is designed for IoT devices located in remote or hard-toreach locations.Sigfox can transmit data over several kilometres without the need for repeaters, making it suitable for applications requiring long-range coverage.
LoRaWAN is a long-range, low-power wireless communication technology that operates on unlicensed radio frequencies.It offers extensive coverage, especially in outdoor environments, and can transmit data over several kilometres without the need for repeaters or additional infrastructure.LoRaWAN provides flexibility in payload size, supporting small to moderate data transmission.
Wi-Fi is a wireless communication technology that uses radio waves to transmit data over short distances.It is widely available in most households and public spaces, making it a convenient and user-friendly wireless technology for IoT applications.One of the advantages of Wi-Fi is its high data transfer rates, which are useful for transmitting large amounts of data quickly and efficiently.
Wi-Fi was considered most suitable for the prototype developed due to its wide availability in households and its interoperability features which made it convenient in integrating all the IoT devices used in the prototype.The main focus was to ensure that data was uploaded in real-time to a cloud-based server, hence, to achieve this functionality existing Wi-Fi routers found in the households were deemed to be the most cost-effective and convenient.

System development methodology
The development methodology that was chosen involved an iterative approach to data collection and analysis, with a focus on continuous improvement of the research problem.In addition, it was expected to reduce the risk of failure and accommodate changes in requirements, as well as allow users to adapt to the system in smaller, incremental steps [21], [22].
Figure 3 provides an overview of the iteration method and the steps involved in the model.The first step was planning, followed by requirements gathering in the second step, design, and analysis in the third, implementation and testing in the fourth, and evaluation and review in the fifth step.These steps went through several iterations until all functionalities were completed.

Research Design
The study utilized an empirical methodology, employing planned observations to systematically collect data.The methodology encompassed five key components: deciding what, whom, how, when, and how to analyse and interpret the data [23].The research was conducted in Kenya, specifically in households located in Nairobi County, Lang'ata constituency.The primary areas of focus were kitchens and bathrooms, equipped with water flow sensors connected to a programmed microcontroller, which were managed through an online and mobile app.A representative sample of five households was selected to enable real-time monitoring of water usage, facilitating the development of efficient water management systems and practices.

Application Architecture
The waterflow sensor is fixed on the direct line of the water faucet to detect any water flow.It uses a water rotor and a hall-effect sensor.When water flows through the rotor, the rotor spins, and the speed changes with the different flow rates.The hall-effect sensor outputs the corresponding pulse signal, and this is calculated to get the flow rate of water going through the sensor in litres/minute.
Node MCU with Wi-Fi, which is a programmable board receives the data, performs a calculation of the pulse signals using a calibration factor of 6.6 as per the model of the water flow sensor, and forwards it to the gateway using the Wi-Fi module.The equation used to calculate the flow rate is as shown in Equation (1):

Flow rate (L/min) = (1000/elapsed time * Output pulse rate) / calibration factor (1)
The router provides the link to the internet.It transmits the sensor data to the cloud server containing the water management application and data analytics.The cloud server hosts the application and database.It processes the data received and acts per the predefined conditions.
The mobile application programming interface (API) offers the user interface in the form of a dashboard for data visualization, receiving alerts, and retrieving reports.
The Cloud Server Analytics hosts the intelligent engine that will be used for data analysis, trends, and reports.
The flow of information within the system is as depicted in the application architecture diagram in Figure 4 while Figure 5 shows a sample of the code where Equation ( 1) is used.

Data Analysis
The research conducted data analysis from the moment of data collection.The system recorded and verified water usage data, ensuring incremental readings during intermittent water flow.Alerts were triggered according to pre-defined limits for the bathroom and kitchen.The bathroom threshold was based on the cistern volume, while the kitchen threshold was set at 4 minutes of uninterrupted water flow.To assess usage patterns and wastage, data from the Blynk cloud app was exported in CSV format, encompassing water usage, appliance durations, and instances surpassing the set threshold.

Hardware and Software Environment
The data acquisition unit, managed by NodeMCU, employs a DN20 Copper flow water sensor to monitor water flow.The sensor measures water flow using a pinwheel integrated with a magnetic hall-effect sensor.NodeMCU collects data periodically and sends it directly to the Cloud server without processing.The water sensor and Wi-Fi module were connected and configured using Arduino Integrated Environment on a laptop, with the Arduino firmware coded in C++.The water management system consisting of the mobile app is hosted on Blynk IoT Cloud, an open-source platform utilizing JavaScript for the API and file systems to store data.

System Modules
To use the mobile app the user needs to sign up and log in to manage their respective devices.The standard dashboard for an average user is shown in Figure 6.It displays the water flow rates, volume of water used in litres and a real-time view of the water flow.An additional message informing the user of effective conservation measures is also included in the dashboard.The events menu shown in Figure 7 enables the user to generate alerts for water usage.This is a crucial feature of the system because it promptly notifies the user of any water wastage.

Hardware Configuration and Uploads
The system involved the configuration of water flow sensors and NodeMCU microcontroller boards.Figure 8 shows the upload of code to the NodeMCU microcontroller.Once this code is uploaded the microprocessor can calculate the flow rate and water volume from the water flow sensor.Testing was done on core functionalities which included a test case, observed behaviour and a conclusion to indicate whether the function worked or not.User and device registration, data acquisition and uploads, alert generation, usage graphs, reports and analytics graphs were the core functions tested and confirmed to be working as expected.

Compatibility Testing
Both hardware and software were tested on whether they were compatible with different operating systems.The hardware components were tested on a Linux and Windows machine to confirm whether the operating system would detect them.

Usability and Integration Testing
The test aimed to showcase the application's consistency and user-friendliness.The dashboard layout and widgets remained consistent, enabling easy navigation.Clear messages alerted users to system events.The water management system passed the usability test, demonstrating its ease of use on various portable devices.Integration testing of the water management system, involving the water flow sensor, Node MCU, and Blynk cloud application, was successfully completed.The testing confirmed hardware and E3S Web of Conferences 469, 00017 (2023) ICEGC'2023 https://doi.org/10.1051/e3sconf/202346900017software integration, allowing real-time communication.The system effectively identified water wastage instances and promptly issued alerts.
Figure 11 and Figure 12 show the user dashboard when there was no flow and when water started flowing.A notification was sent to the user immediately water started flowing.The graphs in Figure 13 are maximized from the dashboard to give a comprehensive overview of water consumption analysis across various time intervals, including hourly, daily, weekly, monthly, and yearly usage.This enables users to observe consumption trends, facilitating quick adjustments or identify plumbing issues in cases of unusual spikes in usage.A view of a sample alert sent to the user immediately after a threshold is reached and surpassed is illustrated in Figure 14.

Conclusions
Water is a precious resource that is currently facing a global threat due to climate change.With the increase in droughts and the depletion of water sources, many countries, including Kenya, are experiencing severe water shortages.Although various mitigation and adaptation practices have been put in place, they often lack the necessary support and maintenance.
This paper highlights how to create a water management system that could detect and monitor water wastage in households.The system is designed to raise awareness about water consumption, and alert users of potential leaks and wastage to encourage prompt action.The results showed that when users were alerted to water wastage in their homes, they were more likely to take action to address the issue.The findings of this paper are significant in promoting water conservation practices and can contribute to efforts aimed at ensuring the sustainable use of water resources.

Fig. 6 .
Fig. 6.User Dashboard with water flow rate and volume

Fig. 8 .
Fig. 8. Compiling and uploading of code to the Node MCU Once the code has been uploaded to the Node MCU, the device is noted to be online in the Blynk App and any water flow data is then uploaded to the cloud and viewed in the dashboard by the user.Figure 9 illustrates real-time data of water flowing from the Arduino IDE serial monitor interface.A graphical representation of the same is shown in real-time on the user's dashboard.

Figure 9 Fig. 9 .
Fig. 9. Sample of real-time data from the Arduino IDE serial interface

Fig. 10 .
Fig. 10.Prototype connected to the bathroom to monitor consumption

Fig. 14 .
Fig. 14.Blynk mobile alert All alerts are stored in the alerts menu and can be viewed on one page as shown in Figure 15.