**Automated Alert System for River Water Level and Water Quality Assessment using Telegram Bot API**

Iman Hazwam bin Abd Halim<sup>1</sup>, Ammar Ibrahim bin Mahamad<sup>2</sup>, Mohd Faris bin Mohd Fuzi <sup>3</sup>

<sup>1,2,3</sup>Faculty of Computer and Mathematical Sciences, Universiti Teknologi MARA, Cawangan Perlis, 02600 Arau, Perlis, MALAYSIA**  
**

*hazwam688@uitm.edu.my, ammarmby99@gmail.com, farisfuzi@uitm.edu.my*

Received Date: \*date

Accepted Date: \*date

Published Date: \*date

**HIGHLIGHTS**

  - Monitoring system is a method that can be used to persistently updated on the river water status

  - Ultrasonic sensor is using soundwave to detect the water surface area

  - pH sensor is using two electrodes in the sensor to measures the pH level

  - Telegram application is an open-source cloud-based instant messaging service.

ABSTRACT

# *Technology has advanced to the point that it can assist people in their daily lives. Human beings may benefit from this development in a variety of ways. Progress in river water monitoring is also one of them. There are many advantages in improving the river water monitoring system. The objective of this project is to develop an automated system for monitoring river water levels and quality with push notification features. Internet of Things (IoT) was implemented in this research by using NodeMCU as a microcontroller to connect both ultrasonic sensors and pH sensors to the Internet. An ultrasonic sensor is used to read the water level, and a pH sensor is used to read the water pH values. The results show the successful output from all of 10 time attempts to obtain more accurate test results. The results will be averaged to be analysed and concluded from the test. All the tests include testing for the accuracy of the ultrasonic sensor, the accuracy of the pH sensor, and the performance of the internet connection using integrated Wi-Fi module in NodeMCU microcontroller. The system test also shows that it performs perfectly with the requirement needed to send the real-time status of the water level, water quality and an alert to the user using the Telegram Bot API. This research can help to increase the level of awareness of the river water monitoring system. This research was done by looking at people's problems in the vicinity of the river area by producing a system tool that helps to monitor the river water in real-time status.*

# *Keywords: monitoring system, NodeMCU, ultrasonic sensor, pH sensor, telegram, real-time status*

# INTRODUCTION 

# A river was a natural and typical freshwater that flows towards the ocean, sea, lake and also to another river. Rivers have been a source of food since time immemorial, especially to the locals. However, rivers could also cause floods and pollution which could be a huge harm to the local people. The flood is the most destroying catastrophic event that had been experienced in Malaysia. Flood regularly occurs on the east coast of peninsular Malaysia due to heavy rains brought by the northeast monsoon winds, especially in Kelantan, Terengganu and Pahang. Sometimes, these floods brought a great destruction which made the government to suffer in repairing the damage caused by the floods itself. In addition, there were also cases where the people did not go to the higher ground in time and ended up facing their own death. 

# Current method used which is the siren system warning also had caused someone who lived far away from the siren or lived in a soundproof house being unable to hear the siren. Moreover, one of the major reasons is the residents themselves when they did not take the warning siren seriously. It was discovered that the siren's crisis cautioning sound could not be separated from the sounds utilized during its typical activity (non‐emergency cases) and, in this manner, had neglected to react to it during a real crisis (Flood Risk Management, 2019). 

# Human activities, especially in manufacturing and development, had caused pollution to the river, damaging ecosystem and harming humans. For example, Sungai Langat water was unsafe to drink without being treated first due to synthetic pollution from pointed and non-point pollution sources, even though it was one of the critical water sources in Selangor, Malaysia. Besides that, low awareness of water quality could endanger our health in the future. There was a cycle when toxins were in the water. Toxins moved from the water consumed by animals and plants which humans ate until the contaminants entering the food chain (Rafia Afroz & Ataur Rahman ,2017). This is because people did not know about the level of water quality. 

