A System for Measuring Water Levels in Open-Air Irrigation Canals

The measurement of the water level in a canal allows us to know its flow. This information is essential for the correct administration of the water resource. Manual quantification can be replaced by micro controlled systems with an internet connection. Thus, the measurement and recording of water levels in open canals in real time is achieved. The chosen micro controlled system was based on ultrasonic instrumentation with GPRS communication. It had a wide cellular network to achieve an effective connectivity in rural areas, a power system combining solar energy with pollutant free batteries and the capacity to store data. The obtained percentage and average errors were lower than the permissible error specified in the requirements. Consequently, the evaluated measurement system is reliable for the evaluation of canals in a real-world setting.


Introduction
The increased demand for water resources for urban and industrial use has had a detrimental effect on the water available for agricultural production [1,2]. Therefore, a better management of the water available for irrigation is now essential.
When evapotranspiration exceeds precipitation, it is necessary to implement irrigation systems to guarantee sustainable agricultural production. Despite the building of reservoirs, water distribution systems are not efficient enough. This produces losses that increase costs and decrease the availability of water resources for farmers [3].
Traditionally, water level measurements were made with manual gauging systems [4] that offered imprecise results. Technological innovations have led to the development of more accurate electronic systems or systems based on diffuse controllers. In Ecuador, although the water distribution systems have been upgraded, they do not have a remote monitoring system to provide information on the water level in the canals.
Certain manoeuvrers are performed during the flow of water in the canals. These include tactics designed to divide the flows in one or several lateral branches, and those aimed at keeping certain stationary states constant. For the latter, the canal requires the shortest possible transition state and insignificant oscillations in water levels to avoid extreme variances in the deliveries [5]. This manoeuvre causes an inadequate measurement of the water level, which leads to unnecessary water costs, electricity consumption and longer pump and gate operations [6].
Notwithstanding the technical requirement, there is no adequate monitoring system to determine the protocols for managing floodgates and activating pumps in the irrigation canals. The consequent occurrence of unrecognized leaks and infiltrations leads to inefficient use of the water resource [7]. Therefore, it is important to check the water level in the network of irrigation canals to control the quality of the water distribution. The current mechatronics' knowledge of the measurement systems based on sensors and microprocessors [8,9] has allowed the optimization of systems used for monitoring, recording and measurement of water in the irrigation canals.
Using appropriate instrumentation, it is possible to detect changes in the water level in a canal, as well as any anomaly along the distribution network. This allows the implementation of corrective or preventive solutions. Therefore, automatic control of the water level in canals plays a key role in the performance of irrigation projects [10].
The modernization of control and measurement systems has gained ground all over the world. This upgrading can generate hydraulic models with proper height monitoring and data recording. Whereas the operation of the irrigation canals was improved mainly in two ways. First, adopting new technologies that enhance the interaction between the operator and the system, and second, using digital sensors to control and supervise the canals [11,12]. The technification of the irrigation systems through instrumentation, control and remote operation was an effective way to increase the efficiency of water distribution in areas of shortage, and resolve the constant disputes over its use.
In this context, various irrigation districts in Mexico have sought to increase the percentage amount of water used. As a result, the crop yields were higher due to the improved irrigation efficiency, optimized energy consumption, and reduced environmental and economic impact of water losses. The consequences observed in the yields were also influenced by the decrease in the duration of the manoeuvres and the reduction of the operators' expense. The modernization of the instrumentation for measuring and monitoring water flow through the irrigation canals was achieved using mathematical models and an automated gauging and measurement system based on fuzzy logic [13,14].
Ecuador is an entirely agricultural country with important irrigation systems for farming, most of which lack automated systems for measuring the volume of water during the distribution process. The objective of this research was to evaluate an automated system for recording, controlling, and monitoring water levels in the irrigation canals. It was based on a mechanism of collection, storage and transmission of data using microprocessors, sensors and a cellular network. These features will allow its use in rural areas of difficult access. The proposed system is based on the use of solar energy combined with heavy metal-free batteries that guarantee its operation with a minimum environmental impact.

Materials and methods
In the field, a system capable of measuring the water level in the canal was used for data collection. The instrumentation employed was suitable for the working conditions. In addition, the integrity of the components was ensured having a strong and resistant protection against external environmental conditions.
A communication system with access to the internet was developed to transfer the water level measurement data from the field to the operator. This system was made compatible with the technology used in the later stages: data acquisition and user interface display.
The acquisition stage of the measurement system must be autonomous to ensure its continuous work even in areas without electrical grid.
Two tests were conducted with the monitoring device placed 4 meters above the base of the irrigation canal to evaluate the system's performance and validate the accuracy of the quantifications. Using the sensor, 182 water level measurements were made with a five-minute interval. Of these, 104 quantifications were performed with a 41 cm and 78 with a 5 cm water level. Thus, the behaviour of the system at different water levels was observed. The data obtained was analysed using descriptive statistical parameters. The water measuring system comprises various components that are described in detail below.

