Design and Implementation of a Microcontroller-Based Water Turbidity Detector Utilizing the Nephelometric Turbidity Unit Method

The objective of this study is to create a water turbidity detection system, aiding customers of a municipal water supply company in preserving the quality of water for everyday use. The aim is to prevent the mingling of stored clean water with turbid water when the tap is turned on. To achieve this, we employ a smartphone as a remote control device, enabling users to monitor the water's condition remotely. The study's findings demonstrate that this system adeptly manages the water separation process based on its condition, allowing manual control via Bluetooth communication within a maximum range of 10 meters. This setup provides two control options: activating and deactivating the water channel through a solenoid valve. Test outcomes indicate the system effectively segregates the water as per its condition and promptly follows user directives.


A. Introduction
Water is a fundamental necessity for all life forms, indispensable for their existence, and impossible to substitute.Its significance extends beyond humans, encompassing the well-being of animals and plants.Human requirements related to water encompass drinking, culinary use, sanitation, and various other applications.Clarity is a crucial criterion for water to be considered suitable for consumption.
In contemporary times, individuals rely on Regional Water Companies (PDAM/PAM) to meet their daily water requirements.However, during the rainy season, particularly when there is prolonged and intense rainfall, the water supplied by PDAM/PAM often becomes cloudy.It may contain impurities like mud from the water source.Consequently, this water is unsuitable for consumption.When PDAM/PAM supplies turbid water, it immediately flows into the clean water storage tank upon opening the tap.This leads to a direct mixture of turbid water with the previously stored clean water.
To resolve this concern, a tool is essential for detecting water turbidity and autonomously segregating the turbid water.This tool is anticipated to uphold the water quality utilized by PDAM/PAM customers, ensuring its suitability for consumption.
Previous studies have delved into the detection of water turbidity [1] [2] [3] [4] [5].These earlier investigations lacked features for automatic and manual water segregation and accessibility to water turbidity information via a smartphone application.This article introduces an automated water turbidity detection system designed to separate clean and murky water discharged by the Regional Water Company (PDAM), relying on Nephelometric Turbidity Unit (NTU) values.The associated smartphone application gathers reports on water turbidity and allows for manual system control.The primary objective of this study is to create a water turbidity detection system that aids in overseeing and upholding water quality.The system's assessment results affirm its accuracy in distinguishing between clean and murky water.This paper's essential contribution lies in detailing the utilization of NTU-based turbidity for separating clean and murky water, employing a straightforward approach applicable in diverse contexts, particularly households.
The paper is organized as follows: Section B explains the method of water turbidity measurement.Section C outlines the research methodology used.In Section D, we present the results and discussion.Finally, Section F provides the conclusions.

B. Method of Water Turbidity Measurement
There are two methods for measuring water turbidity: turbidimetry and nephelometry.Turbidimetry is a quantitative analysis method based on light scattering by solid substances.At the same time, nephelometry measures the intensity of scattered light as a function of the concentration of the dispersed phase.Turbidity measurements obtained using turbidimetry and nephelometry methods are expressed in Nephelometric Turbidity Units (NTU).
The method chosen for measuring water turbidity in this study is turbidimetry, as it provides a broader range of turbidity values compared to nephelometry.The standard instrument used for calibration and comparison with the designed device is the Turbidity Meter Model 800. Figure 1 illustrates the schematic differences between nephelometry and turbidimetry methods.The turbidimetry measurement method is based on the phenomenon of light transmission that occurs when light passes through suspended particles in a liquid.Turbidimetry is a method for measuring the level of water turbidity by passing a light source through the water, allowing the intensity of light transmitted through the materials causing turbidity to be visible or detected by a detector.The higher the intensity of transmitted light, the lower the level of turbidity will be [6].This method compares the intensity of light transmission caused by the water sample under the same conditions.The higher the intensity of light transmission, the lower the scattering of light.This method is very suitable for measuring turbidity with a wide range of NTU values.

System Design
This water turbidity detection system utilizes an LDR sensor to detect potential water cloudiness.Subsequently, the values read by the LDR sensor are processed by a microcontroller, namely the Arduino Uno.The operation of this water turbidity detection tool is illustrated in Figure 2  The main functions of this system are as follows: (1) Users can view the real-time water turbidity level in NTU units through the mobile application on their connected smartphone.(2) The system can control the solenoid valve to automatically stop or allow the flow of water to the corresponding faucet.(3) Users also have manual control through the mobile application on their smartphone to release water when needed.To illustrate the working process and functionality of the system, we present an activity diagram in Figure 3.
The system workflow begins with initialization, such as variable declaration and configuring all pins connected to the microcontroller, as well as activating Bluetooth communication with HC-05.Next, the system enters the Water Flow function.If the user's smartphone is connected to the system, it will send data to the smartphone containing information about the water turbidity level.There are three water conditions: first, "no filter needed," which means the water is in very good condition (turbidity value <= 5 NTU); second, "slight," which means the water condition is still acceptable for the user to use (turbidity value 6-20 NTU); and lastly, "filter needed" (turbidity value >20 NTU).If manual control by the user is required, they can input the desired command.If the user has given a command through the mobile application on the smartphone, the microcontroller will process the manual control function.