# Previous work related to the water monitoring system was published by Gowthamy J et al., 2018 that proposed Smart Water Monitoring System using IoT. Gowthamy research’s objective was to develop a real-time system based on the Internet of Things (IoT) to monitor water level and quality using several sensors such as ultrasonic and pH sensors. This previous project used Arduino Uno and Wi-fi module as a component to send the data instead of using NodeMCU that had built-in Wi-fi. This system also had not equipped with an alert system to notify the users.

# Another previous research was proposed by Teetla Asha and Vidadala (2020) Srija, which was a wireless-based water level monitoring system using Arduino and Bluetooth. They have developed a system to measure water level using a sensor connected to the Arduino as a microcontroller and then send information to the registered mobile phones using a Bluetooth module. Compared to this project, they used Bluetooth module as a component to send information and buzzer as an alert to the users.

# This paper was proposed to develop a monitoring system with the ability to send alert notifications through the Telegram API Bot. In the next section, the methodology of the system developed will be discussed, as well as the test result that were conducted in the project.

# METHODOLOGY 

The waterfall model of methodology was adapted in this project. Five phases in this model have been adapted, which were the initiation phase followed by the planning phase, the development phase, the testing phase, and lastly, the documentation phase. All these phases will be used as a guide in this research until completion.

**Proposed Architecture**

Figure 1 shows the general purpose of the system. This project was developed for monitoring water level and pH level in real-time status. The water level was measured by using an Ultrasonic sensor and pH level using a pH sensor connected to a microcontroller. The architecture from the prototype, that takes data from both sensors were sent to the NodeMCU to be analysed. The NodeMCU with built-in Wi-Fi was connected to the access point that has been configured to connect to the Internet. The following process was continued in the HTTP API cloud server, and then the message was sent to a Telegram API Bot, which replied it into a chatbot. Users then could easily monitor water status using the Telegram application on the phone or the computer just by sending the command message through it.

![](6128afbb43c78_media/media/image1.png)

**Figure 1:** Automated Monitoring System for River Water Level and Water Quality Architecture

Water level was measured by an ultrasonic sensor connected to the microcontroller. Figure 2 showed the flowchart for water level monitoring. An ultrasonic sensor has two different components, which are the transmitter and receiver. First, the transmitter will transmit a sound wave to the surface, and then the reflected soundwave from the surface will be received by the receiver. The duration from transmits and receive of soundwave will be used to measuring the distance. NodeMCU will perform calculations, and if the water level exceeds the limit of save level, an alert will be sent to the user.

![](6128afbb43c78_media/media/image3.jpeg)

**Figure 2:** Flowchart for Water level monitoring

For measuring pH level, an electrode pH sensor was used. pH sensor had two electrodes in the sensor. The first electrode is the reference electrode, and the second electrode is known as an internal electrode. When the pH sensor probe was dipped in the liquid test, the electrochemical potential was created by hydrogen ions in the liquid exchanging other positively charged ions and supplied to the electronic amplifier module, which detects the potential between both electrodes and the difference between these potentials gives the pH value. Figure 3 shows the flow of the pH sensor in the system. The results from the pH sensor were sent to the microcontroller, and then alert was sent to the users if the pH level was under 6.5 or exceeds 8.5 value which was out range of the neutral water pH value.

![Diagram Description automatically generated](6128afbb43c78_media/media/image4.png)

**Figure 3:** Flowchart for pH level monitoring

**Prototype Development**

For the prototype development, this project used a square container to house a breadboard with a microcontroller and power supply adapter. A hole was created on the side of the container for the Ultrasonic sensor and pH sensor wires. On the container's lid, the LCD will be placed to display the data to the user. The power supply of the prototype was obtained from a power bank or Universal Serial Bus (USB) port. Figure 4 shown the prototype that had been built for the system.

![](6128afbb43c78_media/media/image5.png)

**Figure 4:** Prototype of Automated Alert System for River Water Level and Water Quality Assessment using Telegram Bot API

