Water flux management with low-cost iot technology for residences

Implementation of a low-cost water flux management System for residences. Applying bibliographic research for better comprehension of the concepts applied in the work, adopting quali-quantitative research through a survey aimed at a random audience, documentary research for information support on informal agencies and finally a case study to accomplish the construction of a profile of the average expenditure by a Brazilian family. The average water expenditure on Brazilian households exceeds the required amount stipulated by the World Health Organization to achieve sustainable usage, bad habits we maintain about water usage in our daily activities, get us even closer to a future shortage. The expense of water wastage, either by reading failure or clandestine connections, cost to the country a large amount of money. With the export, there is an excessive water consumption in large cities and a lack of control on the part of residents in moderating their use. With the implementation of this system, the resident will have the possibility to obtain the control, clearly over its residential consumption, besides a better awareness about how its actions affects the environment and consequently the people around it.


INTRODUCTION
Facing the water crisis the world is going through, the UN, in its 72nd United Nations General Assembly (UNGA), proposed a resolution that emphasizes the sustainable development and integrated management of water resources in rivers, granting clean water and available for a decent life. The President of the 72nd UNGA highlighted in his speech to ensure that to obtain the Sustainable Development Goals (SDGs 6) need more than government actions, the cost for the empowerment of these infrastructures and the water systems would cost too much investments. However, to create successful scenarios for innovation and entrepreneurship to the monetary resource to be acquired from several sources would ease the project's total cost. The National Water Agency of Brazil (ANA, 2009), declares that Brazil holds 12% of world's total fresh water, where 68% is in the country's northern region and the other 32% are unequally distributed around the other regions. In a survey done by TrataBrasil Institute and GO Associados (2019), it was revealed that the expenses with water wastage in the country cost exactly 11 billion reais, that is an outcome of the misuse done by industrial, residential and agricultural consumption. Nevertheless, many other factors worsen this situation, like clandestine connections, reading failures and several pipe leaks. The national average loss of potable water was 38%. It's 6,5 billion of m³ of water, the equivalent to more than seven thousand Olympic-size pools per day being emptied. This wasted volume could supply 30% of the Brazilian population in a year (CFA, 2019). On average, in a house with up to four residents, the expected consumption per month is 22m³ of water. This divided for each resident is 5,5m³ that is wasted in unnecessary ways most of the time, either by a longer shower or by do not closing the taps correctly (Akatur Institute, 2014). Given the mentioned facts, it's necessary to adopt measures that can lower the water waste in Brazil, aiming the society awareness about its consumption, like social projects and monitoring systems that are reachable to all consumers, in order to bring economic and ecological benefits to society, leading to good practices of consumption and reducing water waste.

Microcontroller:
The microcontrollers are great options to develop electronic prototypes, for their small size and have a good cost/benefit relation. Besides that, they hold inner devices that provide autonomous operation. According to SILVA (2009) Arduino microcontrollers are computers with specific goals of prototyping, and present small sizes, low cost and low power requirement. As a result of these factors, there are many ramifications of applications in the industry like home appliances, toys, electronics, war material among others. In view of the referred aspects, according to MARCHESAN (2012) concludes that Arduino provides a hardware interface that offers all necessary circuits to the operation of the microcontroller and a software's interface and ambiance for programming. Being an open-source platform, there is a vast community of programmers from all over the world that publish libraries with all necessary documentation and available code ready to use, with specific functions, for example, the servomotors' control or the analogical sensor's reading. One of the tools of an Arduino interface is the serial monitor that connects the computer and the microcontroller. It shows in form of text, of great importance for the preview of the received data and very useful for debug.

Sensors:
Sensors are devices that have major importance along with the Arduino microcontroller, they are capable to interact with the environment that are exposed to, depending to their specification. These electronic components convert the interactions in electric signs that can be interpreted by electronic equipment that is able to correspond. The ones that have analogical outputs have their value oscillating according to the variation of the measure unit and type of entries. Those which have digital output, usually binary digital, admit just two defined values. Sensors are devices that work with physical quantities, as temperature, pressure, presence, moisture, luminosity, among others. The measured quantities are combined in order to obtain information about the physical environment where they are present. In general sensors act transforming parts of a physical quantity in an electrical sign, that can be interpreted by certain equipment (BORGES & DORES, 2010). In other words, sensors are electronic components that allows an electronic equipment to interact with the world. Among the many types of sensors, will be presented, during the next topics, the important sensor that will be collecting the data to later be calculated in the presented work, the flow rate sensor.

Flow Rate Sensor:
The water flow rate sensor is composed by a plastic body, a rotor, and a Hall effect sensor. Whenever the water flows through the rotor, it will spin and will influence directly in the pulse rate, and through theses pulses that are delivered by hall effect sensor it's possible to know its flow rate.

