DEVELOPMENT OF A LOW-COST OPEN-SOURCE PLATFORM CONNECTED TO THE INTERNET FOR ACQUISITION OF ENVIRONMENTAL PARAMETERS AND SOIL MOISTURE

The development of the Internet and the technologies associated with it has allowed disseminating and cheapening of communication equipment, prototyping services, electronic sensors, and all types of devices. Agriculture has benefited from these technological advances to boost its productivity and profitability. This study presents the development of a data acquisition and device control platform to obtain, in real-time and remotely, information from the field for decision-making and process automation. All electronic components are low-cost and “open hardware”, and the software is “opensource”. The developed platform was validated during a development cycle of two lettuce varieties (Japanese and crisp), in which the soil water matric potential was monitored at two depths (10 and 25 cm), while solar irradiation, air temperature, and soil temperature were evaluated only to monitor the cycle. The platform automatically and satisfactorily controlled the applied irrigation depths using only the data of matric potential by activating a solenoid valve and made the information from the sensors available on the ThingSpeak Internet of Things (IoT) platform.


INTRODUCTION
In Agriculture 4.0, having reliable, real-time data has become a widespread requirement to minimize risks, maximize production results, and increase farm profit (Rawal, 2017). In this context, the use of Internet of Things (IoT) tools is important (Kansara et al., 2015), as currently almost all devices can be connected (Estevam et al., 2019). Devices such as smartphones can receive or access data in the cloud, send equipment control orders, monitor the evolution of environmental parameters, being important tools that assist in decision-making or automation (Fisher et al., 2018;Fisher & Gould, 2012;Jordão et al., 2017;Payero et al., 2017). Automated microirrigation systems can reduce labor demand and optimize the water depth to be applied, resulting in water savings (Rao & Sridhar, 2018) and benefits to the enterprise and the environment (Gutiérrez et al., 2014). This study aimed to develop a robust data acquisition platform, easy to install, operate, and maintain, autonomous in terms of energy, in addition to being of low cost and able to work under adverse weather conditions (sun or rain). The monitored parameters can have their data sent and received via text messages (SMS), stored on microSD cards for later evaluation, and/or sent to IoT platforms, which enable real-time access or process automation. The monitoring and control of the irrigation of the lettuce crop are presented and discussed to validate the system.

MATERIAL AND METHODS
The design of the data acquisition platform was initially carried out on a perforated phenolite board to confirm that its execution was viable. Modules, sensors, and an Arduino Nano were added to it to manage the designed system. Proven to be feasible, the design of a printed circuit board (PCB) was carried out on the website www.EasyEda and manufactured by the company JLCPCB (Hong Kong). Then, several components were integrated into the boards, including a microcontroller, several sensors, power sources, and communication and data storage components. The platform also included other Engenharia Agrícola, Jaboticabal, v.41, n.3, p.338-346, may/jun. 2021 devices to meet specific needs, such as the activation of electrical equipment. The board with the necessary components, such as relay and batteries, was installed inside a metal box for electrical and electronic circuits with dimensions of 400×300×200 mm and a sealed door to prevent water and dust from entering ( Figure 1). The validation experiment, which consisted of the automatic monitoring and control of the irrigation for the cultivation of two lettuce varieties, was carried out at the experimental area of the Department of Biosystems Engineering of ESALQ/USP, Piracicaba, SP, Brazil, at coordinates 22°42′41″ S and 47°37′'45″ W. The regional climate is Aw, that is, a tropical climate with a dry season, according to the Köppen classification (Dias et al., 2017), with an altitude of 546 m. All variables were monitored every 10 minutes and made available via wireless Internet (GPRS/GSM) through the ThingSpeak IoT platform (www.thingspeak.com). FIGURE 1. Printed circuit board with components, modules, and sensors.

