Smart Soil Moisture Control Based on IoT ESP-32 for Horticulture Cultivation in Coastal Area

. Optimal and effective use of water in coastal areas is an essential aspect of plant growth in horticulture and the maintenance of water availability. It is necessary to monitor soil moisture continuously as the basis for watering time. However, it is hard for farmers to be in the field frequently to monitor the land humidity, even using an instrument to measure it at the site. It is needed a monitoring technique that can control the land humidity remotely. This paper presents a design of wireless soil moisture measurement based on the Internet of Things. We applied capacitive soil moisture sensors coupled with an ESP32 WIFI with a built-in 12-bit ADC function for reading analog sensor output and establishing a wireless connection to the internet network. The ESP32 was programmed using Arduino software. We made a web-based user interface and Google spreadsheet application using the Nodered which is a programmable IoT platform to show soil moisture and control the irrigation sprayers through the pump.


Introduction
Precision Agriculture, also known as site-specific management, is an agricultural management plan based on monitoring and calculating agricultural parameters with precision, which is useful as a reference in taking appropriate actions [1].Conventional agriculture is implemented by practicing some particular tasks (such as planting, irrigation, fertilization, and harvesting) under a defined schedule.On the other hand, predictive analytics could be applied to optimize farming operations by providing real-time status on weather, soil, crop, fertilizerm and even farm equipment or labor [2].
The basic objectives of Precision Agriculture are to increase the production profitability, improve the crop quality, and preserve the environment.It is based on precise monitoring and calculation of agricultural parameters related to water need that are useful as a reference in taking optimal actions for plant growth.Precision agriculture relies on reliable data generation and proper management [3].
The information of soil attributes variability on field is important for the decision-making process.One of important aspects of Precision Agriculture is the cability to reliability and rapidly gather information on soil properties for water management plan.The precise watering is essential aspect for optimal plant growth.It is vital to monitor soil moisture regularly as the base of irrigation time [4].Farmers find it difficult to monitor soil moisture frequently, even when utilizing an in-situ site measurement instrument.A monitoring technique that can control the soil moisture remotely is required [2].
With the recent popularity and growth of Internet of Things (IoT) technology, there are more opportunities to make farming more practical and help farmers in their activitiesThe agriculture IoT devices are aimed to help monitor crop fields using sensors and by automating irrigation systems.This makes it easy to monitor field conditions from any location [5].
Moreover, the implementation of smart farming is inseparable from the IoT (Internet of Things) system that enables processing and data collection in large agricultural area remotely from the farm site.Typically the farm location is limited access to electricity.As IoT and sensing material technology improved, it has been developed fair accurate, compact, simple, and low-cost modules of programmable IoT devices and soil variability sensors, such as ESP32 module and capacitive soil moisture sensor respectively.Therefore, we developed an IoT-based monitoring system of soil moisture using an ESP32 microcontroller with WiFi Transmission, which is powered by solar panels and shown via the Web Server Dashboard for optimum water management of crop cultivation.

Design of IoT ESP32 based soil moisture monitoring system
The design of smart soil moisture Probe Based on Internet of Things is shown in Figure 1.The main component of IoT based soil moisture monitoring system is ESP32 module, soil moisture sensor (i.e.capacitive soil moisture sensor v.2.0), rechargeable batteries, solar panels, and WiFi router include with internet provider card.We only used a single ESP32 module as heart of the system since it has not only the IoT module (WIFI 802.11b/g/n and 802.11n 2.4 GHz up to 150 Mbps) but also it is integrated on the module of 9 channels 12 bit Analog Digital Converter, 2 pins Digital Analog Converter, configurable input output, I2C, SPI, and UART communication [6].
We employed 6 capacitive soil moisture sensor v.2.0 as input of the ESP32.It is a coplanar capacitive soil moisture probe, which principally works by measuring the changes in capacitance caused by the changes in the dielectric (Figure 2).Basically, the capacitive soil moisture sensor is a conductive copper plate in the center and a ground plate that goes around the outside (Figure 3).The capacitive copper plate basically measures the dielectric which is formed by the soil, where its water content mostly affects the dielectric [7].In contrast to the resistive soil moisture sensors, the capacitive soil moisture sensors are known to be resistant to corrosion and therefore the capacitive type has been used [8].The exposed circuitry on top of the capacitive soil sensor should not be wet.Thus, a seal was used for coating isolator the upper side of sensor for ensuring that water will not seep into the circuitry.
The calibration of soil moisture sensor was applied using method of Gravimetric Water Content (GWC) to the output of capacitive moisture sensors.The gravimetric method is the ratio of the mass of water to the mass of soil in a sample.The mass of each sample must first be measured to calculate the instantaneous water content of a soil sample.The instrumentation and consumables required such as: (a) Aluminum tins (small, round tins are proper so you could fit more into the oven at once, but any size works), and (b) analytical There are two different ways to calculate GWC and the subsequent weight needed to achieve the oven-dry basis soil mass for a particular analysis.One uses the dry weight base and the wet weight base.GWC can be expressed as a percentage, or with the units of g water/g soil (field-moist or dry).The calculation of wet weight base is as shown in Eq.1.