Mobile Application Development:
This section is dedicated to present several languages and tools that were studied and utilized in the development of the application's interface and even the manipulation of the collected data on the proposed project. Its purpose is to storage many information that can be accessed anywhere by the Internet. Java Script: JavaScript it's the language of the Web programming. The great majority of the modern sites uses JavaScript and all the modern browsers -in desktops, game consoles, tablets and smartphones -include JavaScript interpreters, making it the most omnipresent programming language of all time. JavaScript is part of the triad of technologies that all Web developers must know: HTML, to specify the Web page's content; CSS, to specify the presentation of these pages; and JavaScript, to specify their behavior. This book will help to dominate the language (Flanagan-1996).
Node JS: The Node.js was born in 2009, presented as a proposal to be a non-blocking architecture. The Node.js makes the most of available resources a grant a good performance in systems that work with high loads of processing. It's a lowlevel scalable platform, where the programmer works with network protocols and internet or uses specific libraries to a certain task (Pereira, 2014). The language used on the Node.js is the JavaScript, because its construction was based on JavaScript V8 engine (Node.js, 2016).

Visual Studio Code:
Visual Studio Code is a light, but powerful code editor, that runs on desktops and is available for Windows, macOS and Linux. It comes with intense support for JavaScript, TypeScript and Node.js and have a rich ecosystem of extensions for other languages(such as C++, C#, Java, Python, PHP, Go) and runtimes(like .NET and Unity) (Visual Studio Code, 2020).
NPM: Node Package Manager (NPM) is a package manager that is installed along with the Node.js. Npm gives you the ability to download modules or packages from Node.js to extend the functionalities of the application. Currently, there are over 46.000 packages available through NPM, giving an indication on how much knowledge and experience can be brought to the application. The packages at NPM varies too much in what they offer. (HOLMES, 2016).

React:
React is a popular library used to create user interfaces. It was built at Facebook to address some of the challenges associated with large-scale, data-driven websites. When React was released in 2013, the project was initially viewed with some skepti-cism because the conventions of React are quite unique. (Banks & Porcello, 2017). React is a JavaScript library that makes the creation of Uis more interactive and turn it in to an easy task. Create simple views for each state of your application, and the React will update and renderize in an efficient way just the required components as far as the data changes. Declarative views make your code more predictable and easier to debug.
React Native: React Native is a JavaScript framework for writing real, natively rendering mobile applications for iOS and Android. It's based on React, Facebook's JavaScript library for building user interfaces, but instead of targeting the browser, it targets mobile platforms. In other words, it enables web developers to write mobile applications that look and feel truly "native," all from the comfort of a familiar JavaScript library. Plus, because most of the code you write can be shared between platforms, React Native makes it easy to simultaneously develop for both Android and iOS (EISENMAN, 2016) Mongo DB: MongoDB is a database manager documentoriented written in C++, under the license of GNU AGPL (Affero General Public License) version 3.0, that storage data inside of documents in the BSON (Binary JSON) format, a "binary" version of JSON (JavaScript Object Notation). This database was created by Dwight Merriman (ex-Founder of DoubleClick and CTO) and Eliot Horowitz (CTO 10gen e cofounder) based in their own experiences of big data, high availability and robust systems. (MONGODB, 2018). According to Cross et. al. (2018) ability to storage objects in the JavaScript format natively of MongoDB, allows to reduce processing time, making the data manipulation faster. Rather than a specific language to domain SQL, MongoDB uses a JavaScript interface to easier to make SQL queries. Consult a document is simple as pass a JavaScript object that partially describes the search destination. And like this, MongoDB became the most indicated NoSQL database for the prototype development because of performance worries, processing a large amount of information in a matter of seconds, besides is a free software.

MATERIALS AND METHODS
For the identification of the main problematic to be discussed about excessive consumption of water, e divided in two phases: I) Bibliographic Research: We considered the documentations made available by the United Nations about the current situation of world's water resources, by the studies published by The National Water Agency of Brazil about how the water fit to residential consumption is divided in the Brazilian territory. II)Quali-quantitative Research: For the survey that will be applied in a mixed questionnaire, composed by 13 objective and 2 subjective questions, with random audience. We provided this questionnaire online to obtain the opinions of our target audience about the addressed subject. III) Documentary Research: The data presented by The Brazilian Council of Administration (CFA), the research by TrataBrasil Institute and GO Associados of how much the excessive water waste and lack of maintenance of pipes cost to Brazil. IV) Case Study: According to Sistema Nacional de InformaçõesSobreSaneamento (SNIS, 2018), the Brazilian average consumption is 154,9 (l/inhab. /day), even with the World Health Organization recommendation of a consumption of 110(l/inhab./day).
The materials used on the project were: ARDUINO MEGA 2560 BOARD -Using Arduino's own IDE to program, the code interacts with the flow rate sensor, that returns the collected data that will be treated, calculated and then exhibited in the IDE's serial monitor. After the microcontroller being programmed, it's necessary to build the circuit to interact with the sensor, WATER FLOW SENSOR YF-S201 -This sensor was utilized to obtain the data about the water flow of a residence, attached to the Arduino, it's responsible to send the collected data every time and send directly to the microcontroller, VISUAL STUDIO CODE 1.42.1 -Utilized to build the interface and the treatment of the received data from the Arduino.
JAVA SCRIPT -Utilized programming language for the creation of the application's interface. NODE JS -Used for the data treatment of the systems. NODE PACKAGE MANAGER (NPM) -Utilized to download the packages used for the application proper running, SERIAL PORT -A NodeJS package utilized to access serial ports using JavaScript, REACT -JavaScript library utilized to build the application, REACT NATIVE -JavaScript library utilized to build the mobile application, MONGO DB 4.0.0 -Database utilized to store the data, GIT 2.25 -Utilized to organize and version the whole project.

