Design of Smart Farm Irrigation Monitoring System Using IoT and LoRA

Agriculture is an essential part of society in Indonesia because most of the population lives off of farming. Water and irrigation are the most critical and central factors in the agricultural system. The uneven distribution of irrigation water can be a problem for farmers. In addition, most of the current irrigation systems are still operated manually, for example, irrigation gates. The gate still works manually and requires human labor to run it. This study aims to design a smart farm irrigation system using internet of things and LoRa communication technology. LoRa can transmit information up to a range of several kilometers without an internet connection. It will be advantageous when the farm's location is deep in the forest, and there is no GSM signal for internet access. The results show that the system can control the farm irrigation automatically without human hands. The water gates in the field are operated based on the water level. The irrigation monitoring process becomes easier because they do not need to come to the farm location. In fact, they can use smartphones to monitor it.


Introduction
Water is one of the sources of life for living things and is needed for growth. One example is in the agricultural sector. The need for water is very much needed. Moreover, if the area is an area that lacks moisture and the soil is dry, then the water becomes a significant problem in the survival of agriculture [1]. Water distribution in agricultural areas frequently becomes a source of conflict between farmers. It can cause physical conflict simply because of the uneven water distribution from downstream rivers [2]. Then, there are still several other problems with agricultural irrigation. For instance, the operating and monitoring systems still require human labor [3].
The current agricultural irrigation system relies heavily on human labor and is done manually. For example, the main irrigation gate, which is the entry point for water from downstream rivers to agricultural areas, is still operated by humans. Other irrigation doors still require human labor to open and close [4]. It causes the irrigation system to be less efficient and have gaps in system failure. If humans, tasked with opening or closing the doors, forget to carry out their duties, this will have fatal consequences for agriculture. It could be that these agricultural products fail due to too much or lack of water [5].
In addition, the process of monitoring or supervising irrigation must also be done by humans. Farmers must always be at the farm site to monitor irrigation and ensure sufficient water is needed for good agricultural yields. Sometimes, farmers' time and energy are wasted for coming to the location to provide the supervision [6]. If this system could be carried out automatically, the time used by the farmers to monitor the irrigation could be used for other productive things that bring benefits to them [7].
The advanced technologies that have been developed can be applied to the agricultural sector to run it better and more efficiently. One of them is the Internet of Things (IoT) technology. IoT technology can make irrigation systems work automatically [8]. Moreover, Long Range (LoRa) communication technology can remotely monitor irrigation systems that can reach tens of kilometers from agricultural locations by using a smartphone [9].
This study aims to design a smart farm irrigation system that automatically controls and monitors irrigation without relying on human labor. The smart system, in this case, is defined as a system that can automatically open and close the irrigation gates according to the water needs for farming using IoT technologies. In addition, the system can be monitored via a smartphone or website in real-time.
The rest of the paper is organized as follows. Section 2 presents the research method used. In section 3, the results and discussion are presented. Finally, in section 4, we conclude the paper with a summary and discuss the future work.

