Analysis and Development of Seawater Density Measurement Algorithm Using Arduino Uno and YL-69 Sensor

In this research, an analysis was carried out to develop a measuring instrument for seawater density in salt production using a microcontroller (Arduino Uno) and YL-69 sensor, this sensor was commonly used to measure soil moisture. The experimental method was used in this research to produce initial data in the form of resistance and seawater density values, then calculations are carried out using statistical methods to find equations and produce a constant variable that connects the resistance and seawater density values. The equation was used to compile the algorithm into Arduino Uno. As for the results of this research, From six experiments conducted, two experiments produced the same sea water density value between the actual and the predicted, namely the 2 and 5 experiments, while for other experiments there was a difference between the actual and predicted values, however, it was not too significant, the difference occurs between the value range 0 ~ 1, to determine the level of error, use the Mean Square Error (MSE) with an error level of = 0.5 and Mean Absolute Error (MAE) with an error level of = 0.6. The contribution of this research is an algorithm that can predict the density value (baume) based on the resistance value obtained from the YL 69 sensor.


Introduction
Salt is one of the agricultural commodities spread in various regions in Indonesia, starting from Aceh, Java, NTB, NTT, and parts of Sulawesi. based on data in 2015, salt production is spread across 44 districts/cities with a total production amount of 2.9 million tons, an increase from the previous year which only reached 2.5 million tons [1], however, this increase has not been able to meet the need for salt in domestically, Indonesia still imports salt from other countries, the three largest importing countries are Australia, India and China [2]. data in 2013, namely China, the United States, and India [1]. Based on the above problems, a new innovation is needed to increase salt production so that it can meet national salt needs and improve Indonesia's ranking as one of the salt producers in the world. The production of salt in Indonesia is still dominated by the evaporation system, where the evaporation method was a process of forming salt crystals by heating using the sun's heat or by boiling it. In the process of forming salt crystals, farmers still use an estimation method based on community habits and some use a sea water density measuring instrument called Baume meter (Be), the Baume meter is being used by farmers today still a conventional measuring instrument where accuracy is needed in seeing the values stated in the measuring instrument, so that an accurate value will be produced, therefore an innovation of the density measurement tool (Baume) was needed which can make it easier to use and has a better level of accuracy, so based on the above problems, in this researched, a sea water density measuring instrument has been developed, There are several tools that have been used in previous research to measure the density of liquid objects, including; volume comparator type VC1005, manufactured by Mettler-Toledo GmbH, Switzerland. In accordance with the manufacturer's specifications, this tool is commonly used to measure the volume and density of solid objects [3], Besides VC1005, ultrasonic sensors has also been used by calculating the time interval required by a signal from the transmitter to the receiver [4], one of the liquids that have been measured using an ultrasonic sensor is a polymer, the ultrasonic sensor has been used to measure the density of polymer melts [5], however, in this research, researchers used a microcontroller which was integrated with YL-69 sensor [6], this sensor is commonly used as a sensor to measure soil moisture [7] By flowing current in the two probes so that there is resistance, the more liquid compared to the dissolved solid, the lower the resistance, while the conductivity will be higher, conversely, if more solids are dissolved than the liquid, the resistance will be higher and the conductivity will be lower. The Yl-69 sensor has been implemented, including in the irrigation monitoring system combined with the Internet of Things (IoT) system [8] the IoT system utilizes the ESP8266, a combination with Wireless Sensor Networks has also been carried out for monitoring rainfed rice fields [9], used in a plant growth monitoring system combined with a Wireless Sensor Networks (WSN) system [10], several studies have also been conducted to make moisture sensors with simple but highly accurate tools [11]. The Arduino Uno R3 is a microcontroller was used in this research, because of its ease of installation and use, the combination between the Arduino Uno R3 and the YL-69 sensor has been widely implemented in previous studies, among others, for automatic vegetable seeding, wherewith this system, farmers did not have to do periodic watering in the seeding process. In this system, the Arduino Uno was used as the main controller which integrated with a soil moisture sensor (YL-69 / LM393), and excited DC motor that functions to drive the sprinklers [12]. Another researched, the YL-69 and Arduino sensors have been used to regulated soil moisture in agarwood tree planting media, wherein the research conducted, if the soil moisture is> 80%, then Arduino command the Water Pump to drain water into the planting medium if the humidity is <= 80%, then the Water Pump stops the flow of water. In the research, the YL-69 processor had an accuracy value of 88.76% [6]. Researched by combining the YL-69 sensor, Ultrasonic Sensor and Arduino Uno R3 has been carried out for plant irrigation systems, the Ultrasonic sensor was used to detect water availability in the storage tank, the YL-69 sensor was used to determine soil moisture, the percentage of average error The ultrasonic sensor average was 4.91% while the YL-69 sensor was 3.285% [13]. Other research has also been conducted, where a humidity sensor was combined with a water flow sensor, a temperature and humidity sensor to regulated the irrigation system, a web-based application was used as an interface to facilitate the monitoring [14], a control system used Android applications has also been developed in irrigation systems. this researched aims to simplify and minimize costs incurred in the irrigation process [15]. However, from several studies that have been conducted, the YL-69 sensor has never been used to detect the concentration of seawater in the salt-making process. So based on these problems, in this research, aims to utilize the YL-69 sensor as a sensor to detect the density of seawater by changing the resistance value in the form of ADC (Analog Digital Converter) value generated by the sensor into a Baume (Be) value, The change in value is obtained from a comparison analysis between the resistance value generated by the sensor and the seawater density value generated by manual measurement, where the results of the analysis were used to build a algorithm and then compile it into a microcontroller. The distribution in the research is to produce a formula or equation to convert the values of the ADC from the YL-69 sensor to a baume (Be) values, which is expected to add a tool as a reference that will be used as a sensor to determine the density values of a liquid, in this case the density of sea water. The results of this study, the YL-69 sensor integrated with Arduino Uno has been able to measure the density of seawater in the salt production process. Of the 6 experiments carried out, 1 experiment produced the same actual and predicted value, namely the second experiment, while for other experiments there was a difference between the actual value and the predicted value, but not too significant, the difference occurred between the values 0 ~ 1, it was noted. one experiment that has a high enough error value, namely the 12th experiment has an error value = 1.4, the Mean Square Error (MSE) and the Mean Absolute Error (MAE) are used to determine the error rate, using MSE it is known that the error rate = 0.5 while using MAE = 0.6.

