w r i t e _ a p i = c l i e n t . w r i t e _ a p i ( w r i t e _ o p t i o n s =SYNCHRONOUS)
query_api = client . query_api ( )
tables = query_api . query ( '''
from ( b u c k e t : "IOT_ACIPRESTES " )
   |> r a n g e ( s t a r t : −4d )
   |> f i l t e r ( f n : ( r ) => r [" _measurement "] == " mq t t _ con sum e r " )
   |> f i l t e r ( f n : ( r ) => r [ " _ f i e l d " ] == " u plink_message_decoded_payload_AirTemperature ")
   |> f i l t e r ( f n : ( r ) => r [ " h o s t " ] == " a v a l e n t e 0 1 " )
   |> f i l t e r ( f n : ( r ) => r [ " t o p i c " ] == " v3 / i o t − a c i p r e s t e s @ t t n / d e v i c e s / advid −atmos41 −01/up" or r [" t o p i c " ] == " v3 / i o t − a c i p r e s t e s @ t t n /
             devices / advid−bme680 −01/up" or r [" t o p i c " ] == " v3 / i o t − a c i p r e s t e s @ t t n / d e v i c e s / a d vi d −bme680 −03/up" or r [" t o p i c " ] == " v3 / i o t −
             aciprestes@ttn / devices / advid −bme680 −03/up" or r [" t o p i c " ] == " v3 / i o t − a c i p r e s t e s @ t t n / d e v i c e s / advid −bme680 −04/up" or r [" topic
             " ] == " v3 / i o t − a c i p r e s t e s @ t t n / d e v i c e s / a d vi d −bme680 −05/up" )
   |> a g g r e ga t eWin dow ( e v e r y : 15m, f n : mean , createEmpty : false )
''' )
values = []
time = [ ]
for table in tables :
      #print ( table . records )
      for row in table . records :
         values = np . append ( values , row . v alues [ ' _value ' ] )
         time = np . append ( time , row . v alues [ ' _ time ' ] )
