Smart Urban Farming Based on Internet of Things Using Soil Moisture Control and Application of Liquid Fertilizer to Mustard

⎯ Soil conditions significantly impact plant growth. Liquid fertilizer is used to optimize plant growth, and soil moisture is crucial too. Insufficient moisture causes withering, while excess leads to reduced soil oxygen. To monitor soil moisture, researchers developed an IoT-based Smart Urban Farming device using ESP32 microcontroller and 6 soil moisture sensors. The system operates through CNC Milling with X and Z axes movement. ADC pin on ESP32 reads sensor values, controlled, and monitored by thinger.io. The device can work automatically or manually. Input and output testing ensures performance assessment. Soil moisture sensor testing yields 2091-3998 bits range, stepper motor testing shows 1.96% highest error, and water pump testing takes 0.05 seconds/milliliter. Mustard plants use a 60% set point for soil moisture, and the pump activates at 55%. The device shows good performance with an error range of 0.03 - 0.08%, demonstrating the effectiveness of the smart urban farming system.

lant growth is influenced by soil conditions.Fertile soil will be a good medium for growing various kinds of plants.The use of organic fertilizers can be a solution in increasing soil fertility [1].In addition to soil fertility, each plant will also absorb enough water according to its needs.In the event of soil drying up and experiencing decreased moisture content, the plants may wither.Conversely, excessive water content in the soil can lead to reduced oxygen levels, hampering root respiration, decreasing root volume, and generating harmful substances [2].So, a system that can control the dose of fertilizer and the amount of water (soil moisture) based on plant needs is needed.
Several studies related to automatic watering management have been carried out previously.An Internet of Things-based automatic watering system using NodeMCU integrated with Telegram on the betel ivory ornamental plant [3].Similar investigations were also undertaken, the device created employs an Atmega32 microcontroller, Real Time Clock (RTC), and soil moisture sensors to enable automatic plant watering and nutrition supply.It incorporates a 4x20 LCD as an interface for user interaction [4].The development of Arduino Nano-based Urban Farming CNC as tool automation and IoT has been carried out [5].Agritalk focuses on implementing the Internet of Things (IoT) technology to enhance the precision soil farming techniques used in turmeric cultivation [6].
Based on the problems above, this research designed an IoT-based Automatic Urban Farming system that is used to optimize mustard greens growth by controlling the application of liquid organic fertilizer and monitoring soil moisture using the ESP32 microcontroller and the Thinger.ioplatform.By using the ESP32 Microcontroller and Stepper Motor as the driving force, applying liquid 1 Departement of Industrial Mechanical Engineering, Institut Teknologi Sepuluh Nopember, Raya ITS, Surabaya, 60111, Indonesia.E-mail: mashuri@its.ac.id organic fertilizer and controlling soil moisture can be done automatically and efficiently.Therefore, in this research the process of creating an IoT system will be carried out to control the application of liquid organic fertilizer and monitor soil moisture.
The objective of this research was to assess the precision and reliability of the stepper motor when employed as the actuator in the system, to connect the communication from the ESP32 microcontroller to the Thinger.iodashboard, and to create an automatic liquid organic fertilizer application system, and to maintain soil moisture so that the mustard plant grows well.

II. METHOD
This chapter will discuss the research methodology which includes the stages in completing the research as a whole process which will be described in a flow chart as shown in Figure 1.

A. Study of Literature
At this stage, conducting literature studies from journals, books, other people's research which contain relevant and reliable methodologies and results in collecting material as well as being a reference.The literature describes around Smart Urban Farming and harnessing the potential of the Internet of Things (IoT).The system operation of this research can be described in Figure 2.This research combines soil moisture sensor and real time clock as input to monitor the soil conditions.The data from both sensors is then calculated in the microcontroller and displayed in IoT support system.Despite being displayed in IoT display the microcontroller give command to both actuators.The motor-stepper moves to designed coordinate that need the watering then the water pump flush the water.This Electrical System starts from the wiring on the components that have been selected and then tested.The decision making of this electrical system is that the sensors and actuators can work properly.
The sensors in the system are capacitive soil moisture sensors and water flow sensors.Both sensors must work properly and must be readable by the microcontroller.Meanwhile, the actuators in the system are stepper motors and DC water pumps.These two actuators must also work properly as actuators in the system.

