Development of a real-time wireless sensor network-based information system for efficient irrigation of upland and lowland crop production systems

This study developed a real-time web-and WSN-based information system for efficient irrigation water management and automation of drip-irrigated upland crop and intermittently-irrigated lowland crop production systems. The web-based system uses Flutter and DART to accommodate multiple end user platforms, while the WSN-based system uses state-of-the-art hardware and sensors for real-time monitoring of soil moisture, water level and weather conditions. The sensors are wirelessly connected in a low-power mesh network that sends data to a central server. The sensor readings are uploaded to the web application via MQTT, which generates charts and graphs for data analysis. The sensor readings compared well with measurements from conventional instruments. The system in this study provides a sustainable solution for improving irrigation efficiencies under both upland and lowland crop production systems, in minimizing water losses and in improving the overall agricultural crop productivity.


Introduction
The Philippines is home to large areas of agricultural land. In fact, within its 30 million hectares of land area, 44% is agricultural [15]. These wide harvest areas are used to grow upland and lowland crops. But despite the size of the country's agricultural real-estate, most of the farmers in the Philippines, especially in the small to medium scale, are stuck using traditional methods of irrigation and water management [16]. This is highly inefficient because these methods often prioritize immediate gain more than overall sustainability. It also leads to high labor and water consumption costs. It can also result in reduced crop yield and crop production because of unintentional under or over-irrigation. For instance, in 2012, 16% percent of the country's rice output was lost due to inefficient farming methods and equipment [17].
Pursuant to the Department of Agriculture's vision of modernizing the country's agricultural sector and to address issues like climate change, climate variability, aging farmers, inefficient irrigation systems among others, this study was conceptualized to develop a smart irrigation system. In general, smart irrigation systems help improve irrigation efficiency and agricultural sustainability by using wireless sensor networks (WSN) that transmit sensor parameters such as volumetric soil water content, temperature, and humidity to information systems, which then serve as basis for irrigation scheduling. These systems allow farmers to monitor and automate irrigation of crops. Furthermore, the system can IOP Publishing doi: 10.1088/1755-1315/1038/1/012028 2 save the sensor readings into storage devices or the cloud. The ability to save data from months or years of crop production opens up opportunities in developing science-backed strategies for better and sustainable use of water.
To date, there have already been numerous research studies about wireless sensor network-based smart irrigation systems all around the world [1][2][3][4][5][6][7][8][9][10] and in the Philippines [11][12][13]. Most of them used an Arduino UNO or a NodeMCU microcontroller board as a base controller [1,2,6,9,11,12,13]. And although these hardware solutions are affordable and convenient, they are not the best for smart irrigation systems. This is especially true for upland and lowland crop production. Upland and lowland fields occupy large areas of land, and sensor nodes are often distributed within them. Wired power is inefficient because long lines have high voltage drops. The Arduino UNO and NodeMCU are both versatile boards but they consume too much power for a battery to support.
Several of these previous studies used standard RF and Zigbee modules [3,6,7,9]. Standard RF technology is adaptive but it is complicated to design. These modules also do not have mesh networking; hence, communications must be done directly between a transmitter and receiver. Alternatively, Zigbee offers a simplified mesh networking but is short-range. Although most sources state that it can transmit up to 100 meters, most modules today only work within 10-meter range [19]. No study has yet developed a web-based information system using Google's Flutter framework. Flutter allows multi-platform application development with a single codebase, significantly reducing development time.
The WSN developed in this study used a Metronome Systems Neomote and Manager. These are lowpower and robust devices specifically designed for outdoor applications. The wireless technology is based on the earlier works of Zhang and Glaser [20,21,22]. This technology has never been applied to drip irrigation or for irrigation water management of lowland rice using alternate wetting and drying (AWD) technology. This study aimed to develop and test a WSN system based on Metronome Systems hardware and a web-based information system using Flutter for efficient irrigation of upland and lowland crop production systems.