Hardware and Software Design
The block diagram of this system design is shown in Figure 4.The hardware components used to construct the water turbidity detection system for the clean and dirty water separator based on nephelometric turbidity unit values are as follows: • Arduino UNO, used for overall system control.
• Relay, employed to amplify the current for Solenoid Valve operation.
• Solenoid Valve, utilized to open and close the water flow.
• LDR Sensor, employed to detect the physical properties of the water, determining whether it is clear or turbid.• Bluetooth communication module HC-05, used to transmit data from the microcontroller to the mobile application embedded in the smartphone, and vice versa for manual commands from the user through the mobile application to the microcontroller.• Smartphone communicates with the microcontroller via Bluetooth.The smartphone also serves as the interface with the user.In software design, a flowchart is used to depict the workflow, as shown in Figure 5. Figure 6 illustrates the logic workflow on the microcontroller.The system read the sensor output value, which is in ADC, and then the microcontroller will convert it into turbidity units (NTU).If the turbidity value is <= 5 NTU, solenoid valve 1 will open, and conversely, solenoid valve 2 will close, ensuring that water only flows through tap 1 to the clean water storage outside the user's house.If the turbidity value ranges from 6-20 NTU, a "No consumable Water" warning will appear, and the user has the option to control manually.By default, if the user does not provide control commands, the system will direct the water to tap 2 leading to the turbid water storage outside the user's house.If the turbidity value is > 20 NTU, the turbidity level is no longer tolerable, and the system will automatically channel the water through tap 2 to the turbid water storage outside the user's house.

Figure 5. Flowchart of programming on the microcontroller
The NTU value processed by the microcontroller will be sent to the Android application after the smartphone is connected via Bluetooth.Logging into the application is required to view this NTU value.Subsequently, manual control to separate clean and dirty water can be done by activating manual control.Figure 6 shows the process of displaying the NTU value in the Android application.

Implementation System
The water turbidity detection system for water separation employs an LDR sensor to gauge the intensity of light passing through particles responsible for turbidity.This enables the system to collect data on water turbidity, which is then displayed on a smartphone screen.The hardware setup is depicted in Figure 7.
In Figure 7(a), various components are labeled as follows: a) a housing for the turbidity detection featuring LEDs and an LDR on its exterior; b) a relay functioning as a switch; c) an Arduino Uno acting as the central processor and controller of the entire system; d) a breadboard serving as the platform for connecting the components and the integrated Bluetooth device; e) an LDR employed as a sensor; f) solenoid valve 2, responsible for shutting off the water flow to the turbid water tank; g) solenoid valve 1, tasked with stopping the water flow to the clean water tank; h) tap 1, designated as the outlet for clean water; i) tap 2, designated as the outlet for turbid water; j) a storage tank for clean water; k) a storage tank for turbid water; l) a box representing the water source.The implementation of the user interface in the Android application is shown in Figure 8.In Figure 8(a), the login page of the application is visible.The connection between the smartphone application and the hardware device is established via Bluetooth.Figure 8(b) displays the smartphone application successfully connected to the Bluetooth HC-05 hardware device.The water turbidity value in NTU units is displayed on the smartphone application, as seen in Figure 8(c).Figure 8(d) shows the control page used for manual settings.

Testing and Analysis
Testing is conducted to assess the performance of this water turbidity detection device.The first test aims to measure the accuracy of the LDR sensor in detecting water turbidity.This test involves varying the distance and angle of light received by the sensor, namely 0˚, 15˚, 30˚, 45˚, 60˚, 75˚, and 90˚ (as seen in Figure 1).The test data is used to establish the characteristic equation of the LDR sensor in relation to distance and angle.In this test, the Turbidity Meter Model 800 with zero control calibration is used as a reference for calibrating the LDR sensor used in the research.The Turbidity Meter Model 800 can detect turbidity levels up to 200 NTU. Figure 9 displays the Turbidity Meter Model 800 used as a reference for LDR sensor calibration.

Figure 9. Turbidity Meter Model 800
The testing scenario involves comparing the turbidity values of the used samples, where tea and coffee solutions are employed as samples.Subsequently, the NTU values of the samples are compared between the Turbidity Meter Model 800 and the LDR sensor.A linear regression method is used to calibrate the LDR sensor by comparing the Analog-to-Digital Converter (ADC) values from the LDR sensor with the turbidity values measured using the Turbidity Meter Model 800.The results of this comparison will provide the characteristic formula of the sensor.Table 1 displays the test results of the sensor output voltage (in volts) with varying incident angles on the LDR sensor and compares them to an increase of 0.5 NTU units on the Turbidity Meter Model 800.