IoT Sub System
IoT sub system the first step starts with making a dashboard on the Thinger.ioplatform, then making a program for the microcontroller, and finally doing the testing.The success parameter of this IoT sub-system is that the microcontroller can communicate with Thinger.io.

F. System Testing
After completing the design of the electrical system and designing the IoT system, the next step is to carry out the tests by giving variable of soil conditions and command to the controller.

G. Decision Making
As stated in Figure 1, there are 2 factors that become parameters of success.
1. Soil moisture = 55 -65 % Mustard plants ideally require soil moisture of 60% for their growth [7] and [8].Therefore, the provision of water will automatically maintain the water content in the soil.To maintain this parameter, it requires soil moisture readings to be carried out by the soil moisture sensor.
Soil moisture sensor calibration needs to be done so that soil moisture readings are read accurately.Calibration is done by comparing the soil moisture meter and sensor readings.If there is a difference, the sensor reading value will be set like a soil moisture meter.After the sensor is calibrated, the sensor is ready for use.Decision Making of this system is soil moisture 55 -65% Testing and analysis of this chapter is divided into various stages, by discussing sub-sections of the overall system design accompanied by tables and drawings that support system testing and analysis.One important factor that needs to be considered in hydroponic cultivation is the nutrient content in the water that is required to be absorbed by the plants for growth [9].This 55% is the lower limit of soil moisture.So, if it is below 55% then watering will run automatically.
2. Dosage of liquid organic fertilizer = 120 ml, once every 3 days.Mustard plants in research [1] state that the dose of fertilizer for the growth of mustard plants is 120 ml with a time of application once every 3 days.This parameter is controlled by Real Time Clock because this component can know the actual time precisely.
The dosage of this fertilizer is tested by knowing the discharge from the water pump combined with time, later testing how many millilitres of fertilizer comes out.The results of the test will be used as a reference to be included in the program.The decision making for this parameter is the dose of fertilizer = 120 ml every 3 days.

H. Analysis and Discussion
After testing and being declared successful, the next step is to analyse the results obtained from the research.The analysis discusses what factors influence how the tool works, and the results obtained.These factors are obtained after realizing or testing, this is because in real conditions external factors can also affect the research results.

III. RESULTS AND DISCUSSION
This chapter discusses the testing and analysis of the Smart Urban Farming system that was planned in the previous chapter.Figure 7 shown Smart Urban Farming prototype which designed to carry out this research.

B. Selection of Components
Based on the description in method regarding the selection of the following components, the selection of components need to fulfil the minimum specifications as mention in Table 1.

Microcontroller
Based on the minimum specifications, this research run on "ESP32" as a microcontroller on the Smart Urban Farming tool.ESP32 has a lot of ADC (Analog to Digital Converter) pins, 15 pins, so it is enough to be an analog input pin on the Smart Urban Farming tool.The specs justification that used in this research shown in Table 2. Kg.cm.The current used to lift the load is 1.7 Amperes.The accuracy of the Nema 17 stepper motor is 1.8° for each step pulse.With these specifications the movement of the tool can be said to be strong and precise.

Stepper Motors Driver
The Driver for the Nema 17 17HS4401 Stepper Motor was chosen, namely Driver TB6600 because it has a current specification of 4 Ampere which means it can be used for the selected stepper motor (1.7 Ampere) and has a working voltage between 9 to 42 Volts DC which means it can be used for power supply 12VDC.