RESULTS AND DISCUSSION
Considering the great disordered population raise in urban centers and the great water consumption in residences, the water waste has been a factor responsible for many environmental problems faced recently. The Brazilian people consumes in average 154 liters of water by day, exceeding the required quantity established by the World Health Organization. Bearing in mind that the Brazilian territory is found in 4th place on the Superficial Fresh Water Distribution Ranking in the world(ANA, 2009) and for attending over 80% of the population with water supply(SNIS, 2018), the failures in readings, pipe leakings, in addition to clandestine connections, end up harming this advance, that in turn, raise the expenditure with the waste of this primary resource to evolution of society. In the last survey made in 2019, by TrataBrasil Institute and GO Associados, the accounting of these many factors added up an average loss of potable water equals to 38,3%, an amount enough to supply 30% of the Brazilian population. A monetary cost with this wastage was of 11 billion reais for the country. In our residences we still maintain habits that contribute to a bad management regarding the water consumption, practices that hasten a future shortage. The average expenditure with treated and piped water it's about 5,4m³ per people/month. The survey made about the profile of water consumption on Brazilian households indicates how much was utilized in each daily task. In this survey the item that showed the highest consumption rate was the shower presenting 13,9% of total consumption on the studied households, followed by the sink tap, presenting 12,0% of consumption.
Other uses like, laundry, cistern, washroom tap, and water tank contemplate 74,1% of this consumption. As a matter of knowledge, if we brush the teeth with the tap open for just 5 minutes, 12 liters of water are spent, while the same action taken with closed tap consumes just 0,5 liters. In the case of shower, in 15 minutes are spent 135 liters of water, exceeding in 300% what was fixed by the WHO as an ideal shower for sustainable use. Given the presented arguments, the water flow management system has as a purpose a simple mean to aware the consumers with quantitative data of water consumption and converting the value in Reais depending on the user's region. The system uses a database to show graphics and comparisons about daily, weekly, monthly and yearly performance, in addition it presents the periods of the year that occur raise in water expenditure and suggests strategies to save on consumption, besides it shows alerts to aware the user about water wastage and how much it will cost financially. Recently the idea of having connected residential devices is gathering strength in the technological market. All this attention boosts the creation of new devices capable of making a specific task ever more productive, as the case of the Water Flow Management, that can offer the calculation in real time of the spent value when water is used in the residence, giving more control over the resident consumption.

Application Development
Hardware Water Flow Sensor: Utilizing a flow rate sensor of ½ inches connected to an Arduino board, we could accomplish the capture of pulses that are received by this sensor through the rotation of the blades located at the turbine, so, every time the water flows through the sensor will make the blades spin and each time a blade pass by the magnet located in fixed point over the rotor, the Hall effect sensor generates a pulse.

Fig. 1. Water Flow Sensor
Arduino Mega 2560 Board: The microcontroller board is responsible to make the treatment of the pulses received by the sensor so we can perform the flow's calculation and send to the application.

Fig. 2. Arduino Mega 2560 Board
Before forwarding commands that will be utilized by the Arduino it's necessary to build the circuit that connects the Arduino Mega 2560 Board to the Water Flow Sensor YF-S201 as shown on Figure 3 and Figure 4. After being applied the logic of how our hardware will operate, we will forward to the next step, to transmit the information the board receives to the application.
Source: Authors, 2020.  Software: Initially was utilized the Arduino's IDE to develop the commands that will be needed to have interaction between the Arduino board and the sensor represented in Figure 4. Firstly, was created the code to the microcontroller convert the pulses generated by the rotor in consistent data, to obtain information about the flow through the following formula: Once obtained the water flow, is necessary to convert it in liters. For this problem we applied the following logic: Source: Authors, 2020.