Sensor
The MB7060 XL-MaxSonar-WR ultrasonic sensor by MaxBotix [15] was selected because of its outstanding characteristics for operating outdoors. It does not require to be in direct contact with the water and is waterproof.
This sensor has an analogue output and one centimetre spatial resolution. The ultrasonic sensor selfcalibrates based on the input voltage according to the Equation 1.
This self-calibration capability reduces or renders the need for sensor maintenance, almost nil, compared to other devices.
Where hs = the distance between the sensor and the water surface of the canal. Vcc = reference voltage

Microcontroller
The ATMEGA 328p microcontroller was used because it is compatible with free software and has an operating current below 200mA at 5V. This microcontroller is the most efficient option for information processing at the data acquisition stage due to the optimal working frequency.
It is worth mentioning that the use of a Programmable Logic Controller (PLC) was not considered, despite its superior intrinsic characteristics of robustness compared to microcontrollers. The hardware characteristics of PLC do not necessarily add value to the system design, along with an unwarranted increase in the cost of the device.

Communication technology
The evaluated irrigation canals were comprised in the Catarama Project, located in the rural area of Los Rios province. In this area, the mobile phone signal is not strong enough to use the Global System for Mobile Communication (GPRS) connectivity.
A data transmission module was selected to access the internet via cell phone. The module was compatible with the chosen microcontroller and the working conditions. This SIMCom [16] cellular communication module had GSM/GPRS SIM800L capacity and was able to work at higher temperatures than the competitors. It has a low power consumption and a high speed for data transfer. In addition, its ability to work with a signal strength as low as -114 dBm is outstanding, and makes it ideal for internet connection.
The SIMCom module was connected to the ATMEGA328P microcontroller through TX-RX serial communication. For this communication the SIM800L has an auto-tuning system with the "autobaud" working frequency.

Power source
For research purposes, photocells that capture solar energy were used to generate electric power. They were chosen given the ease of implementation and energy production.
Data on average annual insolation were considered to choose a suitable solar panel [17]. After the evaluation of the full power characteristics, the monocrystalline panel SYSM10S was selected as it is capable of supplying up to 10W to the system.

Circuit design
Most of the selected components and modules were powered with 5V, therefore, the DC-DC LM2596s integrated circuit module was used. This integrated circuit module was responsible for regulating the voltage up to the 5V required by the system. In addition, a voltage sensor module was added to monitor the performance of the solar panel.

Software development
The program for processing sensor data and sending information to the database was developed using the ARDUINO IDE platform, compatible with the AVR ATMEGA328p, following the process shown in Figure1.

Database
The database recorded information on the date and time of the measurement, the device identification code and the power source voltage. As a security measure, for the design of the application it was necessary to limit the access to the information and its manipulation. Consequently, a table was created to supervise the access of the users to the platform. The password and user type ere also registered. The database used was of type MariaDB.

Web Application
The web application was designed to consult the information stored in the database and generate reports on records displayed. A built-in template-based PHP code generation tool was used for application development. Thus, a fast and efficient management of the information and the linking of tables previously created in the were achieved. The linked charts were the CAUDREGISTRO transactional table and the  SEGURIDADES  security  table. Hereby, the CAUDREGISTRO dynamic table was created, which allows the creation of diagrams.

Flow calculation
The calculation of the water flow in the irrigation canal was done by measuring the water level using ultrasonic technology. This technology was used as it did not require direct contact between the sensor and the water to take measurements. In addition, it can be placed on the canal out of reach of third parties.
Considering the typical cross section of a trapezoidal canal, the placement of the sensor on the canal is showed in (Figure 2).
Where: d = canal water tie-back HS = distance between the sensor and the base of the canal hs = distance between the sensor and the water mirror of the canal.
Posterior to the computing of the water tie-back (d) and using the dimensions of the canal, Equation 3 [18] was applied. Thus, the average speed of the water in the canal was estimated.

Choice of instrumentation
The water level measurements were made in an open chanel. Therefore, one of the conditions taken into account for the selection of the instrumentation was its ability to operate outdoors. Ultrasonic technology was selected because it did not require direct contact between the sensor and the water to perform measurements [19]. In addition, the sensor could be located on the canal out of reach of third parties. This type of technology had a number of advantages when compared to hydrostatic, capacitive and mechanical methods. The benefits are summarized in Table 1. The second criterion for the choice of instrumentation was the ability of the microprocessor to transmit the measured data. The selected microcontroller made it possible to collect the data from aforementioned ultrasonic sensor, transform this data into information and then send it to the web through a communication module. In [20], it is indicated that the cost of microprocessors reduced the cost of sensor installation. However, affordable controllers with high data storage and transmission capacity are currently available on the market.
The choice of the controller (ATMEGA 328p) was based on its compatibility with free software, its operating current that does not exceed 200mA at 5V, and its optimal working frequency. Additionally, ATMEGA 328p had a lower acquisition cost than other microcontrollers (Figure 3), which improves the viability of the project.