Research Method
In this research, two methods have been used, first by using experimental methods, this method was used to generate initial data, namely (1) density data and (2) resistance data were generated by the YL-69 sensor in the form of ADC values. The second is statistical methods, this method was used to determine the relationship between the two data above, so that an equation was generated which then converted into an algorithm.

Data Collection Process
There are several stages in the sample data collection process, starting with the seawater data collection process in salt production land, the seawater criteria used as the initial data must be clear and do not have a mixture of mud particles, if there is a mixture of mud particles, it needs to be deposited so that it is separated between both. After that, the evaporation process of the sample data is carried out, evaporation is a process of forming salt crystals from seawater by means of evaporation, in this research the evaporation process is carried out using the heat of the sun. Finally, the measurement process was carried out on the sample data so that 31 data were produced, there are two tools used, namely the Baume meter to measure the density of sea water, and the YL-69 sensor to determine the resistance value in seawater solutions. Both data are then used as initial data in this research.

Data Analysis
The data that has been obtained from the data collection process was analyzed using statistical methods to determine the relationship between seawater density and resistance. The analysis process is carried out by looking at the data that has been converted into curves in order to make it easier to see the relationship between the two data. This process produces an equation that connects the density and resistance values, then this equation is used to create an algorithm in the microcontroller system (Arduino Uno). To find out the accuracy of the predicted value generated by the algorithm that has been made, a comparison of the predicted value with the actual value is carried out, where the actual value is obtained by making direct measurements using Baume meter ( Figure  1). Meanwhile, to determine the error rate of the prediction results, the Mean Square Error (MSE) and Mean Absolute Error (MAE) equations are used.

Tools and Materials
There are several tools used in making the system, including (1) the YL-69 sensor with the LM393 Comparator Chip which functions as a sensor to determine the seawater density based on its resistance value, (2). The microcontroller, in this case, uses the Arduino Uno R3, (3) Power Supply or a battery as the input voltage, the required voltage is between 3.3 ~ 12 volts on the microcontroller, (4) i2C as a converter tool as well as simplifying the circuit to connect the microcontroller to the LCD (5) LCD 14x2 as a tool to display the seawater density and resistance values. these tools can be seen in the image below.