Figure 5 showed that the schematic diagram that was used in the project. For the prototype, NodeMCU ESP8266 version 3 was used as a microcontroller and as the component to transmit the data with its built-in wi-fi. Breadboard Power Supply Module was used because NodeMCU only supplied 3.3V instead of 5V used by the sensor. The Ultrasonic sensor was used in the project to measure the water level. Ultrasonic sensor transmitter sends the sound wave, and the receiver acts as a microphone to receive the echo from the sound wave. The distanced was determined by measuring time lapses between the sending and receiving of the sound wave. Next for water quality monitoring, a liquid pH sensor was used to measure the pH level of water. An LCD display was used to display the reading from ultrasonic sensor and pH sensor and the brightness of LCD was controlled by potentiometer.

For the source code, Arduino IDE software was used as a platform to write the code and upload the code to the microcontroller which was NodeMCU. The Telegram bot was created as a platform for the user to receive the information about the status of water level and pH level that the user can also access it from smartphone or computer.

![Diagram, schematic Description automatically generated](6128afbb43c78_media/media/image6.png)

**Figure 5:** Schematic diagram for the prototype

**FINDINGS AND DISCUSSIONS**

The system was evaluated by testing the performance of prototype’s sensitivity. This testing was conducted to see the output from the prototype through the LCD, and the result was sent to the telegram bot. The

prototype was able to send the alert to the telegram bot when the water level exceeds the level set in the system and when the pH level was at alkali or acid level. The LCD would display the water level and the pH level with the status neutral, acid or alkali. Table 1 showed that the water monitoring system test result that was conducted. The result showed that LCD display and Telegram bot has succeed to display a real- time reading from the ultrasonic sensor. The result also showed that the system was capable to send an alert to the user when the water level exceeded above 11 cm that has been set in the system.

**Table 1:** Water monitoring system push notification test result

<table>
<thead>
<tr class="header">
<th></th>
<th><strong>Water Level (CM)</strong></th>
<th><strong>LCD Display</strong></th>
<th><strong>Telegram Output</strong></th>
<th><strong>Resulted</strong></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>4 CM</td>
<td>Water Level: 4CM</td>
<td>Water Level: 8CM</td>
<td>success</td>
</tr>
<tr class="even">
<td>2</td>
<td>8 CM</td>
<td>Water Level: 8CM</td>
<td>Water Level: 4CM</td>
<td>success</td>
</tr>
<tr class="odd">
<td>3</td>
<td>11 CM (Alert set)</td>
<td>Flood Alert!!!</td>
<td><p>Danger water level!!!</p>
<p>Water level:11CM</p></td>
<td>success</td>
</tr>
<tr class="even">
<td>4</td>
<td>17 CM</td>
<td>Flood Alert!!!</td>
<td><p>Danger water level!!!</p>
<p>Water level:17CM</p></td>
<td>success</td>
</tr>
</tbody>
</table>

Figure 6 showed the sample output from Telegram for water monitoring push notification. On the left highlighted in red, it showed the output system which was sent to the user. Meanwhile, on the right highlighted in red, it showed the system was sending an alert to the user that the water was at the danger level.

![Graphical user interface, text, application, chat or text message Description automatically generated](6128afbb43c78_media/media/image7.jpeg)

**Figure 6:** Output on the Telegram bot for water monitoring push notification

Figure 7 showed that the result from the pH sensor accuracy test from different types of liquid. All the results read by the system were compared to the result by litmus paper. It showed that the system reading was able to give a precise read of pH level.

![Chart, line chart Description automatically generated](6128afbb43c78_media/media/image8.jpeg)

**Figure 7:** pH sensor test

Table 2 showed the results from pH monitoring system test that had been conducted. An alert had been set if the pH level was below 6.5 and above 8.5. According to the Environmental Protection Agency (EPA) and World Health Organization (WHO), the acceptable pH range of drinking water is between 6.5 and 8.5. The system test successfully showed the LCD with the accurate real-time reading and sent the information to Telegram user. The table also showed that the system succeeded in sending an alert when the pH level was below 6.5 or above 8.5 to the user.