Research Method
The method that was carried out in this study can be seen in the diagram in Figure 1. The world of computers and communications has evolved very quickly since the advent of internet technology. Initially, the internet was a means to broadcast information, interact, and communicate between computers. Recently, various kinds of technologies have evolved much faster with the help of the internet, and one of them is the Internet of Things. In addition, the internet has also combined several other technologies, which previously could only stand alone without being able to be connected at all, such as the telegraph, telephone, radio, and computer [10].
Internet of Things (IoT) is a network that can connect one device to another. Currently, IoT has received much attention from researchers and practitioners in developing today's technology-based on wireless networks. The virtue of this IoT technology is its positive impact on aspects of everyday life. With IoT technology, human life will be more and more efficient at work and socially [11]. The benefits and potential provided by IoT technology allow many applications to improve the quality of human life, which is currently very rare. There are so many environments in society today that have been equipped with various tools to communicate. With these capabilities, certain types of information are spread widely and quickly. Different types of IoT applications can be grouped as follows [11]: 1) transportation and logistics, 2) healthcare, 3) intelligent environmental systems, 4) personal and social, and 5) futuristic. The details of classifications can be seen in Figure 2. The term smart farming (SF) has emerged in the last few years. SF aims to utilize the application of the latest information and communication technology in agriculture to increase the productivity and economy of the community. In addition, SF seeks to reduce the negative impact of agricultural processes on the surrounding environment so that natural sustainability is more easily maintained and not easily damaged [12].
With the industrial revolution 4.0, all industrial systems that have initially been traditional or manual will be transformed into a digital ecosystem. Therefore, the use of IoT in applications in various fields is increasing, which causes a considerable increase in the volume of data collected from the digital system, known as big data. Currently, more than 98% of global information is stored digitally, and experts predict that the amount of data stored will increase by 20,000 times by 2045. So, IoT and big data will be the primary keys in the future, and one of them is the agricultural industries [13].
Agricultural with IoT can be described as a network consisting of various sensors, cameras, and other tools that aim to assist farmers in completing their work. These tools work autonomously and automatically without any assistance from humans. In other words, these tools are equipped with intelligence and can communicate and interact with other devices on the same system [12]. In Figure 3, there are several IoT applications in agriculture. Examples are using drones to monitor agricultural processes, using IoT in water management, monitoring soil moisture with sensors, and operating machines automatically with IoT. Figure 3. IoT applications in agriculture [14] 2.1.3. Farm Irrigation with IoT The irrigation system is a system for managing and supplying water to support agricultural needs. As an agricultural country with a high level of soil fertility, the majority of Indonesian people work as farmers. One of the most critical things in agriculture is water. Humans still operate irrigation systems in agriculture manually, such as opening and closing floodgates. However, in the current era of technological advances, it is possible to make innovations by making irrigation systems smarter with the help of IoT [15].
There are several types of irrigation found in Indonesia [16], namely: 1) Surface irrigation: a type of irrigation that takes water directly from the river by using a channel so that the water will seep into the soil's pores. 2) Subsurface irrigation: the irrigation system irrigates the plants through pipes that have been planted in the roots so that water can go directly to the plant roots. 3) Spray irrigation: the irrigation uses pressure to channel water out like raindrops that wet the farm or crops. 4) Drip irrigation: the system uses a pipe with small holes so that the water that comes out in the form of droplets will go directly to the plants.

LPWAN and LoRa
LPWAN stands for Low Power Wide Area Networks. LPWAN is a wireless network that connects batteryoperated communication devices, has a low data transfer rate, supports communication with a wide coverage area, and is quite far away. LPWAN provides the best service because it requires a small fee compared to traditional mobile network technology. So far, LPWAN is the most widely used technology in IoT because it offers extensive communication coverage [17]. Figure 4 presents the data rate and communication coverage in wireless technologies. wireless technologies [17] LoRa (Long Range) is a modulation technique that uses spread-spectrum developed by Semtech. LoRa can transmit information up to tens of kilometers. It is because of the support from LoRaWAN. Also, LoRaWAN only works on a star topology in communicating. IoT devices (nodes) send information signals to a gateway device connected to the internet network. Usually, the gateway device has a high device specification that can receive multiple transmissions simultaneously. IoT node tools are grouped into three classes, namely: class A, class B, and class C. The use of LoRa in communication on wireless sensor networks has several interesting aspects. First, because the LoRa communication coverage distance is quite large, the network can communicate without routing too much information over many hops. Second, although the transmission is carried out at the same frequency, it can use different spread factors. Third, when communication coincides using the same parameters, the transmission with the strongest signal will be received with a high probability [18].

System Design
Solving the problems that arise in the introduction are carried out by designing a smart farm irrigation system using IoT and LoRa technology. The purpose of this system is for the irrigation process to work so that the main irrigation gate from downstream of the river leading to agricultural irrigation and other sluice gates can work without having to rely on humans. There is a water gate and a water level sensor in each rice field. The water gates are used to fill and drain water into the areas. Meanwhile, the water level sensor measures the amount of water in the fields. If the soil water content is assessed as high and sufficient for the plant's needs, the water gates will be closed. If the fields or rice fields lack water, the water gates will be opened. A microcontroller carries out controlling the water gates and measuring the water level. The microcontroller and LoRa transceiver are located in the near of irrigation gate.