Materials and Methods
This section describes the system architecture (Section 2.1), hardware (Section 2.2) and software (Section 2.3) used in this study. The technical descriptions are simplified as the technology is published under a BSD open-source license (https://github.com/realms-team/). Section 2.4 provides the particular experimental setup used to investigate the improvement of lowland and upland crop production systems using the underlying WSN technology.

System Architecture
The WSN-based system developed in this study involves sensor stations, a manager, a cloud server, and an end-user application ( Figure 1). The sensor station reads the analog and digital data from the sensors, and sends the data to a central device called Manager. Furthermore, the network manager is connected to the internet through a cell-phone modem, allowing it to send the data to a cloud server using MQTT (MQ Telemetry Transport). Meanwhile, inside the cloud server is a Python parser, which converts the raw data from the manager to individual sensor readings. Afterwards, the readings are converted to a float data type, then packed to a JSON format. The converted JSON holds all the sensor readings and is used to store information into an InfluxDB database inside the cloud server.
The web-based information system is written in Dart using Flutter framework. The flutter-based web application accesses the data from a time-series database InfluxDB. It uses a RESTful API to fetch sensor readings in real-time and displays them in multiple platforms by the end users.
This system is primarily intended for lowland and upland crop production field applications. For that reason, the WSN must be adaptable to function in a wide range of outdoor environments. Mesh networking allows the motes to pass messages to each other ( Figure 1). This feature increases the network range of the WSN without using high-power radio modules. It also improves reliability since a defective or non-functioning mote does not disable the whole network. Rather, the other motes use alternate communication paths. Another advantage is flexibility in node placement; multiple routing paths allow motes to choose an optimal receiver with better connection. Additionally, repeaters are used to extend the signal reach of the WSN to the manager. Repeaters use the same wireless module as the motes. The main difference is that they are used in areas outside the deployment field.
The user inputs the desired mac address of a sensor station to view real-time information from the sensors. This data is used to automate and schedule irrigation by reprogramming the motes based on the data gathered from the wireless sensor network.

Hardware Design
As mentioned in Section 2.1, the three core components of the WSN-based system are sensor stations, repeaters, and a network manager ( Figure 2). A sensor station reads sensory data and transmits it to the WSN made up of motes and their corresponding sensors. The mote used is Metronome Systems' Neomote ( Figure 2a) which is a highly-configurable and ultra-low power solution for real-time sensing and control. It features a Cypress PSoC 5LP system-on-chip with a 16-bit ARM programmable microcontroller. The chip has 48 fully configurable IO pins which allows the mote to interface with virtually all analog and digital sensors. The mote uses a SmartMesh IP low-power wireless module from Analog Devices. This module allows wireless mesh networking out-of-the-box with over 99.999% IOP Publishing doi:10.1088/1755-1315/1038/1/012028 4 reliability. Unlike common power-hungry radio modules, the SmartMesh IP only consumes less than 5µA at 3.6V. Moreover, the Neomote contains an SD card for local storage and an on-board real-time clock (RTC) for timestamping. For field deployments, repeaters ( Figure 2b) are used if the sensor stations and network manager is further than the range of their wireless modules. It maintains the redundancy of the WSN. Unlike the sensor stations, the repeaters have an onboard battery holder. This allows them to function right out of the box which is advantageous for creating node placement strategies.
The network manager (Figure 2c) collects the raw data from the sensor stations (up to 100 nodes) and uploads them to the cloud via an Ethernet connection. It also builds the multi-hop mesh network with the sensor stations and repeater nodes. The manager used is Metronome Systems' Manager. It features an embedded TS-4800 GNU/Linux computer and a SmartMesh IP Manager. The TS-4800 was used because of its low-power consumption (rated 50mA). It sits at the root of the network allowing users to interact with the WSN and even incorporate their custom applications.

Software Architecture
The software design of the WSN-based system is divided into four parts: the Mote firmware, the Repeater firmware, the Manager software, and the cloud server software. The Web-based end of the system uses Dart with Flutter.

Mote firmware
The SmartMesh IP chip inside the Neomote is pre-programmed in slave mode. Slave mode allows the module to communicate with the PSoC. The PSoC is programmed to accomplish 3 main tasks: (i) read the sensors attached; (ii) save the values into an SD card; and (iii) send the raw data over serial (HDLC) to the SmartMesh module. These tasks are executed every minute, or depending on the time interval set in the code. When the mote is inactive, it stays in an ultra-low-power mode.
The mote firmware is written in C using PSoC Creator. PSoC Creator is an Integrated Development Environment (IDE) provided by Cypress. Aside from the traditional C development environment, it features a graphical user interface for rerouting the analog and digital connections of the chip. This allows users to add or remove components like UART and ADC by simple drag-and-drop. With this functionality, the PSoC chip becomes a highly configurable solution for interfacing to any kind of sensor. The mote had no problem interfacing with the sensors used in both lowland and upland crop production systems.
For the sensor drivers, all are based on their respective data protocols. The MP306 Soil Moisture Sensor (Figure 3a) and Ametek Water Level Sensor (Figure 3b) are both analog sensors. Thus, they measure data by returning varying degree of energy called analog signal. This signal is connected to a On the other hand, the Lufft Weather Station uses an SDI-12 digital protocol. SDI-12 is an asynchronous serial communication protocol for smart sensors. This protocol allows multiple data values to be sent in a single packet, which is very convenient for the Lufft sensor since it transmits a data packet containing multiple readings. The Lufft interface is standard RS-485, but we used a converter to access the sensor's configuration tool and convert the output to SDI-12.

Repeater firmware
The SmartMesh IP module inside the repeater is pre-programmed as well. It runs on master mode so that it does not need any external microcontroller such as the PSoC. It does not produce a health report but instead relays all data it receives to the manager.

Manager software
Similarly, the SmartMesh IP module inside the Manager is pre-programmed. The manager is able to support up to 100 nodes as is. It handles retrieving of sensor readings and network statistics from the WSN, and uploading the data to a cloud server. The manager firmware is a multi-threaded Python program that connects to the server over a RESTful API using HTTPS.

Server software
The cloud server used is an Ubuntu 20.04 LTS computer hosted by Digital Ocean. The server runs four applications: (i) an MQTT parser that receives the data from the manager; (ii) an InfluxDB time-series database that stores all the WSN readings; (iii) a RESTful/HTTPS API in JavaScript that pulls data from InfluxDB; and (iv) a web-based real-time information system in Flutter.

Flutter web application
The other main part of the study is the development of a web-based information system that displays real-time data of the WSN. In the previous papers using WSN with Metronome Systems' hardware, Grafana was used as the default display interface for the WSN. In this study, the proponents developed their own with Flutter as the base framework. Flutter is a Google SDK (Software Development Kit) that allows cross-platform development using a single codebase. Retrieving sensor readings becomes effortless with the use of the RESTful/HTTPS interface in the server. The web application simply sends HTTPS requests to the server for data.

Field testing of the WSN and web-based system
Both the WSN and Web-based systems were tested at the mini-field laboratory test site located at the College of Engineering and Agro-industrial Technology Building complex at the University of the Philippines Los Baños (Figure 4).  The micro-paddy for lowland rice (Figure 4b) is 2.5 meters long, 1.5 meters wide, and 1-meter-tall concrete box with 20 x 20 cm-spaced rice plants. The rice crops were irrigated using alternate wetting and drying method. The rice variety used generally matures at 107 days after seeding if direct seeded and 122 days if transplanted. All tests performed in this study were within the planting and harvesting dates of the crops.
The sensors were connected to separate motes in a room next to the test site. These motes were powered by a constant voltage 12V power adapter. The manager was also positioned in the same room. Since the mote and manager were within the detection range of the SmartMesh IP, no repeaters were necessary during the testing.

Results and Discussions
This section presents the outputs and major findings of this study. Section 3.1 describes the deployed system using the technology described in Section 2. Section 3.3 shows the examples of real-time soil moisture, water level, and weather data from the sensor measurements taken. Section 3.3 provides comparative analyses between the sensors used and conventional instruments.

Deployment
The WSN-based system was deployed at the mini-field test site at the building complex of the College of Engineering and Agro-Industrial Technology (CEAT), University of the Philippines Los Baños (UPLB), Philippines. Two sensor stations were used to test the WSN-based system. One sensor station was connected to the AWS (Automatic Weather Station) and the Soil Moisture Sensor, while another was connected to the Water Level Sensor. Both were placed in a room adjacent to the test site. For the power source, the sensor stations and the manager were connected to 12V power adapters. Due to the proximity of the sensor stations and the manager, no repeater was used in this study.
The Soil Moisture Sensor was installed within the rootzone of the corn plant box filled with Lipa-Calumpang clay loam. The Ametek sensor was placed inside a fabricated container in the rice micropaddy. The AWS was positioned atop a 4-meter steel pole at the center of the test site. It measures air IOP Publishing doi:10.1088/1755-1315/1038/1/012028 8 temperature, relative humidity, air pressure, wind speed, wind direction, rainfall intensity, and rainfall depth. Figure 5 shows the Grafana dashboard used to visualize the sensor data. Grafana is an open-source interactive data visualization web application that provides graphs and charts using supported data sources. Grafana supports InfluxDB: the time-series database used in this study. Moreover, Grafana refreshes in set intervals set by the user (as low as 5 seconds). It auto-populates the graph as soon as a sensor reading is added in the database.  Figure 6 shows the Flutter-based web application developed in this study. This application displays the real-time values of the sensors. Currently, the dashboard can only display the sensory data of one sensor station. In order to change the target device, the application must be recompiled using an Integrated Development Environment (IDE) that supports Flutter. The IDE used to develop the application is Visual Studio Code. The web application is static, meaning the user must refresh the page to get the latest sensor readings of the target device. The application uses the RESTful API in the cloud server to fetch data from the InfluxDB database.

Sensor Comparison with Conventional Instruments
The readings from the sensors used in this study were compared those obtained from traditional instruments to evaluate the performance of the WSN-based Information System.

MP306 Soil Moisture Sensor
The resulting volumetric water content readings from the MP306 were recorded and compared with the soil moisture readings of a Time Domain Reflectometry (TDR) sensor. TDR sensor is a highly-accurate reference sensor that measures soil moisture using time-domain reflectometry (TDR) based on the correlation of the soil's electric and dielectric properties. The manufacturer's calibration equation was used to obtain the %VWC readings of the MP306. Both %VWC values of the MP306 and TDR were plotted against each other as shown in Figure 7. To quantitatively assess the differences between the MP306 and TDR readings, the RMSE (Root-Mean-Square Error) was computed estimating residual variance (difference between the measured and reference values). Results showed a relatively low RMSE at 5.16%, indicating that the %VWC of the MP306 can vary up to 5.16% from the reference %VWC of the TDR sensor. It should be noted, however, that this assessment was only based on a sample subset of soil moisture readings. The degree of contact between the sensors and the soil may have been a factor that caused the discrepancy between the readings at each instant.

Ametek Water Level Sensor
Similarly, the Ametek water level sensor readings were recorded along manual water level readings. Linear regression was done to convert the sensor's analog signal to water level in centimeters. The calibration equation was based on the following general linear regression equation: in which V is transducer output (mV), P is pressure (cm of water); a is the y-axis intercept and b is the slope of the best-fit line. Both water level values were plotted against each other as shown in Figure 8. It is apparent from Figure 8 that the Ametek water level sensor adequately captured the actual water level fluctuations in the micro-paddy based on manual water level measurements. Moreover, the computed RMSE between the values was appreciably low at 1.4737 cm., indicating that the Ametek sensor's readings can vary up to 1.437 cm only on average.

Lufft Automatic Weather Station
The weather data from the Lufft Automatic Weather Station was also recorded and compared to the data recorded at the National Agrometeorology Station, at the University of the Philippines Los Baños (UPLB), Philippines, located less than 1 km away from the test site. This weather station uses conventional weather instruments such as maximum and minimum thermometers, sling psychrometers, hygrometers, mercurial and aneroid barometers, 200 mm (8-inch) standard raingauge, tipping bucket raingauge, 3-cup type anemometer, propeller-type anemometer, among other traditional instruments.
Since the data collected at the Agromet station are generally mean daily values, the Lufft sensor readings were converted to the same time step to enable proper comparison. Approximately 1440 sensor readings were averaged to get the daily mean of the Lufft sensor readings. Moreover, only air temperature, relative air humidity, and relative sea-level air pressure were used. Figures 9 to 11 show a comparison between Lufft sensor readings and those obtained from the National Agromet station for the aforementioned weather parameters. The RMSE for all three parameters were computed to assess the Lufft sensor's performance.    Figure 11. Comparison of mean relative air pressure from the Lufft Automatic Weather Station and the National Agrometeorology Station.
For air temperature, an RMSE of 2.6676 was obtained indicating an average 2.6676 °C of residual variance of the Lufft weather station against the values from the Agromet station ( Figure 9). Relative humidity values had an RMSE of 8.6323 (Figure 10), which apparently is a relatively high residual variance considering the relative humidity is in percentage. This value means the Lufft sensor can vary up to 8.6323% compared to the reference value from the Agromet station. Lastly, the air pressure comparison yielded an RMSE of 4.2201 (Figure 11), meaning the average residual variance can vary up to 4.2201 millibars, which is appreciably low.
While there are obvious minor discrepancies between the Lufft sensor readings of air temperature, relative humidity and atmospheric pressure, it should be noted that the Lufft weather sensor could generate weather data at smaller time intervals and that the daily average values from these smaller incremental observations could prove to be more accurate than the daily observed values from the Agrometeorological station. Moreover, there are multiple variables from the environment at both sites that may contribute to the variations in observed weather data. Nevertheless, the tests performed in this study demonstrated the reliability of the Lufft weather sensors readings.

Summary and Conclusion
This study developed a WSN and Web-based information system for efficient irrigation of upland and lowland crop production systems. The system was designed to read, record, and upload soil moisture, water level, air temperature, relative humidity, relative sea-level air pressure, wind speed, wind direction, rainfall depth, and rainfall intensity values from an ICT International MP306 soil moisture sensor, Ametek SDT (SDTSF006ELSV) submersible pressure transducer, and a Lufft WS600-UMB Automatic Weather Station. The web-based information system used Flutter and DART to display realtime values of a target sensor station from the WSN. Both the WSN and Web-based systems were tested in a mini-field laboratory test site with upland corn and lowland rice crops. The high-end sensor readings were compared with those obtained from traditional instruments. Statistical data revealed that the volumetric water content readings from the MP306 (RMSE = 5.16%) are comparable to those obtained using a TDR soil moisture meter. Similarly, the Ametek water level sensor results (RMSE = 1.4737) proved to match well with manual water level measurements. The Lufft weather sensor also performed well in its temperature (RMSE = 2.6676), humidity (RMSE = 8.6323), and air pressure (RMSE = 4.2201) readings relative to the climatological data obtained from a nearby weather station. All of the sensors used have proven to be reliable alternatives for conventional instruments and could prove adequate for efficient irrigation water management of upland and lowland crop production systems.