Fig. 5. Arduino's IDE's screen
With the implementation of a JavaScript algorithm that will be responsible to the connection between the Arduino board and the application was possible to gather the same information that the board receives. It was utilized together with NPM package manager to import a SerialPort library to perform the capture of information that will be later inserted on the MongoDB database shown on Figure 6.

Fig. 6. Creation of the JavaScript Algorithm
In the application's interface development was utilized the editor Visual Studio Code, because it's a low storage demand software to produce applications with extensions that enhances the project's building, fast and multiplataform tools. It was utilized the JavaScript language and the libraries React and React Native to develop the app screens as shown at Figure 7. Through NPM was possible to download the utilized packages in the screen's development.

Fig. 7. Creating the Mobile Application
Home Screen: The application's main screen, it contains all the important information to the user. On the upper part, it's shown the consumption in cubic meters and its equivalent cost in monetary value. In the section 'Consumption History' is found a summary of how much was spent on the previous month, and the values that will be used to the calculation basis. Right bellow there is a notification area, where the system will show warnings telling how to save water, consumption statistics and systems warnings.

Fig. 8. Home Screen of Hydro Application
Daily Screen: On this screen is present the history of the past days of the user's consumption, showing how much water he used and how much it cost, besides a classification about its expenditure.

Fig. 9. Daily Screen of Hydro Application
Profile Screen: On the profile screen all user information is available, such as name and figure, right below there is the 'Consumption Calculation' that are consumption metrics utilized to perform the calculation, with the difference that in this screen the user can change these metrics and, finally, there is the section 'Your Consumption' where the user will define a monthly expenditure goal for the system to analyze the consumption and report the goal progress.

Fig. 10. Profile Screen of Hydro Application
Surve: Observing the analyzed aspects, the implementation of the water flow management system will benefit and hel society to have consciousness about its expenses. Were interviewed 101 people with a 16 questions questionnaire and to demonstrate the results will be showed the Graphics of 6 questions that are crucial to the research to be aware about the application and the utility of the presented system.

Graphic 1. Percentage of people interested in environmental issues
In the Graphic 1, 23% of the interviewed are mindful about environmental related issues, so, they are active in ways to lower the environmental impact. 72% are aware of the actions that affect the environment but are not that active in actions that can help to lower the impact. And 5% of the interviewed does not have any interest in the subject.
Graphic 2. Percentage of people that are aware of their monthly water consumption On Graphic 2, were obtained the results of 51% to yes regarding the awareness to their own water consumption, demonstrating that most people are conscious about their monthly water consumption.

Graphic 3. Percentage of people who would use a water consumption monitoring system
The Graphic 3 shows the percentage of people who would use a system that help the monitoring of water consumption. With results of 96% to yes. A water monitoring system would be useful to a society that seeks clarity about water consumption.
Graphic 4. Percentage who would like to compare their water consumption with previous months On the Graphic 4, is possible to notice the need of society to compare the consumption across the months, obtaining 89% to 'yes' answers. The idea for comparing the records is too aware about the periods that have increased water consumption and reduce it and show to the user when is consumed more. However, 11% of the interviewed, do not think this is relevant.

Graphic 5. Percentage of monthly expenses with water
On Graphic 5, is possible to observe the expenditure of people with water, obtaining 55% to less or equal to R$ 100,00. 24% less or equal to R$ 200,00. 9% less or equal to R$ 300,00, also 9% less or equal to R$ 400,00 and finally 3% of the interviewed say the spent values lesser or equal R$ 500,00.

Graphic 6. Percentage of expenditures that interviewed people judge as an ideal to water consumption
The Graphic 6 is shown the value that people would like to pay for their water consumption. Were obtained results of 84,2% for less or equal to R$ 100,00. Demonstrating the need to a project that motivates to save and aware society about its water consumption.
On Graphic 7, 43% of the interviewed concluded that the system will help in the environmental awareness, other 29% judge that it will be useful on expenses control. 16% believe that it will help to reduce water wastage, avoiding a future shortage. 12% do not know how to answer. According to the results, can be concluded that the project will be beneficial to society regarding to economy and environment.
Graphic 7. Percentage of the importance that people judge on a water flow management system

Conclusion
In virtue of what was previously mentioned, the concerns regarding the water available in the planet became focus of many environmental organizations. The lack of awareness of people to preserve this resource worsen even more this situation. The water excessive consumption in residences, although is not the highest compared to agricultural and industrial consumption, is the most worrying, as in the last surveys the wastage numbers only raises. With the obtained results through the survey done, its notable the following situation: there is people seeking to a better awareness about environment and economy that help them to improve their daily habits, such as using systems that help with this improvement and lower the excessive expenditure regarding water consumption. Our solution to a residential water consumption control showed promising informing the resident on how its water consumption is, displaying statistics, tips and its progress towards a better awareness to environment. The project is an alternative to the user to have a better control over the water consumption in its home, warning that bad habits can bring severe consequences to environment, to the people around and for itself.