Irrigation System Design
The complete system design on the sending side can be seen in Figure 5. In this system, there are four rice fields, each of which is equipped with a water level sensor and an automatic door. The sensor is used to measure the water level. Usually, rice requires more water to grow properly in the early days following the planting of rice seedlings. If the rice lacks moisture, it can fail to grow and cause crop failure. But when the rice gets old, the need for water decreases. If the water is present, this can cause the rice to be damaged. The automatic water door flows water from the irrigation river into the rice fields. If the required water is not enough, the water gate will open. If the amount of water in the field midwife is sufficient, the water gate will be closed. Opening and closing the floodgates is carried out automatically by measuring the water level using sensors and observing the condition of rice development.
There is also a main irrigation gate that works automatically. It regulates the amount of water flowing into the rice fields. In this system, rice fields A and B are connected. Likewise, with lots C and D. If fields A and B need water, the water gate in Field B will open. The water will enter the irrigation river and flow into rice field A. If there is too much water in fields A and B, the water gate in Field A will open so that the volume of water will decrease. Fields C and D also work similarly as fields A and B. The water gate in Field C is used to enter the water, and the water gate in Field D serve to reduce the amount of water. The volume of water is measured using a water level sensor.
All water gates and sensors work automatically and are controlled by a microcontroller. The microcontroller is also responsible for sending information from the sender to the receiver. The communication module used in this system is the LoRa (

Monitoring System Design
The complete system design on the sending and the receiving side can be seen in Figure 6. In the receiving system, a web server receives data from the intelligent irrigation system in the fields. The web server is connected to a local network using a WiFi router. Farmers can use a mobile phone connected to a local WiFi network to access the web server. By opening a browser, farmers can also view and monitor smart irrigation systems via mobile phones. This web server Figure 5. Irrigation system design feature can be supported by using a microcontroller with WiFi capabilities. By using this system, the result of farming will be more effective, and the time used to maintain the fields every day will be less. Thus, the time used to come to the fields and standby can be used for other, more productive purpose.

Espressif 32
Espressif 32 (ESP32) is a microcontroller in which the system is already embedded in the chip and is also lowcost (cost-effective) and low-power (saving electricity). ESP32 is the latest generation of the previous generation, namely Espressif 8266 (ESP8266). ESP32 uses the Tensilica Xtensa LX6 microprocessor series, which has two variations: dual-core and single core. On the ESP32, there is already Wi-Fi support and dualmode Bluetooth [19].
There are two voltage sources produced on the ESP32, namely 3.3V and 5V. It allows the ESP32 to operate more widely and supports more sensors and electronic devices performing at 3.3V and 5V voltages. The ESP32 is also classified as a microcontroller that saves energy, where electricity consumption ranges between 15 Figure 7 shows the physical appearance of the ESP32 DEVKIT V1. This ESP32 has 36 GPIOs.

HopeRF RFM95W
HopeRF RMF95W is a transceiver used for LoRa communication, which has the characteristics of ultralong range spread spectrum communication and high immunity to interference with minimum electric current consumption. HopeRF uses the LoRa modulation technique. LoRa applications are pretty broad, including automatic meter reading, home, and building automation systems, wireless security and alarm systems, industrial control and monitoring systems, and  [20]. Figure 8 shows the pins of the LoRa module.

Solenoid Valve
The solenoid valve is one of the control components that is often used in fields related to fluids. This component works electromechanically, which combines electrical and mechanical processes. This solenoid valve operates on a voltage of DC12V, DC24V, or AC220V. This solenoid valve works like an automatic water faucet that can drain and turn off the air if given an electric current. Figure 9 shows the physical appearance of the solenoid valve. There are two choices of pipe sizes on this solenoid valve, namely 1/2 or 3/4 inches.

Water level sensor
To measure the water level, we can use a water level sensor. This sensor works at a voltage of 5V or 3.3V.
There are three pins, namely 1) pin +, 2) pin -, and 3) pin S. 'Pin +' can be connected to digital pins on the microcontroller. 'Pin -' is connected to GND on the microcontroller, and 'Pin S' is connected to an analog pin. This 'Pin S' is used to read the water level. The more the water level decreases, the higher the output voltage at 'Pin S'. By measuring the voltage, we can find out the water level. Figure 10 shows the shape of the water level sensor. Relay modules are fundamental and are often used in electronic projects. Relays work like automatic scalars that can connect and disconnect the electricity. This relay is also often used in several motorcycles or cars and operates on a voltage of 5V. Relays use electromagnetic principles to move the contractor to the ON or OFF position. Figure 11 is a picture of a relay with two channels and 5V. Relays generally have two conditions: NC (normally closed) and NO (normally open). NC is the initial condition where the relay is closed because it does not receive an electric current. At the same time, NO is when the relay is open and gets an electric current. In addition, the COM (Common) on the relay must be connected to one end of the cable to be used.