DC Water Pumps
The selected DC Water Pump is a pump that is not submerged in water from the "molar" brand with the type "PP25W".This pump was chosen because it has a voltage of 12 Volts and produces a high-water discharge of 4 Liters per minute and consumes a current of 2.2 Amperes.

Relay 5 Volt DC
The relay used has a coil voltage of 5 VDC because it adjusts the working voltage of the ESP32 microcontroller.This relay is used to turn on and off the DC water pump and does not require fast switching.

Soil Moisture Sensor
The choice of using a capacitive-type soil moisture sensor is due to its extended lifespan and its ability to provide relatively accurate readings of soil moisture levels.The specs justification that used in this research shown in Table 3.

Real Time Clock
The standard selected RTC is used because there is no special need for the installation of the Smart Urban Farming Tool.RTC is only used for liquid organic fertilizer administration timer for 3 days.

Power Supply
The 12 Volt power supply was chosen with a current of 10 Amperes because of the following assumptions.The total current required is 5.62 Amperes.According to the experience of power supplies on the market, the current is usually lower than the nominal specifications listed.So, the selected power supply has a current of 10 Amperes to anticipate a power shortage as shown in Figure 9.The specs justification that used in this research shown in Table 4.

C. System Design
System design is divided into 3 parts, as follows: 1. Mechanical Subsystem The mechanics that are made adhere to the working system of a CNC Milling machine on its X and Y axes (without the Z axis).The dimensions of the tool are 75 cm (X-axis) x 50 cm (Y-axis).For the slider or coordinate transfer mechanism using 4 Wheels that flank along the V-Slot Aluminium Profile which can be seen in Figure 10.What drives this drive mechanism is the Nema17 Stepper Motor by pulling the drive mechanism using the Timing Belt.On the stepper motor shaft there is a Timing Pulley and at the other end there is an Idler Timing Belt Pulley.
The specifications of the drive mechanism are shown in Table 5: Referring to the specifications of the drive mechanism in the Table 5, it can be used to determine how many pulses will be used to move it to the position you want to go to.Based on the standard GT2 Timing Belt has a pitch of 2 mm.So, the calculation is obtained as follows: From these calculations, the result is that for every 1 mm movement, 40 pulses signal is needed.These 40 pulses will later be entered into the program and processed according to the program's algorithm.
The results of testing the drive mechanism are as shown in Figure 11.The pulse sample is based on calculations, while the distance based on the test is the real data of the drive system displacement.Error is the difference between calculation and testing expressed in percentage.The following is the Stepper Motor pulse test data for the driving mechanism.Figure 11 shows the difference between the results of the calculation (which should) and the results of the test (actual).From these differences, there are differences in inaccuracies (errors).The error is obtained from the difference between the calculation and the actual divided by the actual value multiplied by 100%.The following is the error rate of the actual calculation and is presented in graphical form.It can be seen from Figure 12 that the lowest error rate is given when the input signal is 400 pulses with an error value of 0%.As for the highest error during the second test, namely when given an input signal of 2,000 pulses with an error value = 1.96%.Test 3 and so on decreased and then flat.From the graph, all errors that occur below 2% mean that the X-axis stepper motor test is still within the realm of tolerance.
After knowing the technical specifications of the X-axis stepper motor, then testing the Y-axis stepper motor, using the same method as the X-axis but with different variations in values.The following Figure 13 of Y-axis stepper motor testing data.
Figure 13 show the data in each test is compared, which is presented in graphical form to see the difference between the calculated and tested data.The Y-Axis Stepper Motor test is carried out up to five times to determine the characteristics of the stepper motor itself.The following is a graph of the Y-Axis Stepper Motor test with the calculation results.The Figure 13 shows the difference between the results of the calculation (which should) and the results of the test (actual).From these differences, there are differences in inaccuracies (errors).The following is the error rate of the actual calculation and is presented in graphical form.It can be seen from Figure 14 that the lowest error rate is given when the input signal is 400 pulses with an error value of 0%.As for the highest error during the second test, namely when given an input signal of 2000 pulses with an error value = 1.96%.The 3rd test onwards experienced a decrease in value and then the value was flat.If you look at the graph, all the errors that occur are below 2%, which means that the Y-axis stepper motor test is still within the realm of tolerance.From the selected components, the next step is assembled so that these components can function according to the instructions that the author made.The electrical circuit or better known as the wiring diagram of the Smart Urban Farming tool, can be seen in the Figure 15.While in the Figure 16 is a stepper motor test before it is implemented on the tool.The results of the soil moisture sensor test are as shown in Figure 17.Each sensor was tested in dry conditions and wet conditions used for upper (dry) and lower (wet) value thresholds.The six sensors are tested together at one time as in the original conditions.