Calibration of Soil Moisture Sensor
Figure 4 shows the results of the calibration procedure between the voltage reading of the soil moisture capacitive sensor (volt) and GWC (%) derived by gravimetric methods.We tested 6 soil moisture sensors and each measurement was repeated three times.We also found the average standard deviation of voltage sensor output and GWC measurement respectively is around 0.01 and 3.95, indicating low standard deviation that the values tend to be close to the mean or the expected value.This deviation is also slight similar responses that have been extensively calibrated the soil water content using time domain reflectometry (i.e.0.04) [12].We obtained the fit equation of polynomial model (equation 1) with the highest R 2 value by observing some model using Excel spreadsheet application as shown in Table 1.Then, we calculated the RMSE and MAPE between measured water content and calculated water content.We obtained the MAPE was 10.09%, indicating that the volumetric water content of the soil utilized in this investigation can be approximated to within 0.08% of a given reading.This inaccuracy is also near similar devices that have been extensively calibrated [13].

IoT based-soil moisture monitoring system
We have built 3 soil moisture measurement systems based on IoT WIFI ESP32 to determine the soil moisture of 3 plots of land used for Land-ARS test.Each system consists of 6 soil moisture sensors.The system was developed from previous research [14][15][16][17].
Each system is composed of 6 soil moisture sensors, ESP-32, 12-volt 5Ah battery, 5 Wp solar panel, and WIFI Router.The reading of measurement results is displayed in two ways, namely by (a) the NodeRed Premium web server application, and (b) the Google spreadsheet cloud which also functions to store/acquire measurement data Figure 6 shows the apparatus of the soil moisture monitoring system based on IoT ESP32, and Figure 7 shows a connection test of ESP-32 using Arduino software .

Conclusion
We built an IoT based soil moisture measurement based on low-cost soil moisture sensor.Six sensors was used and coupled with an ESP32 WIFI which built-in ADC function for reading analog sensor outputs.The ESP32 connects to the Internet using a WIFI wireless connection.The ESP32 was programmed using Arduino software.And, a user interface was developed using the Node-Red which is a programmable platform to show soil moisture and store the data into a spreadsheet cloud file.We used the equation model of capacitive soil moisture as θw = 34.23 x V2 -182.84 x V + 249.45 where θw = soil moisture, wet based (%) and V = sensor voltage (volt).

,Fig. 1 .
Fig. 1.Design of wireless soil moisture probe based on internet of things.

993 Fig. 5 .
Fig. 5. Linear fit between the measured water content and predicted water content.

Figure 8 and
Figure 8 and Figure 9 respectively show the interface between NodeRed and Google spreadsheet, and the implementation in the field for online soil moisture monitoring.IoTbased soil moisture measurement system with NodeRed.
(at least two decimal places).The procedures of GWC method for calibrating the capacitive soil moisture sensor includes [9-11]: A. The preparation of soil sample 1. Numbering of aluminium cans, weighing of each can and recording of the weight.2.Weighing ~ 10 g of each sample of field-moist soil into its own tin. balance

Table 1 .
Comparison of calibration model of soil capacitive model to sand soil.