Prototyping
The design of smart irrigation systems from the sender side can be seen in Figure 12. The microcontroller used is ESP32 which has 36 GPIO (General Pin Input Output). The ESP32 requires 5V power to operate. The LoRa communication module uses the HopeRF RFM95W, which operates at 915 MHz. There are five solenoid valves used as sluice gates and four water level sensors that measure the water level.
The solenoid valve is controlled via a relay connected to the ESP32. The relay used is a 2 Channel 5V relay. The solenoid valve requires 12V power to work. At the same time, the ESP32 can only provide 3.3V and 5V power. So, it takes an external 12V power source to operate the solenoid valve. The water level sensor can be directly connected to the ESP32 to measure the water level. If the water level reading through the water sensor is lower than it should be, the solenoid valve will open so water can flow. If the water level exceeds the required limit, the solenoid valve will close automatically.
LoRa and ESP32 at the sender will send all information related to the system to the receiver. The frequency used to send information data by this LoRa module is 915 MHz. This frequency is a free license, which is not paid for and can be used by anyone. It is also permitted by the Indonesian government regulations regarding the regulation of frequency usage for LoRa communication.
The flowchart of the system can be seen in Figure 13. Firstly, the system will close all the water gates (i.e., A, B, C, and D). Then, it reads the water level sensor in each rice field, namely rice fields A, B, C, and D. If the water level in rice fields B and C is less than 50% of its height, the system will open the water gates B and C. The gates will keep opening until the water level reaches 80%. Then, if the water level in rice fields A and C is higher than 90%, it indicates that the water volume is too much and needs to be reduced by opening the water gates A and D until the water level touches 80%. Figure 11. Schematic of smart irrigation system at the sender In addition, the schematic on the receiving side can be seen in Figure 14. In this design, only three hardware components were used, namely; 1) ESP32 as a microcontroller, 2) LoRa HopeRF RFM95W as a communication module, and 3) an I2C 16x2 LCD as a data display. The ESP32 will receive the information data sent by the sender via the LoRa module and display the data on the LCD. Furthermore, the data can also be displayed on the webserver for further monitoring by the farmers. The ESP32 already supports a web server, and the monitoring system can be built and displayed on the web server. To access the web server, the user can open a browser application on a smartphone. Figure 14. The schematic of monitoring system at the receiver