Tabel 1. Comparison of NTU Values (Turbidity Meter Model 800) with Sensor Output
Voltage at Angles 75˚, 60˚, 45˚, 30˚, 15˚, 0˚.Based on Table 1 above, equations were obtained for the angles 75˚, namely Y = 4.0418 -0.1257x.From this result, it can be concluded that every increase of 1 NTU will decrease the sensor output voltage of 0.1257.For the angle 60˚, the equation obtained is Y = 3.4984 -0.1393x, concluding that the sensor output voltage decreases by 0.1393 for every 1 NTU increase.At a 45˚ angle, the obtained equation is Y = 3.3013 -0.1855x, and the conclusion is that the sensor output voltage will decrease by 0.1855 for every 1 NTU increase.For the 30˚ angle, the obtained equation is Y = 2.6562 -0.2210x, with the conclusion that the sensor output voltage will decrease by 0.2210 for every 1 NTU increase.At a 15˚ angle, the obtained equation is Y = 1.6345 -0.2269x, and the conclusion is that the sensor output voltage will decrease by 0.2269 for every 1 NTU increase.Finally, the equation Y = 0.6498 -0.1550x indicates that the sensor output voltage will decrease by 0.1550 for every 1 NTU increase at 0˚ angle.
After obtaining the equations between NTU and sensor reading values, a comparison was made between the readings on the Turbidity Meter Model 800 and those on the designed device.Furthermore, calibration was carried out on the obtained results by calculating the absolute error.This was done by taking the difference between the turbidity value measured using the Turbidity Meter Model 800 and that measured using the designed device.The relative error was then calculated by comparing this absolute error with the actual measurement using the Turbidity Meter Model 800.The comparison of test results between the designed device and the standard device (Turbidity Meter Model 800) was conducted by placing the LED at a specific angle relative to the sensor position, as shown in Table 2.  Based on the comparison of turbidity values between the standard device and the designed device, the smaller the angle used, the narrower the range of turbidity readings, resulting in increased accuracy of the turbidity sensor at low turbidity values.Conversely, the more extensive the angle used, the more comprehensive the range of turbidity readings, but the accuracy of the turbidity sensor will increase at high turbidity values.Regarding NTU units, a 75˚ angle showed the lowest average error rate, 2.82%, with the most significant error reaching 10%.Therefore, this angle was chosen and implemented in the device design.For the 75˚ angle, the characteristic equation obtained is Y = [4.721]V + [-0.078]x, indicating a decrease of 0.078 V/cm.The characteristic graph can be seen in Figure 9.
Ten experiments were conducted in the functional testing of the device, as seen in Table 3.The system successfully transmitted turbidity values to the smartphone device in these experiments without errors.Meanwhile, the system operated smoothly in the automatic water flow experiment to the storage tank.The initial position of solenoid valve 1, closed, and solenoid valve 2, which was open, effectively detected the turbid water sample introduced into the turbidity detection box.As a result, turbid water did not flow through the main pipe.

Discussion
The main objective of this study is to develop a water turbidity detection system that can monitor and maintain water quality.The functional testing results indicate that the designed water turbidity detection and water separator system successfully detects turbidity values in NTU units with an error rate of 2.83% when compared to the standard turbidity tool, Turbidity Meter Model 800.

Figure 1 .
Figure 1.Scheme of water turbidity measurement using turbidimetry and nephelometry methods.
. Information regarding the level of water turbidity is transmitted to a smartphone via Bluetooth.If the detected water condition indicates turbidity, the microcontroller will command the Solenoid Valve to stop the flow of water to tap 1 (Solenoid Valve 1 will close and Solenoid Valve 2 will open), preventing water from coming out when tap 1 is opened, allowing water to only flow through tap 2. Conversely, if the detected water condition indicates clear or clean water, the microcontroller will command Solenoid Valve 1 to open and Solenoid Valve 2 to close, allowing water to only flow through the main tap (tap 1).

Figure 2 .
Figure 2. Architecture of the water turbidity detection system.

Figure 6 .
Figure 6.Flowchart displaying turbidity value on the smartphone application.

Figure 7 .
Figure 7. (a) Implementation of the water turbidity detection device for water separation, (b) Hardware components in the box, (c) Components of the turbidity detector box.

Figure 8 .
Figure 8. User interface on the Android application.

Table 2 .
Results of the proposed device testing with Turbidity Meter Model 800.

Table 3 .
Functional testing of proposed device