Electrical Subsystem
From Figure 17, the data in each test is presented in graphical form to see the difference between the upper and lower values for each sensor.The Soil Moisture Sensor test is carried out up to five times to determine the characteristics of the sensor itself.The following is a graph of the upper and lower values of the soil moisture sensor test.The results of the DC Water pump test can be seen in Graphic.There are 5 variations, namely 100 ml, 200 ml, 300 ml, 400 ml, and 500 ml.From these 5 variations, this research found the time it takes the pump to turn on to pump 100 ml of water used to water the plants.The DC Water pump test is carried out up to five times and then the average is taken to determine the characteristics of the pump itself.The Figure 18 shown the DC Water pump test based on volume and time.The results of the Mini Water pump test can be seen in Table 4.14.There are 5 variations, namely 50 ml, 100 ml, 150 ml, 200 ml, and 250 ml.From these 5 variations, you can find the time it takes for the pump to turn on to pump 120 ml of liquid fertilizer used to fertilize plants.The Mini Water pump test is carried out up to five times and then the average is taken to determine the characteristics of the pump itself.From this average, it can be calculated in seconds/millilitre:  The Figure 19 shows the time needed for the Mini Water pump to turn on to pump 50 ml, 100 ml, 150 ml, 200 ml, and 250 ml of water.The graph that appears is directly proportional to the volume issued.In the Figure 20 an IoT dashboard that uses the "thinger.io"platform on the website.This dashboard is used for monitoring and for controlling or controlling Smart Urban Farming tools or systems remotely.As for what can be monitored are as follows: soil moisture conditions.Meanwhile, the control system is as follows: manual or automatic water sprinkling depending on the selected mode.

IoT Subsystem
Thinger.io is an Internet of Things platform that utilizes a cloud system where all connected devices are interconnected through the internet network [10].

D. Control System Testing
Mustard plants ideally require soil moisture of 60% for their growth [7] and [8].Therefore, the provision of water will automatically maintain the water content in the soil.To maintain this parameter, it requires soil moisture readings to be carried out by the soil moisture sensor.
Mustard plants in research [1] state that the dose of fertilizer for the growth of mustard plants is 120 ml with a time of application once every 3 days.This parameter is controlled by Real Time Clock because this component can know the actual time precisely.As stated in the flowchart.

First Test
Testing is done by setting the set point at 60%.With soil with early moisture and soil with final moisture.Then the final humidity is calculated by error with the set point.From Figure 22, the highest error occurs in plant 3 with a value of 0.08%.While the lowest error occurred in plant 2 with a value of 0.03%.

Second Test
Testing is done by setting the set point at 60%.With soil with early moisture and soil with final moisture.Then the final humidity is calculated by error with the set point.From the Figure 23, the highest error occurs in plant 2 with a value of 0.08%.While the lowest error occurred in plants 1, 3 and 5 with a value of 0.05%.

Third Test
Testing is done by setting the set point at 60%.With soil with early moisture and soil with final moisture.Then the final humidity is calculated by error with the set point.From the Figure 24, the highest error occurs in plant 5 with a value of 0.08%.While the lowest error occurred in plants 2, 4, and 6 with a value of 0.03%.