The
ATmega328P microcontroller (Atmel Corporation, San Jose, CA, USA) contains 32 KB of flash memory for storing programs, 1 KB of non-volatile memory (EEPROM), 2 kB of static random-access memory (SRAM), 23 general-purpose digital inputs and outputs (GPIO), one I 2 C interface (Inter-Integrated Circuit) and SPI (Serial Peripheral Interface), programmable serial USART (Universal Synchronous/Asynchronous Receiver-Transmitter), 6-channel, 10-bit analog-to-digital (A/D) converter. It operates between 2.7 to 5.5V (reference datasheet). It is programmed using the free Arduino Integrated Development Environment software (Arduino IDE; https://arduino.cc). The IDE is based on the C ++ programming language and is used to write the algorithm (program), compile the code, check for any programming errors, and transfer the compiled program to the microcontroller. Finally, the program instructs the microcontroller to manage the entire system.

Temperature sensors
The platform includes connectors (terminals) and a special circuit for the DS18B20 digital temperature sensor (Dallas Semiconductor, USA) for measuring soil temperature. This sensor has an accuracy of +/−0.5 °C, according to the manufacturer, is waterproof, and communicates via the Dallas 1-Wire protocol, allowing bidirectional communications with the microcontroller. This versatility (Cavalcanti et al., 2019) allows sharing a digital port on the platform with numerous other DS18B20 sensors. In this case, this sensor was used exclusively for measurements of soil temperature, which were used only as complementary information.
The DHT22 sensor (Aosong Electronics Co. Ltd, Guangzhou, China) was used for air temperature measurements. This sensor has an accuracy of +/−0.5 °C for air temperature. It enables temperature readings from −40 to 125 °C. It works with a current of 2.5 mA during measurements and 100-150 µA in standby, and a voltage from 3 to 6 V. This variable was also used only for monitoring the experiment.

Solar irradiance
The measurements of solar irradiance on the horizontal plane (Stocker et al., 2019) were performed with an ML-01 pyranometer (EKO Instruments Co., Ltd, Tokyo, Japan), calibrated in August 2019. This device has a sensor of silicon photodiode with a spectral response of 400-1100 nm, measurement range from 0 to 2000 W m −2 , response lower than 1 ms, and output from 0 to 100 mV. The voltage of the signal generated by the sensor under the conditions of this study is in the order of 1 to 60 mV, being necessary to design and build a signal amplifier and locate it before the reading by the microcontroller (Figure 1). Solar irradiance was not used directly in irrigation management.

Current, voltage, and power sensor
This subsystem was responsible for monitoring the production and/or energy consumption of the platform. The INA219 modules (Texas Instruments, Dallas, USA) were used, enabling the current, voltage, and power data from the source or load via the I 2 C protocol, and the DC Engenharia Agrícola, Jaboticabal, v.41, n.3, p.338-346, may/jun. 2021 (direct current) voltage sensor P25 (GBK Robotics, São Paulo, Brazil). Voltage sensors are important to have information on the charge status of the batteries (lead-acid and lithium-ion). The platform operates in a direct current (DC) regime.

Soil water matric potential (ψm)
Four porous capsule tensiometers, 45 cm long for water and air, with an MPX5100 pressure sensor (Freescale Semiconductor, Inc. Denver, Colorado, USA), connected to four analog platform ports, were used to measure the soil water matric potential (or tension) in the zone of highest activity of the lettuce roots at two depths (10 and 25 cm), thus controlling irrigation.

Communication
The communication subsystem consists of a SIM800L module (SIMCom Limited, China), which allows data to be sent from remote locations, without cabling, using the GPRS/GSM networks (2.5G General Packet Radio Service/2G Global System for Mobile Communications), from mobile phone operators, which are technologies widely used in Brazil. This module requires a chip (SIM card) with a subscription to connect to the Internet. The data can be accessed in real-time and remotely once the data are sent to the cloud, with no need to travel to the location where the data have been collected. The subsystems (communication and monitoring/control) are independent and, therefore, there will be no damage to the functioning of irrigation in case of a temporary lack of communication with the internet. Another benefit of having a communication infrastructure is making decisions in a shorter time if necessary (Rolim et al., 2019). The employed module has a 5 V supply voltage.

Internet of Things platforms
The services of the Internet of Things platforms are available for the user to create an account, free of charge. Then, a channel that will accept the data flow could be created within the account and a page will be displayed with the channel's options. The user must list the fields of data that will be sent to the platform. A unique key (API, Application Programming Interface) is assigned to each created channel to allow communication between platforms and associate the data sent to the channel. These platforms have options such as ThingSpeak (http://thingspeak.com), Adafruit IO (http://io.adafruit.com), and Thinger.io (http://thinger.io), among others. In this study, we opted for using the ThingSpeak platform, as used by Kansara et al. (2015).

Electricity
Two energy subsystems were necessary, as the data acquisition platform adopted a 5V DC supply voltage and a 12V irrigation system.
The energy subsystem 1, which energizes the data acquisition system, consists of a solar plate, as suggested by Uddin et al. (2012). The plate is 3W and 6V (150 x 160 mm), has four lithium-ion batteries model 18650 (4.2 V and 1800 mAh) in parallel, a TP4056 battery charger, and a step-up DC-DC converter (direct current-direct current with increased voltage) model MT3608, which regulates the voltage required for the platform to operate at 5V direct current. Average consumption of 310 mWh leads to a daily consumption (24 h) of energy of 7440 mWh. Therefore, the autonomy of the system is up to four days with the set of lithium-ion batteries, with 7560 mWh of power per unit.
The energy subsystem 2 energizes a solenoid valve (12 V), which has the function of opening or closing the passage of water to the irrigation system, which was operated only by gravity. It consists of a Sinosola SA10-36P solar plate of 10 W and 12V (350 × 252 mm), a leadacid battery (12 V and 7Ah), and a 10A charge controller. The average consumption of the solenoid valve was 6 Wh.

Irrigation management and uniformity
The land was cleared and the soil was regularized for the preparation of the bed, with an area of 7.25 m 2 . Before planting, 200 g m −2 of the mineral fertilizer 4-14-8 and approximately 3 kg m −2 of cured cattle manure were incorporated into the soil. After 10 days, the soil was subjected to irrigation for moistening. A total of 68 lettuce seedlings, 34 of the Japanese variety and 34 of the crisp variety, were transplanted with a matric potential close to −10 kPa. The seedlings were divided into four cultivation rows (5 m long each), with 0.30 × 0.30 m spacing between plants and rows ( Figure 2). Engenharia Agrícola, Jaboticabal, v.41, n.3, p.338-346, may/jun. 2021 FIGURE 2. Micro-irrigation lines (on the left) and process for evaluating their uniformity (on the right).
The irrigation system consisted of four polyethylene drip tapes (5 m long and 17 mm diameter), spaced 0.3 m from each other, totaling 17 drippers per tape ( Figure 2). The four lines were subjected to a uniformity test to determine the Christiansen uniformity coefficient (CUC), distribution uniformity coefficient (DUC), and statistical uniformity coefficient (SUC) to evaluate the hydraulic characteristics of the system, as suggested by Frizzone et al. (2012) and Araújo et al. (2020). The system was pressurized by gravity at a pressure of 4.4 mH2O, provided by the water supply system of ESALQ. The evaluations of the irrigation system were carried out by collecting water samples from all drippers for 15 minutes, measuring the volume in each collector, and calculating the flow rate and uniformity coefficients.
Irrigation management was based on real-time continuous monitoring of the soil water matric potential at two depths (10 and 25 cm) by using four tensiometers with digital pressure transducers (MPX5100) connected to the data acquisition platform (Figure 3). According to Reichardt (1985), matric potential is the result of capillary and adsorption forces that arise due to the interaction between water and solid particles, that is, the soil matrix. As a consequence, the matric potential is linked to soil moisture. The tensiometer installed at the smallest depth (10 cm) was the sensor whose reading the data acquisition system used to monitor indirectly the reduction in soil moisture once an algorithm condition was met, that is, ψm < −20 kPa, for the solenoid valve to be energized and allow the passage of water for irrigation. The end of irrigation also occurred automatically when the matric potential (ψm) at a depth of 25 cm became higher than −12 kPa, characterizing the arrival of the wetting front provided by the dripper and leading the solenoid valve to be de-energized and the water flow interrupted. The values of matric potentials used to start and end irrigation were based on the literature (Marouelli, 2008;Chinchilla et al., 2018).

Phytotechnical variables
The lettuce plants were cleaned by removing the leaves close to the soil, their weights were determined, and the commercial fresh mass was calculated. The productivity of water use relative to the fresh mass during the production cycle was calculated by the ratio between the applied volume of water and fresh mass.
The dry mass was determined by placing the clean lettuce in a paper bag and drying it in a forced-air circulation oven at 65 °C until constant weight.

Uniformity coefficients
The uniformity coefficients of the irrigation system determined in the evaluations were all higher than 90% (Table 1), being classified in the literature (Bralts, 1986;Sobenko et al., 2020) as excellent. The average flow rate measured in the drippers was 1.03 L/h and coincided with the value declared by the manufacturer for the established pressure.

Crop performance
Lettuce varieties were harvested after 42 days of the production cycle ( Figure 4) and some phytotechnical variables were determined (Table 2).
According to Lima (2007) and Geisenhoff et al. (2016), the recommended minimum fresh mass is approximately 200 g. This value was surpassed by the two varieties at the harvest time.

Soil water matric potential and irrigation opportunity
Soil water matric potential with the plant development, drainage, increase in leaf area, and atmospheric demand decreased over time after being close to the field capacity at the beginning of the cycle. According to Coelho & Teixeira (2004), a mercurycolumn tensiometer would characterize a decrease in the matric potential during the morning due to a temporary decrease of moisture in the root zone caused by the atmospheric demand and a higher temperature and expansion of mercury. The readings of matric potential from tensiometers used in this study had an inverse behavior, reaching a maximum value close to 12 pm ( Figure 5). The conception of tensiometers with a column of water and air inside, which varies the flow (exchange) of water with the soil by the capsule, has its reading also impacted by an increase in temperature in the morning. In summary, the soil water matric potential, measured by the tensiometers used in this study, was affected in the first instance by solar irradiation. Figures 5, 6, and 7 show that the profiles of the daily variation in soil water matric potential and air and soil temperature are very similar to the daily variation of solar irradiation. In other words, the increase in solar irradiation at the beginning of the day induces the corresponding increase in air and soil temperatures and the consequent contribution to the variation of the soil water matric potential. Kansara et al. (2015) also reported disturbances in sensors caused by temperature variation from data acquisitions performed every 10 minutes, thus allowing studying the variation of all monitored variables.
Engenharia Agrícola, Jaboticabal, v.41, n.3, p.338-346, may/jun. 2021   The values of matric potential (Figure 8) at the two monitored depths (10 and 25 cm) increased due to irrigation after transplanting the lettuce seedlings (August 6, 2020). We observed in this study that matric potential increased in the mornings ( Figure 5) until around 12 pm, but the values decreased again in the afternoons due to a decrease in solar irradiance. All irrigation opportunities occurred in the late afternoons. According to Marouelli (2008), the time to start irrigation for horticultural crops (in this case, lettuce) would be when the matric potential was lower than −20 kPa for the shallower tensiometer. On the other hand, the author suggests that the time to finish irrigation would correspond to the field capacity, with values higher than −12 kPa in the tensiometer installed at the highest depth. The data acquisition system detected the first opportunity for irrigation on August 14, 2020, when the matric potential at 10 cm was lower than −20 kPa, with irrigation being automatically started and providing a water depth application of 19.3 mm. The system ceased irrigation when the matric potential at a depth of 25 cm became higher than −12 kPa, de-energizing the solenoid valve.
A period of three days of rainfall was observed between the first and second irrigation opportunities, which allowed the matric potential to remain high and with few variations (Figure 8).

CONCLUSIONS
In this study, a data acquisition system was designed and built to collect data from sensors in real-time and send them to an Internet of Things platform, the ThingSpeak, via wireless cellular communication (GPRS) for later viewing and sharing, using a computer or smartphone.
According to the programmed algorithm, the action of activating a solenoid valve was also performed. This system (platform) is flexible and can be configured according to other specific needs, such as activating a motor pump.
The developed system, employing low-cost opensource hardware and software, efficiently monitored and controlled the lettuce bed irrigation system throughout a production cycle.
Disturbances were observed during the day in the readings of the soil water matric potential. However, the disturbances only increased the readings of matric potential, with no risks of triggering the irrigation system wrongly.
The use of the system enables to save water and reduce labor with irrigation, with a reduction in financial costs and better use of time by the irrigator to be able to be used in the phytotechnical management of the crop.
The cost of assembling the platform, including solar board, data acquisition board (PCB), wires, metal box for electrical circuits, connections, lead-acid battery, lithium-ion battery, charge controller, microcontroller, four pressure sensor tensiometers, circuit breakers, current, voltage, and power sensors, direct current voltage converter, and lithium-ion battery charger, was of approximately US$ 400.00 (using the labor of the authors).