**Table 2:** pH monitoring system push notification test result

<table>
<thead>
<tr class="header">
<th></th>
<th><strong>PH Level</strong></th>
<th><strong>LCD Display</strong></th>
<th><strong>Telegram Output</strong></th>
<th><strong>Resulted</strong></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>Vinegar</td>
<td>PH:2.55(Acid)</td>
<td><p>Water PH at Acidic level</p>
<p>PH:2.55</p></td>
<td>success</td>
</tr>
<tr class="even">
<td>2</td>
<td>Drink water</td>
<td>PH: 7.16(Normal)</td>
<td>PH: 7.16</td>
<td>success</td>
</tr>
<tr class="odd">
<td>3</td>
<td>Milk</td>
<td>PH: 6.95(Normal)</td>
<td>PH: 6.95</td>
<td>success</td>
</tr>
<tr class="even">
<td>4</td>
<td>Soap</td>
<td>PH:8.94(Alkali)</td>
<td><p>Water PH at Alkali level</p>
<p>PH:8.94</p></td>
<td>success</td>
</tr>
</tbody>
</table>

Figure 8 showed that the system sent a real-time reading to the user. On the left highlighted in red, it showed the reading for the drinking water. On the right highlighted in red, it showed an alert that was sent from the system to the user because the pH was at the Alkali level.

![](6128afbb43c78_media/media/image9.jpeg)

**Figure 8:** Output on a Telegram bot for pH monitoring push notification

**CONCLUSION AND RECOMMENDATIONS**

The prototype system had successfully passed all the testing that had been conducted. The project's objective was achieved which was to develop a system that could measure water level, and quality level of water and sent the information to the user using Telegram. The reading of water level height measured using ultrasonic was accurate comparing to manual measurement. Using the pH sensor, the pH reading of different types of liquid could be obtained quickly and precisely. Although all the objectives had been fulfilled, this project had several limitations. Due to the COVID-19 pandemic, the prototype system was not appropriately tested to the public or in real environment. Instead, the demo was only shown to the respondents via video demonstration. For the future work, this system can be improved by testing the system in real environment so that the data collection can be more accurate than the indoor simulation testing.

**REFERENCES**

> Gowthamy J, Chinta Rohith Reddy, Pijush Meher, Saransh Shrivastava, & Guddu Kumar. (2018). Smart Water Monitoring System using IoT. International Research Journal of Engineering and Technology (IRJET), 05(10), 1170–1173. https[://www.irjet.net/archives/V5/i10/IRJET-](http://www.irjet.net/archives/V5/i10/IRJET-) V5I10219.pdf
> 
> Mohsen Nasirian. (2007). Journal of Applied Sciences. A New Water Quality Index for Environmental Contamination Contributed by Mineral Processing: A Case Study of Amang (Tin Tailing) Processing Activity, 7(20), 2977–2987. https://doi.org/10.3923/jas.2007.2977.2987
> 
> Mrs. Teetla Asha, & Mrs.Vidadala Srija. (2020). Design and Implementation of Wireless Based Water Level Monitoring System Using Arduino and Bluetooth. International Research Journal of Engineering and Technology (IRJET), 07(01), 745–749. https://[www.irjet.net/archives/](http://www.irjet.net/archives/) V7/i1/IRJET-V7I1122.pdf
> 
> Rafia Afroz, & Ataur Rahman. (2017). International Journal of Advanced and Applied Sciences. Health Impact of River Water Pollution in Malaysia, 4(5), 78–85. https://doi.org/10.21833/ijaas.

2017.05.014

Tarek Mohammad. (2009). Using Ultrasonic and Infrared Sensors for Distance Measurement. World Academy of Science, Engineering and Technology, Hong Kong. https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.193.4326\&rep=rep1\&type=pdf