plt . plot ( time , values )
plt . xticks ( rotation = 90)
pl t . show ( )
```
to

access

InfluxDB.

1:

## *3.5. Module Power Consumption*

The power consumption of the four types of modules (BME680, ATMOS41, Plant and Soil) was measured using a Nordic Semiconductor Power Profiler Kit II and is summarized in Table 2, where *current* is the average current consumed by the module (takes into account the different operating times during the 15 min sampling period: 2 s sampling time, 2 s transmission time, 3 s reception time and 893 s sleep), *battery* is the capacity of the lithium-ion battery used in the module and *days* is the number of days the module has been operating without solar charging. The ATMOS 41 module must always be powered to obtain wind gus<sup>t</sup> and precipitation values, even though the microcontroller is in sleep mode.

**Table 2.** Module power consumption.


## **4. Discussion**

The implemented system, in terms of data communication, has been operating without losses. All eight modules have their batteries with voltage values higher than 4 V, which demonstrates that the battery–solar panel set is well-dimensioned for all modules.

Regarding the data collected, it should be noted that there is a difference between the temperature values of the ATMOS41 and the BME680 sensors (Figure 8). This may be due to the difference in shields, because in terms of accuracy, the two systems are nearly identical (±0.6 °C). However, the BME680 sensors use a 3D-printed PLA shield [38] (Figure 15), for which studies indicate that the error in the measurement of air temperature is not greater than 1.5 °C [39]. As in the implemented system, the difference when solar radiation is high is greater (about 4 °C) than when it is low (about 2 °C); more studies will have to be carried out to determine the origin of this difference.

**Figure 15.** Example of the 3D-printed BME680 sensor shield.

In relation to the remaining data, these are within the expected values. It should be noted that during the period presented in this study, there was only one episode of rainfall that can be observed, both in Figure 9 on the precipitation curve, and in Figure 11 on the leaf wetness curve.

A similar and, eventually, more generic study was developed in [40]. On it, a lowcost, modular, Long-Range Wide-Area Network (LoRaWAN)-based IoT platform, called "LoRaWAN-based Smart Farming Modular IoT Architecture" (LoRaFarM) was proposed and aimed to improve the managemen<sup>t</sup> of generic farms in a highly customizable way. The authors stated that the platform, built around a middleware core, is easily extensible with ad-hoc low-level modules (feeding the middleware with data coming from the sensors deployed in the farm) or high-level modules (providing advanced functionalities to the farmer). The proposed platform was evaluated on a farm in Italy, where it collected environmental data (air/soil temperature and humidity) related to the growth of farm products such as grapevines and greenhouse vegetables over a period of three months from July to September 2019. It should be noted that in their work, for soil moisture, air humidity sensors were used in water-resistant casings, which does not give the water content in the soil as is necessary and is provided by the system implemented and presented here. A webbased visualization tool for the collected data is also presented to validate the LoRaFarM architecture. In general, the LoRaFarM platform inherits its topological structure from the LoRaWAN architecture, as low-level communication patterns are built around the LoRaWAN technology. Specifically, data obtained from farm-level modules are collected by LoRaWAN-oriented End Nodes (ENs) and forwarded to a Network Server (NS) by a LoRaWAN Gateway (GW). In their case, the NS was built on The Things Network [31], and the core middleware was developed to retrieve the data collected from the NS to feed high-layer modules (i.e., the Application Server (AS)) and to be available to end users. The results and discussion of the vineyard scenario reported are in concordance with the results we obtained and the discussion presented for the same environmental data. The actual

study goes further, with data collected from plant groups, and it can be extended to other data for which the sensors are already implemented in the modules.

There are other studies that approach obtaining water stress without a wireless sensor network. As an alternative, timely optical remote sensing and non-invasive evaluation of plant water stress based on unmanned aerial vehicles (UAVs) has become common [41]. In this study, remote and proximal sensing measurements were compared with plant physiological variables to test innovative services and support systems to farmers for optimizing irrigation practices and scheduling. The experiment was conducted in two vineyards located in Sardinia, Italy. The indicators of crop water status (crop water stress index and linear thermal index) were calculated from UAV images and ground infrared thermal images and then related to physiological measurements. Remote and proximal sensing images acquired with high-resolution thermal cameras mounted at ground level or on unmanned aerial vehicles (UAV) have spatial resolutions of a few centimetres. They can provide information accurate enough for both assessing plant water status in the field and implementing appropriate irrigation managemen<sup>t</sup> strategies. The crop water stress index (CWSI), a thermally derived indicator of water deficit based on leaf/canopy temperature measurements, has been used to assess the water status of crops in several plants, such as grapevines, French beans, wheat, rice, maize and cotton. Many studies of plant water stress have analysed the relationships between air temperature, remote sensing indices, and physiological parameters such as stomatal conductance (Gs) and stem water potential (SWP). However, any image acquisition is costly, even when using low-cost UAV solutions. The technique applied in this study built on the use of the CWSI, which has been tested in several studies using ground and satellite data. The use of CWSI maps gives the main advantage of managing irrigation at a large scale by considering the spatial variability of vine water status and developing an approach for providing precision irrigation recommendations.

Another study was based on low-resolution thermal infrared imaging [42]. The goal of this work was to demonstrate the capability of VineScout, a ground robot designed to assess and map vineyard water status using thermal infrared radiometry. Trials were carried out in Douro Superior (Portugal) under different irrigation treatments during the 2019 and 2020 seasons. Grapevines were non-invasively monitored at different times of the day using leaf water potential as reference indicators of plant water status. Grapevine canopy temperatures, recorded with an infrared radiometer, as well as environmental data acquired with a multispectral sensor were saved on the robot controller's computer. The authors state that the promising outcomes gathered with VineScout using different sensors based on thermography, multispectral imaging and environmental data disclose the need for further studies considering new variables related to plant water status, and more grapevine cultivars, seasons and locations to improve the accuracy, robustness and reliability of the predictive models in the context of precision and sustainable viticulture. Leaf water potential was used as a reference indicator of the plant water status (ground truth), and its measurement was taken simultaneously with vineyard monitoring by the robot by a Schölander pressure bomb. One of the main advantages of the VineScout approach to assess plant water status is that vineyard water status variability can be mapped, expanding the concept and application of precision viticulture—in this case, precision irrigation or variable-rate irrigation to optimize water usage and efficiency. The data collected were extracted by pen drive after the map was completed.

These approaches have some advantages, but for a region such as the Demarcated Region of the Douro, with vineyards on steep slopes and a quite heterogeneous environment where conditions on one level may be very different from those on a neighbouring level, they are not the most suitable. Approaches based on wireless sensor networks are the most suitable for this region, and due to the poor GSM network coverage, LoRaWAN technology is the most suitable.

This work shows that through the combination of different technologies, it is possible, even in remote areas, to monitor atmospheric, plant and soil status remotely and in real

time, overcoming the challenges of traditional methods (Schölander method) used for water status determination.

## **5. Conclusions**

Regarding climate change, the effects of high temperatures and water scarcity are increasingly significant across the globe. For the success of agriculture, especially for vineyards, the assessment of plants' water status is essential in order to act in a timely and conscientious manner towards efficient managemen<sup>t</sup> of the culture and water resources. In this sense, this study leads to lower cost and a more effective way of continuously monitoring crop water status remotely and in real time, overcoming the challenges of the Schölander method. This is particularly important in regions where access to parcels and their managemen<sup>t</sup> is difficult. Furthermore, installation of the LoRaWAN module adds value due to its reduced costs and superior range compared to WiFi or Bluetooth, which is especially valuable for applications in remote areas where cellular networks have little coverage. Altogether, this will support producers in efficient managemen<sup>t</sup> of their farms, allowing increased quality while contributing to environmental and economic sustainability.

The developed system aims to monitor water stress of the vineyard; however, it allows for other parameters. Water stress arises as the relation between several biotic and abiotic factors. Following that, it is necessary to understand water flux in the atmosphere, plant and soil, as considered in the development of this sensor network.

The system was implemented in a Douro vineyard (Quinta dos Aciprestes) that shares the connection problems of remote areas. Through the implementation of a wireless transmission system based on LoRaWAN protocol (class A) and an online platform (Grafana) for data observation, the system has been operating without communication losses. The installed batteries present the correct voltage, demonstrating that the battery–solar panel set is well-dimensioned for all modules. Regarding the data collected, it should be noted that there is a difference between the temperature values between the 'ATMOSPHERE' group sensors, and more studies will have to be carried out to determine the origin of this difference. In relation to the remaining data, they are within the expected values.

As future work, all system data, together with data collected on-site with a Schölander camera and meteorological data, will eventually become training data to feed a machine learning system. This will allow more accurate estimation of the water stress of the vineyard and can be the base of an information-support decision system with one or more systems such as smart harvest, smart irrigation, etc.

**Author Contributions:** Funding acquisition, S.S.; investigation, A.V.; methodology, A.V. and C.C.; hardware, A.V. and J.L.; software A.V. and J.L.; supervision, B.S., L.P., J.L. and S.S; visualization, A.V.; writing—original draft preparation, A.V., C.C., L.P. and B.S.; writing—review and editing, A.V., C.C., L.P., B.S. and L.P. All authors have read and agreed to the published version of the manuscript.

**Funding:** This work was financed by National Funds through the Portuguese funding agency, FCT—Fundação para a CiênciaeaTecnologia, within project UIDB/50014/2020.

**Institutional Review Board Statement:** Not applicable.

**Data Availability Statement:** The data presented in this study are available on request from the corresponding author. The data are not publicly available as it are private data of Quinta dos Aciprestes.

**Acknowledgments:** Special thanks to ADVID (Association for the Development of Viticulture in the Douro Region) for supporting this work through CoLAB VINES&WINES, and to Real Companhia Velha (RCV), for allowing the development of this project in Quinta dos Aciprestes, and to all the staff who supported the implementation of the trial in the vineyards. Rui Soares and Vitória Rodrigues (RCV) are also acknowledged, as well as Nelson Machado (CoLAB VINES&WINES), and Igor Gonçalves and Luís Marcos, from the Technical Services Department of ADVID, which supported the development of this work.

**Conflicts of Interest:** The authors declare no conflict of interest.