System Design
In this research, a tool to measure the seawater density in salt production land is produced. The tool made is still a prototype and can be developed further. system design can be seen in the figure 7. In the system design figure 7, it is explained that 4 tools communicate with each other, including (1) the YL-69 sensor. There are two pins with positive and negative currents, the function of these pins is as a medium for connecting with the probe, in addition to the two pins in, there are four pins out, including (1) the VCC pin is charged with a positive current with a voltage of 3 ~ 5 volts, (2) pin Ground, for negative current, (3) pin D0 for digital signal output and pin A0 for analog signal output. In this research, the pinout signal used is A0, because the expected output is an analog value with a value range of 0 ~ 1023. The function of the YL-69 sensor is to take the resistance value presented in the form of ADC (Analog Digital Converter) and then the value is converted into the seawater concentration value, Arduino Uno R3 with IC ATMega328P is a microcontroller whose job is to convert this value. There are three pin clusters in the Arduino Uno R3, including (1)  In Figure 8, it describes the system flowchart that is inserted into the microcontroller (Arduino Uno).

Figure. 8. Flowchart System
In the flowchart figure 8 above, it can be explained that there are several steps to determine the value of seawater density. (1) seawater density data was collected using the YL 69 sensor. This value is compared with the higher and lower limit values of the calibration results, (2) if the resistance value is higher than the upper limit, the density value = 0. (3) if the value The resistance is lower than the lower limit, the density value = 30. (4) If the resistance value is between the higher and lower limits, equation 3 is used to determine the density values.  (ADC)  0  96  1  93  2  88  3  89  4  77  5  75  6  74  7  71  8  69  9  68  10  68  11  66  12  66  13  67  14  59  15  55  16  52  17  51  18  52  19  44  20  36  21  35  22  35  23  31  24  30  25  28  26  24  27  23  28  20  29  16  30  8 To produce an equation that is used to create an algorithm whose system is able to predict the density value of seawater accurately, it is necessary to enter a constant into the equation, and to produce this constant a statistical analysis is performed. by making a comparison of the density value of seawater generated from the Baume meter (Be) with the resistance value in the form of an ADC generated by the YL-69 sensor. There are 31 data from manual measurements consisting of the Baume meter values and resistance values which are used as data for analysis. The measurement results are presented in Table 1.

Result and Discussion
The measurement results are presented with a curve can be seen in the image (Figure 9).
Based on the data in Table 1 and Figure 9 above, it can be seen that the relationship between the sea water density value (Baume) generated from measurements with conventional Baume meters (be) is inversely proportional to the resistance value generated by the YL-69 sensor, the higher the density value. , the lower the resistance value, thus forming a downward linear curve, this equation is often used for representation systems in fuzzy logic [16] (equation 3). Therefore, the equations used to construct the algorithm are uploaded to the microcontroller using a downward linear curve. In this equation, the constant value = 30 is added because the expected predicted value is between 0-30 as shown below in equation 4.   From table 2 above, it can be seen that there are three variables, namely the resistance variable, the actual sea water density and the predicted results, each variable having 12 data. Baume data (Actual) in column two is the result of measurements using a conventional seawater density measurement tool and used as comparative data, while Baume (Prediction) in column III is the measurement result of a tool that has been made, the way the tool works is by changing the resistance value to density value. There are several differences in values between the actual and predicted sea water concentration measurements, but the difference is not too significant, there is a difference between 0 ~ 1 from the actual value. the biggest difference occurred only in the 12th experiment. Figure  9 was presented the measurement results using a curve.  the error value was generated, = 5.9/12 = 0.5

Conclusion
The results of this study, the YL-69 sensor integrated with Arduino Uno is able to measure the density of sea water for salt-producing materials, due to changes in resistance with different density levels (Baume). Of the 12 experiments conducted, 1 experiment produced the same value between the manual density measurement value (actual value) and the measurement result using the algorithm that was made (predictive value), namely the 2nd experiment, while for other experiments, there was a difference between the actual value and predictive value, but not too significant, the difference occurs between 0 ~ 1.The error above number 1 only occurs in the 12th experiment with a value of 1.4, to find out the error rate, Mean Square Error (MSE) and Mean Absolute Error (MAE) are used, with known error MSE rate = 0.5 with MAE error rate = 0.6. Some further research is needed to produce an equation that will produce a predictive value that has a smaller error value, so that it will increase the accuracy value generated by the tool being developed, besides this research focuses on discussing the tools used as a conductor needed. into seawater, which is better and stronger against corrosion caused by saline solutions.
The inconsistency that often occurs in the ADC values generated by the YL-69 sensor affects the predicted results, an innovation is needed to make the YL-69 sensor have a better consistency values.
The purpose of this research results is to help salt farmers to produce seawater density values that is more precise than conventional measuring instruments. In addition, to the development of a digital-based density measuring device so that it is easier to develop in this digital era.