# Usage of IoT Framework in Water Supply Management for Smart City in Nepal
## 3 Proposed Methodology
### Working Mechanism
The annual data of any province/state can be computed using the following equation:  
\[CL_{Year}^{State\_Number}=\sum_{House\_Number}\Biggl{[}\sum_{Day=1}^{365}\left(CL_{ Day}\right)\Biggr{]}\ litres/year \tag{6}\]  
Eventually, the overall consumption of water in a country can be discovered using the equation:  
\[CL_{Year}^{Country}=\sum_{State=1}^{N}\left(CL_{Year}^{State\_Number}\right) litres \tag{7}\]  
Equations (5)-(7) provide the information for consumption of water in the entire country which can be used by the department of water supply. Table 3 provides the technical specifications and limitations of device associated in this research work. The resolution of the ultrasonic sensor used in this research is 2 mm. Also, it cannot measure distances less than 20 cm and greater than 450 cm. Also, during the experiment, a minimum of 50 microseconds was needed for each consecutive measurement. Also, the sensor sometimes threw up an error measurement which was mitigated by using software that incorporates moving average and exception handling technique. Uncertainty quantification of the sensors was conducted. The systematic uncertainty \((S_{U})\) is the sum of error data generated by the sensor \((S_{E})\) divided by the number of repeatability test and the random uncertainty \((R_{U})\) is the sum of error data generated while measurement \((M_{E})\) is taken in random manner. The total uncertainty \(T_{U}\) is the square root of sum of square of measurement error and square of error data generated by the sensor. A repeatability test, i = 1 to 50, was conducted before deploying the IoT system in the field. The systematic uncertainty \((S_{U})\) has been obtained as \(S_{U}=\pm 0.18\%\) and the random uncertainty \((R_{U})\) has been obtained as \(\pm 0.16\%\). The total uncertainty has been obtained as \(\pm 0.24\%\), which is computed using the equation:  
\[\text{Systematic Uncertainty }(S_{U})=\frac{1}{50}\sum_{i=1}^{50}S_{E} \tag{8}\]  
\[\text{Random Uncertainty }(R_{U})=\frac{1}{50}\sum_{i=1}^{50}M_{E} \tag{9}\]  
\[\text{Total Uncertainty }(T_{U})=\sqrt{\left(S_{U}^{2}+R_{U}^{2}\right)} \tag{10}\]  
The random uncertainty is less than systematic uncertainty and total uncertainty. Six different spots were considered for this study and the experiment as shown in Figure 2 was conducted for one house per spot. The experiment was carried out for 360 days. No flaws were discovered during the experimental period. Until 360 days there was no overflow of the water. The members of the house did not have to employ effort or time to switch on and off the motor. Here, \(N\) represents the number of states in any country. The data of the consumed amount of water was sent to the server and in the unusual condition, an appropriate message was sent to the user. Using this IoT application, a water supply corporation can cut the water supply line of the house that does not make the payment on time. Similarly, leakage of water in each house can be noticed by using this IoT application. The algorithm to identify the leakage of water from the house has also been developed as follows:  
Step 1: Continuously monitor the volume of water in both the tanks in the time span of 10 s. Step 2: Check the current volume with the previous volume of the bottom tank when the motor is off. Step 3: If there is any deviation, enable the interrupt and notify the user. Step 4: Compare the current with previous water volume in the upper tank at nighttime for one week. Step 5: If there is a constant deviation for each day, enable the interrupt and notify the user. If the difference of water level (i.e., 0 \(<\Delta W<\) 0.01 m) is considered an insignificant case (where \(LR=0\)), and no operation is done. However, when the value of \(\Delta W>\) 0.01 m, indicates that there is leakage (\(LR=1\)) and in this case, special notification is given to the user. Most strikingly, it must be noted that the algorithm for leakage monitoring is calculated at nighttime for the only reason that the motor does not get on at that time.