Result and Discussion
The results of the prototype of the IoT and LoRa-based smart farm irrigation system that has been designed can be seen in Figure 15. This prototype will allow the flow of water from the brown bucket at the topmost position and descend to the black bucket located at the bottom. The brown bucket is used as a water tank, and the black bucket is used as a water reservoir. Several tools and items are used to simulate natural agricultural conditions. For instance, several transparent plastic containers are used for rice fields A, B, C, D, and irrigation rivers. Moreover, solenoid valves are used as water gates. Also, water level sensors are used to determine the water level of the rice fields.
The solenoid valve requires a 12V power supply, so an external power supply is needed because the ESP32 microcontroller cannot produce 12V power. The ESP32 can only have 3.3V or 5V power. Then the solenoid valve is connected to a 5V relay to be further controlled by the ESP32 sender. The ESP32 will control all irrigation processes, and the information data is sent to the ESP32 receiver using the LoRa HopeRF RFM95W communication module, which works at a frequency of 915MHz. The experiment was carried out by opening the water faucet in the brown bucket so that the water would flow down and through fields A, B, C, and D. If the water demand in the rice fields is high enough, the solenoid valve will open. Usually, when the rice is 15-50 days old, the water needs in the fields are quite a lot. Rice plants need about 2-3 cm of waterlogged. In this condition, the water gates B and C can be opened. Meanwhile, floodgates A and D must be closed. The gate can be closed if the water level is sufficient (i.e., 2-3 cm). Each field has been equipped with a water sensor to measure the water level. Figure 16 shows a prototype of the LoRa sender and receiver devices. In this system, LoRa will send data every 10 seconds. However, it is adjustable according to the requirements. The more often LoRa sends data, the more electrical energy is needed. However, LoRa can send data every 30 minutes to save energy consumption. Then the ESP32 can be in a deep sleep state to be more energy efficient. The ESP32 only requires 0.5 µA of electricity when in a deep sleep [19].
LoRa receiver will receive all the data information sent by the sender. The data will be shown on a 16x2 LCD. In addition, the data will also be displayed on the webserver for the monitoring process. In this experimental setup, the distance between the sender and receiver is only one meter. It is to confirm whether the system can run properly or not. The LoRa antenna used is a cable antenna. However, the signal results obtained are pretty good. Figure 16. Prototype of LoRa sender and receiver Furthermore, the LoRa sender and LoRa receiver are placed far away to test the performance of the system. We measure the RSSI (i.e. Received Signal Strength Indicator) level and the received packets. The sender transmits twenty packets in total. Tabel 1 shows the value of distance, RSSI, and received packets. The receiver can receive the packets completely without loss under distance of 10 meters. However, when the distance reaches 50 meters, there is a packet loss. The number of packet losses increases when the distance is longer. For instance, when the distance is 300 meters, the number of packet losses is 7. The receiver is completely lost the packets when the distance is 1000 meters. Meanwhile, the value of RSSI is slightly pointing the same number from distance of 50 to 700 meters.
If this system is applied to the real-world agricultural system scenario, one of the challenges is access to a power source. However, the most likely source of electricity in the IoT project is batteries. The reason is that the power plant's electricity source hardly reaches the farm fields. Therefore, the best possible energysaving mechanism must be considered.
The smart farming irrigation system interface can be seen in Figures 17. It shows a web server that is accessed via a smartphone. The data displayed is the status of the water gates and the water level of each field. In addition, LoRa signal strength information can be seen from the RSSI (Received Signal Strength Indication) value. There is a timestamp that shows the last LoRa packet was received.
The water gates B and C are set to open when the water level is less than 50% so that more water can enter the fields. If the water level is higher than 80%, water gates A and D will open to remove the excess water. The gates can open and close automatically according to water level conditions. When the rainy season comes, water is not only from irrigation rivers but also from rainwater. It will cause the amount of water to increase faster if it rains. So, the role of automatic water gates is needed in agricultural irrigation systems. With these conditions, farmers do not have to supervise the farm location every time. Moreover, the agricultural irrigation system can run automatically and without the supervision of the farmer.
By implementing this intelligent agricultural irrigation system, farmers will be significantly helped. It can also improve the welfare of farmers. The time used for work will be more effective and efficient. The remaining time can be used to do other productive things that can generate additional income, for example, by running other businesses simultaneously besides farming. In addition, the quality of agricultural products can be maintained because agricultural irrigation can meet the water requirement. Monitoring this system is also relatively easy by using a smartphone. Also, monitoring can be done remotely without coming to the farm location.

Conclusion
In this paper, a smart farm irrigation monitoring system has been designed. We utilized internet of things technologies and LoRa communications to carry out the design. We made a prototype to proof that our design is working under some assumptions and conditions. The water level and gates are controlled by a microcontroller. Then, the data is sent to the receiver using LoRa, which is operated in 915MHz. The farmer can monitor the irrigation system through a web server and smartphone. Furthermore, we evaluated the system performance by located the LoRa sender and LoRa receiver in a various distance. Overall, the results confirm that the system can be monitored quite well under distance of 100 meters. If the distance is more than that, the number of packet loss is higher.
For the future work, a further investigation and analysis of the RSSI are required. In order to implement this system in a real-world case, the distance of LoRa transmission need to be improved. In theory, LoRa coverage is about 3-5 kilometers. However, in our experiment, the coverage is about under 1 kilometer. In addition, this system is not perfect. There is no notification delivery system yet. This system is beneficial when an error occurs in the irrigation system, for example, when the floodgate is damaged and cannot function normally. The notification delivery system can use an SMS gateway or an Android application.