Fourth Test
Testing is done by setting the set point at 60%.With soil with early moisture and soil with final moisture.Then the final humidity is calculated by error with the set point.From the Figure 25, the highest error occurs in plant 5 with a value of 0.08%.While the lowest error occurred in plant 1 with a value of 0.03%.

Fifth Test
Testing is done by setting the set point at 60%.With soil with early moisture and soil with final moisture.Then the final humidity is calculated by error with the set point.From the Figure 26, the highest error occurs in plant 5 with a value of 0.08%.While the lowest error occurred in plant 3 with a value of 0.03%.

Fertilizer Application Test
Fertilizer testing is carried out by setting the time to the 3rd, 6th, 9th, 12th, 15th, 18th, 21st, 24th, 27th and 30th at 7.30 WIB.This setting is done by the RTC component as real time for the microcontroller.Dosage of fertilizer by setting the ignition time of the Mini Water pump.This time is obtained from data retrieval from Mini Water pump calculation is 0.05 second/millilitre.Mustard plants in research [1] state that the dose of fertilizer for the growth of mustard plants is 120 ml.Then the time needed for the Mini Water pump to turn on is as follows: So, the time for the Mini Water pump to turn on for liquid fertilizer application is 6 seconds.

IV. CONCLUSION
From the planning process to system design on the Smart Urban Farming tool, it can be concluded that: 1. Actuators and sensors can work according to the purpose of the system.2. The ESP32 microcontroller can communicate with each other with the IoT platform, thinger.io. 3. A system has been obtained by applying liquid fertilizer once every 3 days and maintaining soil moisture around 60%.

Figure 1 .
Figure 1.Research Flowchart 1. Design Criteria a.The system can be used for 6 plant pots.b.Tools to maintain soil conditions in mustard plants.c.Maintain soil moisture in the range of 55% -65% d.Administration of 120 ml POC doses within 3 days

Figure 8 .
Figure 8. Design System Figure 8 shown the planned tool design in accordance with the design criteria and design parameters in the points above.The frame is made of V-Slot 2020 type Aluminium Profile.The polybags used are 16 cm in diameter arranged in parallel 2 x 3.According to the plan above, the following specifications are needed:

Figure 11 .
Figure 11.Stepper Motor Testing Graph for X-Axis

Figure 12 .
Figure 12.Error Graph of Stepper Motor for X-Axis

Figure 13 .
Figure 13.Stepper Motor Testing Graph for Y-Axis

Figure 14 .
Figure 14.Error Graph of Stepper Motor for Y-Axis

Figure 16 .
Figure 16.Stepper Motor Trial After carrying out a series of electrical wiring diagrams, the next step is to test the electrical subsystem.There are 3 tests in this electrical subsystem namely, Soil Moisture Sensor, DC Water pump, and Mini Water pump.Each part (Soil Moisture Sensor, DC Water pump, and Mini Water pump) was tested 5 times.a. Soil Moisture Sensor

Figure 17 .
Figure 17.Graph of Sensor Testing b.DC Water pump

Figure 18 .
Figure 18.Graph of DC Water Pump Testing 046 = 0.05 second/mililiter(5) The Figure19of the Mini Water pump test based on volume and time.

Figure 19 .
Figure 19.Graph of DC Mini Pump Testing

Figure 22 .
Figure 22.Graph of First Test

Figure 23 .
Figure 23.Graph of Second Test

Figure 24 .
Figure 24.Graph of Third Test

Figure 25 .
Figure 25.Graph of Fourth Test

TABLE 2 .
Nema 17 Stepper Motor with type 17HS4401 is capable of lifting loads with a torque of 40 N.cm or 4 MICROCONTROLLER SELECTIONComponentESP32 NodeMCU Advantages 15 pin ADC, Wi-Fi built.Wi-Fi built Disadvantages Expensive 1 pin ADC 2. Stepper Motors Choosing a