Communication technology
Internet connection was achieved through the mobile network. The cellular network had considerable advantages over other Internet connection technologies. The most relevant advantages were its wireless autonomy for sending data and its cost-benefit ratio due to its installation versatility [21]. The advantages of this network are described in Table 2. High cost.
Another advantage that stood out is the wide coverage of the cellular network in urban and rural areas of Ecuador. The project was located in the rural area of Los Rios province, as is the Catarama Project. Mobile network coverage was strong enough to use GPRS connectivity along the canals.
In the South American countries, which are crossed by the Andes mountain range, data transmission becomes complicated. Among the efforts to improve it, [22] the use of a DTT and 4G-LTE cellular transmission system in Colombia stood out. This DTT technology provided benefits that allowed Internet connectivity improvement in rural areas, minimizing connection costs per user. Furthermore, it reduced the need for specialized infrastructure building, since it reused the existing analog and/or digital TV infrastructure. Its applications could be used in data transmission projects for environmental and agricultural purposes as proposed in this research.

Power source
The measurement system was located in a rural area, so an autonomous power system that ensured constant data acquisition throughout the year had to be chosen. Besides, this energy source must be sustainable and lowpollution. Thus, a mixed system was chosen, combining solar energy with the use of low-polluting batteries. In this sense, [23] stated that the use of solar energy was relevant for irrigation systems in isolated areas, due to the high cost of using another energy sources.
In this project, photocells were used to capture solar energy and generate electrical power, since this is an easy method to obtain energy. Given that the canal water measuring modules required 11.5W of power from source, the photocells did not guarantee sufficient autonomy for continuous data acquisition. Thus, the system had to rely on the use of batteries, which were chosen according to their cost, unit of mass and volume.
When reviewing the advantages and disadvantages of the different types of batteries (Table 3), the lead acid batteries stood out, both for their cost-benefit and for their safety. These batteries had a lower risk of explosion under the given working conditions, even though they had a lower charge density per unit of mass compared to other batteries. Undoubtedly, the low charge density per unit of mass and volume makes the devices less portable. However, this is not a relevant factor for the proper functioning of the device, since portability is not required in this project. The selected power source guarantees portability, system autonomy and adequate storage capacity. However, lead acid and nickel batteries were discarded due to the risk of contamination of the river and surrounding areas, since heavy metals are present in their composition [24,25].
This whole system allowed the calculation of the long-term water flow, that permitted the recognition of the water supply in the canal and the operation of the irrigation system. Thus, guaranteeing an equitable water delivery to the farmers who benefit from the irrigation system of the Catarama River.

Water level measurement
The results of the statistical analysis for the 41 cm depth are shown in Table 4. This analysis showed an average of 40,81 cm, a coefficient of variation of 2,21 and a percent error of 0,09. The fact that the values measured by the system were similar to the real values, indicated that the use of the sensor can replace manual gauging systems. The proposed system allowed simultaneous measurements to be carried out continuously during different seasons of the year and environmental conditions. In addition, this measurement system performed the storage and transmission of data, which allowed a systematic evaluation of the operation of the irrigation system. The use of sensors allowed the non-dependence from the operators, which usually increased operating costs [26]. It also facilitated the water level measuring in rural populations that are difficult to access (irrigation systems in the Andean regions of South America [27,13]) or regions where manual measurements are difficult due to social conflicts or insecurity (some irrigation districts in Mexico or Colombia [28,29]).
The operation of the sensor was tested at two water levels, to evaluate its behaviour when changes in depth occur. Table 5 shows the water height for a water level of 5 cm, observing that the percent error in none of the cases reached 1%. The reliability of the measurement system at different water levels allowed its use in the monitoring and control of water levels in open canals. In this type of canals, environmental conditions could affect the measurements, while inadequate measurements lead to prolonged floodgate openings. Excessive opening time leads to water losses and waste of operating time and energy [26]. Furthermore, the structure of the sensor allows it to be placed at different points in the canal, and thus identify leaks and filtrations that reduce the efficiency of the irrigation system [30].
On one hand, the system provides the measurement of water levels with values close to the established standards. Moreover, it provides a method for the acquisition and recording of data that is easily transmitted from remote sites to decision making areas using clean energy.

Conclusions
The percentage and average errors were lower than the permissible error. Consequently, the measurement system is reliable for calculating the flow rate in canals under real conditions. The use of the mobile network as a means of web communication allowed the remote monitoring of water levels. It is important to highlight its ability to work in rural areas or areas of difficult access due to its wireless mode of operation.
The use of solar energy in the devices combined with non-polluting auxiliary energy sources ensures 100% autonomy of the system.
The verification of the correct functioning of the web platform was successful. Its subsequent execution allowed the visualization of new information on the height of water in the canals and the storage of data on the measurements made by the sensor.