LoRa-LBO: An Experimental Analysis of LoRa Link Budget Optimization in Custom Build IoT Test Bed for Agriculture 4.0

: The Internet of Things (IoT) is transforming all applications into real-time monitoring systems. Due to the advancement in sensor technology and communication protocols, the implementation of the IoT is occurring rapidly. In agriculture, the IoT is encouraging implementation of real-time monitoring of crop ﬁelds from any remote location. However, there are several agricultural challenges regarding low power use and long-range transmission for effective implementation of the IoT. These challenges are overcome by integrating a long-range (LoRa) communication modem with customized, low-power hardware for transmitting agricultural ﬁeld data to a cloud server. In this study, we implemented a custom-based sensor node, gateway, and handheld device for real-time transmission of agricultural data to a cloud server. Moreover, we calibrated certain LoRa ﬁeld parameters, such as link budget, spreading factor, and receiver sensitivity, to extract the correlation of these parameters on a custom-built LoRa testbed in MATLAB. An energy harvesting mechanism is also presented in this article for analyzing the lifetime of the sensor node. Furthermore, this article addresses the signiﬁcance and distinct kinds of localization algorithms. Based on the MATLAB simulation, we conclude that hybrid range-based localization algorithms are more reliable and scalable for deployment in the agricultural ﬁeld. Finally, a real-time experiment was conducted to analyze the performance of custom sensor nodes, gateway, and handheld devices. The results indicate that a change in antenna height from 1 to 7 m leads to signiﬁcant changes in the coverage area.


Introduction
According to a United Nations report [1], the world population will reach 9.8 billion in 2050, representing a 25% increase over the current population. Additionally, the pattern of urbanization is anticipated to grow at a rapid pace, with approximately 70% of the world s population expected to be residing in urban areas by 2050 [2]. As a result, the amount of food production will be required to double by 2050 [3]. The size of the area of the Earth's surface remaining for agricultural usage is limited due to climate, temperature, soil quality, and topography [4]. Additionally, compared to past decades, the total utilization of agriculture for food production has declined. Thus, agriculture transformed into a means of living that was considerably more sustainable and able to generate food surpluses than hunting and gathering alone. Subsequently, agriculture has become an integral part of human life [5,6], and many advancements have since taken place in agriculture in terms of crops, fertilizers, pesticides, etc. Agriculture has become a means of survival and a key component of national economies. Hence, it can be said that the agricultural development a.
An overview of LoRa and distinct localization algorithms, namely range-free and range-based, is provided in this article. b.
The customization of sensor nodes and the gateway was designed and implemented for monitoring agriculture. c.
LoRa and Wi-Fi communication for agriculture is also proposed. d.
Implementation of a localization algorithm for agriculture is presented, and we conclude that hybrid range-based localization algorithms are more reliable, scalable, and easy to deploy in the field. e.
The energy harvesting mechanism for the sensor nodes is presented, and was evaluated using the Cisco packet tracer. f.
To characterize the behavior of LoRa, we undertook a simulation using MATLAB. g.
A real-time experiment was performed using the customized sensor node and gateway. The sensor node was able to communicate with the cloud server through the LoRa-based gateway.
This paper is organized as follows: Section 2 provides the theoretical background with technical specifications of wireless communication protocols. Section 3 presents an overview of LoRa and localization algorithms. Section 4 discusses the customization of the sensor node and gateway, and the LoRa and Wi-Fi communication-enabled architecture for agriculture. Section 5 outlines the simulation of localization, energy harvesting, and MAT-LAB simulation. Section 6 describes the real-time experimental setup and discusses the results.

Theoretical Background
The Internet of Things (IoT) is a pioneering technology that provides an efficient and accurate automation solution for modernizing agriculture with minimal human interference [13]. The advancement of sensor technology, wireless communication technologies, and remote sensing technologies encourages precision agriculture (PA). In the attempt to enhance the yield and quality of crops, wireless transmission is necessary to transfer data to information processing centers. Wireless communication empowers the effective utilization Agronomy 2021, 11, 820 3 of 24 of limited resources in agriculture, thereby allowing the development of agriculture in terms of reliable connectivity [14]. Generally, most agricultural fields are located in remote areas, where internet connectivity is unstable. To overcome these limitations, the implementation of a wireless sensor network (WSN) is required. In a WSN, open-licensed band communication protocols are embedded in the sensor node and the communication protocol for transmitting the agricultural field data to an area in which the internet connectivity is sufficiently strong to allow communication with the cloud server [15].
In [16], IoT-and WSN-based agriculture systems based on a CC3200 single chip for monitoring the humidity and temperature of the crop field were implemented. Additionally, a camera module was integrated with a CC3200 single chip to capture visuals and communicate a multimedia message (MMS) to a farmer. The WSN-based smart agriculture system was implemented by utilizing the Zigbee network and communicating the crops' status to farmers and a cloud server [17,18]. A Wi-Fi, GSM, and WEMOS D1 controller-based agriculture monitoring system has been implemented for monitoring the parameters of crops, such as pH, soil moisture, soil type, and weather conditions, and communicate these to a cloud server [19]. A low-cost information-based system was implemented for agriculture using 2G GSM and orang-pi [20]. In the agriculture scenario, wireless communication protocols such as ZigBee, Wi-Fi, and GPRS have been implemented for transmitting data to processing centers. Sensor-based data acquisition has been achieved using Bluetooth, ZigBee, and cloud servers. Because sensor nodes are energy-constrained devices, the implementation of GPRS and Wi-Fi communication protocols is challenging because they consume large quantities of power, as shown in Table 1. Because its communication is characterized by low power consumption, ZigBee is also implemented in agriculture. However, its transmission range is limited. Of the above-mentioned communication options, LoRa is a reliable and feasible communication technology used in agriculture to implement the effective WSN-based IoT. To implement the WSN, LoRa communication is chosen because it can transmit data to an Internet-connected area [21]. LoRa communication has been integrated into agriculture to capture and communicate real-time images of farms [22].
A wireless sensor network includes small, low-energy consumption sensor nodes for various applications. The task of localization is to determine the physical coordinates of the sensors. Because each application has specific requirements, several localization algorithms are used. WSN localization plays a significant role in the agriculture IoT. Tiny and cheap devices with low energy consumption and limited computing resources are being heavily used in agriculture applications. To deploy sensor nodes in fields, localization algorithms, such as time on arrival (TOA), time difference of arrival (TDOA), and received signal strength indication (RSSI), are required to estimate the number of sensor nodes and their position in a particular field [23]. A statistical method has been implemented to identify the non-line of sight (NLOS) nodes in the WSN network [24,25]. A combination of range-based, range-free-based, and hybrid-based localizations can be emphasized. A combination of range-based and range-free algorithms has been studied concerning the sensor node distance, density, and reliability. As discussed earlier, selecting accurate wireless communication is critical for overcoming the problems of power consumption and transmission range. A study of various communication techniques is tabulated below according to frequency band, network size, network topology, etc. Table 1 discusses three emerging LPWAN technologies, namely LoRa, narrow band-IoT (NB-IoT), and SigFox, regarding the requirements of the IoT for a wide range of applications. Of these LPWAN technologies, LoRa is considered to be an independent network and can utilize the frequency bands without any cost [27]. NB-IoT is a licensed band, and is also a dependent network that charges for the use of the bands. The Sigfox network is deployed by network operators, and users are subscription-based. LoRa is one of the best candidates for long distance and low power transmissions [28].

LoRa and Localization Algorithms
In this section, we provide an overview of LoRa and the localization algorithms of the WSN. In the Section 1, LoRa and its fundamental parameters are discussed. In the Section 2, the significance of localization and distinct types of localization algorithms are discussed.

Overview of LoRa
LoRa is a form of robust low-power wireless networking that is used for long-distance communication. LoRa utilizes chirp spread spectrum (CSS) modulation to modulate the Industrial, Scientific and Medical (ISM) bands [29]. Modulation of the chirp spread spectrum broadcasts a narrow band signal over broader channel bandwidth. LoRa operates on ISM bands such as 868 MHz in Europe, 995 MHz in North America, and 433 MHz in Asia [30]. LoRa can communicate over distances of between 10 and 40 km in rural areas, and urban area coverage is between 1 and 5 km. The LoRa protocol specification was developed by the LoRa Alliance, as shown in Figure 1. The LoRaWAN protocol comprises the MAC Layer and the Application Layer, and operates based on the LoRa physical layer. LoRaWAN is a network standard for telecom operators founded on the LoRa physical layer (PHY). It enables network services and encourages systems to transfer data to gateways wirelessly over a long range. LoRaWAN communicates between LoRa gateways and IoT devices via a star-network topology, and single hopping is allowed between a gateway and a LoRa device. ways wirelessly over a long range. LoRaWAN communicates between LoRa gateways and IoT devices via a star-network topology, and single hopping is allowed between a gateway and a LoRa device.
The analysis of LoRa communication in distinct applications can be undertaken based on the parameters of spreading factor (SF), link budget, signal-noise ratio (SNR), bandwidth (BW), link budget, receiver sensitivity, bit error rate (BER), and packet error rate (PER).

Spreading Factor
The initial frequency of the chirp is recognized as a symbol. The encoded bits in a symbol are configured by a unique parameter known as the spreading factor (SF). This indicates that a chirp with the spreading factor SF represents 2 SF bits per symbol, which implies that one symbol is described by multiple chips that are spread spectrum code pulses. SF is expressed as:

Signal-to-Noise Ratio (SNR)
SNR is the ratio of transmitted signal powers to the unwanted signal i.e., noise power. It is preferred that the SNR is minimized to ensure that demodulation at the receiver end is straightforward and the signal can be decoded correctly. To enhance LoRa performance, it uses forward error correction (FEC) techniques and the spreading factor, thus allowing significant SNR improvements. In particular, the SNR range is between −20 and +10 dB. The received signal is less distorted if the range is around +10 dB. LoRa has an SNR range of −7.5 to −20 dB. The analysis of LoRa communication in distinct applications can be undertaken based on the parameters of spreading factor (SF), link budget, signal-noise ratio (SNR), bandwidth (BW), link budget, receiver sensitivity, bit error rate (BER), and packet error rate (PER).

Spreading Factor
The initial frequency of the chirp is recognized as a symbol. The encoded bits in a symbol are configured by a unique parameter known as the spreading factor (SF). This indicates that a chirp with the spreading factor SF represents 2 SF bits per symbol, which implies that one symbol is described by multiple chips that are spread spectrum code pulses. SF is expressed as:

Signal-To-Noise Ratio (SNR)
SNR is the ratio of transmitted signal powers to the unwanted signal i.e., noise power. It is preferred that the SNR is minimized to ensure that demodulation at the receiver end is straightforward and the signal can be decoded correctly. To enhance LoRa performance, it uses forward error correction (FEC) techniques and the spreading factor, thus allowing significant SNR improvements. In particular, the SNR range is between −20 and +10 dB. The received signal is less distorted if the range is around +10 dB. LoRa has an SNR range of −7.5 to −20 dB.

Link Budget
The link budget cab be determined from transmitted power and node sensitivity, and is expressed as:

Sensitivity (S)
Sensitivity is defined as the ability of the receiver to amplify the weak signals that are obtained by the receiver. In LoRa, the spreading factor, noise figure, and bandwidth Agronomy 2021, 11, 820 6 of 24 are considered to be inputs for providing the sensitivity as output. Sensitivity (S) is calculated as: where BW is the band width of the channel, NF is the noise figure gain in dB, and SNR is the signal to noise ratio power in dB. Bit Rate/data rate is defined as the rate at which bits are transferred from one location to another. The bit rate (R bit ) of LoRa is expressed as:

Bit Error Rate (BER)
BER is the percentage of bits that have errors compared to the cumulative number of bits received in a transmission. BER is represented as 10 −4 . If BER is 10 −4 , then it indicates that 10,000 bits have been transferred, and one bit has an error. A higher BER indicates that network performance is poor.

Packet Error Rate (PER)
PER is the total number of received packets divided by the number of error packets after forward error correction (FEC). A packet is a data unit used in a radio transmission that is subject to FEC.

Localization Algorithm
Localization is crucial for identifying the physical locations of sensors in the deployment area. Concerning the deployment land in agriculture, it is important to identify the required number of sensor nodes and the distances at which they need to be positioned so that sensor nodes can establish communication links among themselves. Here, we discuss localization algorithms to determine a suitable node architecture for farm land. Various parameters are evaluated using these algorithms, such as accuracy, reliability, and scalability. Localization algorithms are broadly classified into two types, namely, range-based and range-free-based, as shown in Figure 2 [23]. Moreover, these two types are classified into two kinds, namely, fully range-based and hybrid range-based.

(a) Range-free localization algorithms
These algorithms determine the location of an unknown deployed sensor node [9]. Range-free methods utilize radio connectivity to communicate between nodes to identify their location. In range-free schemes, the angle of arrival (AOA), specific hardware, and distance measurement is not considered [31]. Range-free schemes comprise the centroid system, distance vector (DV) hop, approximate point in triangulation (APIT), and hop terrain, described as follows: In DV hop, the distance between the nodes is estimated using hop count, and the hop count of at least three anchor nodes is distributed across the network [32]. The hop count of a node is incremented by one when the neighbor node (a) Range-free localization algorithms These algorithms determine the location of an unknown deployed sensor node [9]. Range-free methods utilize radio connectivity to communicate between nodes to identify their location. In range-free schemes, the angle of arrival (AOA), specific hardware, and distance measurement is not considered [31]. Range-free schemes comprise the centroid system, distance vector (DV) hop, approximate point in triangulation (APIT), and hop terrain, described as follows: In DV hop, the distance between the nodes is estimated using hop count, and the hop count of at least three anchor nodes is distributed across the network [32]. The hop count of a node is incremented by one when the neighbor node transmits the information to another neighbor node. The hop distance is evaluated as the distance between two nodes/number of hops. • Centroid localization: This is the most basic scheme that uses anchor beacons, containing location information (X i , Y i ) [31], where n is the number of the anchor nodes Ai.
• APIT: In APIT, the location information is obtained by anchor nodes through a global positioning system (GPS) and the unlocalized node receives the location information via overlapped triangles [33]. • Gradient: In the gradient algorithm, the unlocalized node utilizes the multilateration method to estimate the position of nodes. Moreover, it utilizes hop counting and the hop increment while being distributed to neighboring nodes.

(b) Range-based localization algorithms
Range-based localization is based on angle estimation and distance estimation. The main techniques in this form of localization are time of arrival (ToA), angle of arrival (AoA), time difference of arrival (TDoA), and received signal strength indication (RSSI):

•
ToA localization: This localization algorithm refers to the time of arrival, i.e., ToA, which refers to the time taken for the signal to travel from the sending node to the receiving node [34]. The distance is measured using roundtrip-time of flight (RTOF) to determine the distance between two nodes and is represented in Equation (6) as: Sensor coordinates (x 1 ,y 1 ), (x 2 ,y 2 ), (x 3 ,y 3 ), and (x 4 ,y 4 ) determined using the response information and the TOA-based distance measurement method can be used to obtain the distances between them and the moving node S as d 1 ,d 2 ,d 3 , and d 4 , respectively. Given the coordinates of the moving node S, (x, y), the following equation can be used to calculate the location coordinates of the moving node: where i = 1, 2, 3, 4.
• AODV localization: AODV is the routing protocol based on the distance-vector algorithm, which integrates the target serial number of DSDV and the on-demand routing discovery in DSR [35]. This protocol mainly includes routing discovery and routing maintenance, where the former is only requested to save the overdue routing. • AOA: The location of an unlocalized node is estimated through the angles at the points at which the anchor signals are obtained [36,37]. Here the unlocalized nodes implement a triangulation procedure for estimating the location. • RSSI: In this method, the estimation of the distance between receiver and transmitter is obtained by evaluating the signal strength at the receiver [38,39]. The power of the signal decreases when the distance between receiver and transmitter decreases.
A comparative analysis of fully range-based and hybrid range-based algorithms is shown in Table 2. Fully range-based algorithms are used to determine the distances or angles between nodes to allow an unknown node to be identified easily, whereas hybrid range-based algorithms use various distance and angle measuring methods. Different parameters, such as node density, range, scalability, and reliability of algorithms, are shown in Table 2. These exploit geometry to improve hybrid AOA/TDOA-based localization (EATL). Fusion of RSSI and TDOA measurements from the wireless sensor network provides robust and accurate indoor localization (FRTL). Hybrid range-based algorithms perform better than fully range-based algorithms. Table 2 shows that hybrid range-based algorithms perform better in range combinations using TOA, TDOA, and RSSI. Scalability and accuracy of the fully range-based algorithms are comparatively lower than those of hybrid range-based algorithms. Table 2. Localization algorithms (range free vs. hybrid range-based) [40].

Parameters
Fully To design a reliable and scalable sensor network architecture for smart monitoring, we proposed an architecture in which data nodes are deployed on agricultural land and agricultural field node localization is used to establish proper sensor coordination. For the deployment of data nodes to establish suitable communication among sensors, i.e., temperature, humidity, rainfall, altitude, pressure, and fire sensors in open-field lands, hybrid range-based localization techniques are preferred. Data nodes transfer information to the gateway and from the gateway to the cloud platform. A data logger was designed in which all of the sensor data can be stored. For the storage of data, both the local server and cloud server are preferred. The user on a remote device can visualize the data. From remote devices, via the Internet a farmer or any user can operate motors, sprinklers, and blowers connected to farming land.

Hardware
The sensors are interfaced and powered from the solar panel. All data is gathered at the sink node and is transmitted to the destination via a gateway. The hardware can be operated on a rechargeable Li-Ion 2200 mAH battery. Figure 3 consists of sensor modules, ADC, LoRa modem, and a LoRa helical antenna. The device can be deployed to collect sensor data from the field and transmit it via the Internet to the receiver device through the gateway, which is a customized ATMEGA 328 p board with an inbuilt Wi-Fi module and it is shown in the Figure 4. the sink node and is transmitted to the destination via a gateway. The hardware can be operated on a rechargeable Li-Ion 2200 mAH battery. Figure 3 consists of sensor modules, ADC, LoRa modem, and a LoRa helical antenna. The device can be deployed to collect sensor data from the field and transmit it via the Internet to the receiver device through the gateway, which is a customized ATMEGA 328 p board with an inbuilt Wi-Fi module and it is shown in the Figure 4.    The block diagram ( Figure 2) is a depiction of the components used in the entire project. The connections were made so that the main component Raspberry Pi board is connected to the Arduino Uno board through the standard pyfirmata. The remainder of the sensors are connected with both the Arduino and Raspberry Pi models. The digital sensors are attached to the Raspberry Pi, and the analog sensors are connected to the Arduino Uno board. The sensors gather data in real-time. All of the outputs are stored on the Thingspeak server/Blynk on the cloud, and can be accessed at any point in time.
A circuit diagram of a reference model of the interface connections made in real time is shown in Figure 5. Firstly, the Arduino is connected to the Raspberry Pi using a USB cable. The gas sensor is connected to the Arduino at the analog A0 pin. The ultrasonic sensor is connected to pin no. 9 of the Arduino for trigger, and echo at pin no. 10. DHT11 is connected to pin 2 of the Arduino. Soil moisture is connected to analog pin A3 of the Arduino. The motor pump is connected to pin no. 8 of the Arduino. The block diagram ( Figure 2) is a depiction of the components used in the entire project. The connections were made so that the main component Raspberry Pi board is connected to the Arduino Uno board through the standard pyfirmata. The remainder of the sensors are connected with both the Arduino and Raspberry Pi models. The digital sensors are attached to the Raspberry Pi, and the analog sensors are connected to the Arduino Uno board. The sensors gather data in real-time. All of the outputs are stored on the Thingspeak server/Blynk on the cloud, and can be accessed at any point in time.
A circuit diagram of a reference model of the interface connections made in real time is shown in Figure 5. Firstly, the Arduino is connected to the Raspberry Pi using a USB cable. The gas sensor is connected to the Arduino at the analog A0 pin. The ultrasonic sensor is connected to pin no. 9 of the Arduino for trigger, and echo at pin no. 10. DHT11 is connected to pin 2 of the Arduino. Soil moisture is connected to analog pin A3 of the Arduino. The motor pump is connected to pin no. 8 of the Arduino. is shown in Figure 5. Firstly, the Arduino is connected to the Raspberry Pi using a U cable. The gas sensor is connected to the Arduino at the analog A0 pin. The ultraso sensor is connected to pin no. 9 of the Arduino for trigger, and echo at pin no. 10. DHT is connected to pin 2 of the Arduino. Soil moisture is connected to analog pin A3 of Arduino. The motor pump is connected to pin no. 8 of the Arduino.

Proposed LoRa Architecture
A cloud-based agriculture field-monitoring scheme was implemented to precisely monitor the temperature, humidity, and other required parameters to operate end devices in an agriculture field. This scheme facilitates the conservation of water and energy in a field.
Here, an open agriculture field was studied. Figure 6 shows the architecture of the LoRa network. The proposed protocol can be adapted to a greenhouse, hydroponic agriculture, and vertical farming. Devices provide numerous data on agriculture parameters from the field, and analysis of the data allows the farmer to work more effectively. A LoRa-enabled sensor network was deployed in the agriculture field. A LoRa-enabled architecture for precise irrigation and monitoring has been demonstrated in which LoRa enabled each sensor node and could establish a communication link with another LoRa-enabled receiver. LoRa is a low-power operating technique that enables transmission and reception with a wide range of communication. Although many other protocols exist, they have significant limitations compared to LoRa. enabled sensor network was deployed in the agriculture field. A LoRa-enabled architecture for precise irrigation and monitoring has been demonstrated in which LoRa enabled each sensor node and could establish a communication link with another LoRa-enabled receiver. LoRa is a low-power operating technique that enables transmission and reception with a wide range of communication. Although many other protocols exist, they have significant limitations compared to LoRa.

Localized Algorithm Simulation
A flow diagram of the sensor node localization is illustrated in Figure 7. Initially, the type of node distribution is chosen as per the application, which may be uniform or random. Furthermore, node density is determined to check the number of nodes present in the area (measured in square meters). The algorithm computes these input data and results in sensor node distribution patterns. After confirming the communication link among the sensor nodes, a hybrid range-based localization technique was chosen because it is more effective. Localization is crucial to determine the sensor node target tracking location. Here, we first grouped the algorithms into free range-based and hybrid rangebased. Furthermore, we analyzed the suitable localization techniques. Range free-based localization is preferred because of its low power consumption, whereas hybrid rangebased localization is preferred depending on the applications. Because the land is not uniform in nature, hybrid range-based localization is widely preferred in agriculture. Most IoT-based applications require sensor node localization because these applications are easy and convenient to monitor. Simulation studies were carried out to compute the localization of algorithms. The effect of the node density, data rate, and signal strength was

Localized Algorithm Simulation
A flow diagram of the sensor node localization is illustrated in Figure 7. Initially, the type of node distribution is chosen as per the application, which may be uniform or random. Furthermore, node density is determined to check the number of nodes present in the area (measured in square meters). The algorithm computes these input data and results in sensor node distribution patterns. After confirming the communication link among the sensor nodes, a hybrid range-based localization technique was chosen because it is more effective. Localization is crucial to determine the sensor node target tracking location. Here, we first grouped the algorithms into free range-based and hybrid rangebased. Furthermore, we analyzed the suitable localization techniques. Range free-based localization is preferred because of its low power consumption, whereas hybrid rangebased localization is preferred depending on the applications. Because the land is not uniform in nature, hybrid range-based localization is widely preferred in agriculture. Most IoT-based applications require sensor node localization because these applications are easy and convenient to monitor. Simulation studies were carried out to compute the localization of algorithms. The effect of the node density, data rate, and signal strength was analyzed to develop the optimal algorithm for our application. Furthermore, we undertook a comparative analysis of the range-based agriculture applications, and concluded that range free-based localization was more suitable. analyzed to develop the optimal algorithm for our application. Furthermore, we undertook a comparative analysis of the range-based agriculture applications, and concluded that range free-based localization was more suitable.

Simulation of Energy Harvesting
In agriculture, sensor nodes are deployed in an outdoor environment. Moreover, the sensor node′s battery life represents a challenge because the life of the battery drains due to distinct environmental conditions. Thus, the optimal solution for implementing energy harvesting for sensor nodes involves renewable energy sources. Energy harvesting is the optimal mechanism used to power the activities of the sensor nodes, including sensing, preprocessing, and transferring data. The evaluation of sensor node battery life using solar panels and wind turbines was performed using a Cisco packet tracer. The Cisco packet tracer is a visualized-based simulation tool that encourages the user to implement distinct network-based simulations. The simulation model for evaluating the sensor node′s energy through solar panels and wind turbine was implemented in the Cisco packet tracer environment and is shown in Figure 8.

Simulation of Energy Harvesting
In agriculture, sensor nodes are deployed in an outdoor environment. Moreover, the sensor node s battery life represents a challenge because the life of the battery drains due to distinct environmental conditions. Thus, the optimal solution for implementing energy harvesting for sensor nodes involves renewable energy sources. Energy harvesting is the optimal mechanism used to power the activities of the sensor nodes, including sensing, preprocessing, and transferring data. The evaluation of sensor node battery life using solar panels and wind turbines was performed using a Cisco packet tracer. The Cisco packet tracer is a visualized-based simulation tool that encourages the user to implement distinct network-based simulations. The simulation model for evaluating the sensor node s energy through solar panels and wind turbine was implemented in the Cisco packet tracer environment and is shown in Figure 8. devices connected to the network. Each renewable resource is connected using a power meter for calculating the power consumption. Timestamp details of the IoT devices are represented in the time column; the IoT 2 device is connected to the network with a time of 0.129 s. Devices IoT0 and IoT1 are currently connected within 1.011 s. Total device connection time is 77.660 s with a specific time gap or delay. Further power is transferred to the battery for storage purposes. A sample scenario of power of 11 kWh in the case of a turbine and 78 watts with 82 Wh was considered.  The establishment of LoRa-based communication from the sensor node to the mobile phone is presented in Figure 10. The simulation model shown in Figure 8 signifies the The lifetime of the nodes is presented in the simulation, as shown in Figure 10. Data transmission occurs from end nodes to the hub, the hub to a central server, and from mobile phones via cell towers. The simulation panel in Figure 9 presents the number of IoT devices connected to the network. Each renewable resource is connected using a power meter for calculating the power consumption. The lifetime of the nodes is presented in the simulation, as shown in Figure 10. Data transmission occurs from end nodes to the hub, the hub to a central server, and from mobile phones via cell towers. The simulation panel in Figure 9 presents the number of IoT devices connected to the network. Each renewable resource is connected using a power meter for calculating the power consumption. Timestamp details of the IoT devices are represented in the time column; the IoT 2 device is connected to the network with a time of 0.129 s. Devices IoT0 and IoT1 are currently connected within 1.011 s. Total device connection time is 77.660 s with a specific time gap or delay. Further power is transferred to the battery for storage purposes. A sample scenario of power of 11 kWh in the case of a turbine and 78 watts with 82 Wh was considered.  The establishment of LoRa-based communication from the sensor node to the mobile phone is presented in Figure 10. The simulation model shown in Figure 8 signifies the The establishment of LoRa-based communication from the sensor node to the mobile phone is presented in Figure 10. The simulation model shown in Figure 8 signifies the Agronomy 2021, 11, 820 14 of 24 communication link established among sensor end nodes and establishes a connection with the gateway to transmit the data to the central server. In the simulation panel, the data transmission time in seconds, from the router to the hub and the hub to smartphones, is displayed. The simulation signifies the on-air data transmission. Three events are noted as having a time of 218.952 s. Each of the three devices, i.e., wireless router, central office, and another wireless router, connected to the network at the same timestamp. This signifies, in LoRa communication, that the device synchronization time gap is extremely small, which is an additional advantage. As soon as the authentication key matches, the devices are synchronized and begin communicating. communication link established among sensor end nodes and establishes a connection with the gateway to transmit the data to the central server. In the simulation panel, the data transmission time in seconds, from the router to the hub and the hub to smartphones, is displayed. The simulation signifies the on-air data transmission. Three events are noted as having a time of 218.952 s. Each of the three devices, i.e., wireless router, central office, and another wireless router, connected to the network at the same timestamp. This signifies, in LoRa communication, that the device synchronization time gap is extremely small, which is an additional advantage. As soon as the authentication key matches, the devices are synchronized and begin communicating.

MATLAB Simulation
The MATLAB simulation platform was considered in this study for characterizing the behavior of the LoRaWAN network. A simulation model was developed in MATLAB for evaluating the effects of various parameters, such as SNR, bitrate, and SF. A sample LoRa testbed was developed on the MATLAB simulation platform. The simulation was implemented by considering the following features: a network with 10 to 100 nodes, one gateway, and one network server. The nodes were distributed both randomly and uniformly with a minimum period of 100 s. SF, transmission power, and gateway transmission power were defined as per the protocol. The SNR value was determined from the simulation result. We classified the simulation into cases as follows: Case I: LoRa trades the transmission and reception data rate for sensitivity within a given channel bandwidth. As shown in Table 3, LoRa implements an adaptive data rate by the utilization of orthogonal SFs. This allows the user to minimize the power consumption and optimize the network performance for a given bandwidth. The receiver maintains the mode of operation downlink, gate power at 27 dB, node sensitivity at −124 dB, operating frequency at 868 MHz, antenna gain at 10 dB, and node noise and node antenna gain at 30 dB. After performing the simulation, the obtained results are presented in Table 4. The results indicate that a change in antenna height from 1 to 7 m leads to significant changes in the coverage area.

MATLAB Simulation
The MATLAB simulation platform was considered in this study for characterizing the behavior of the LoRaWAN network. A simulation model was developed in MATLAB for evaluating the effects of various parameters, such as SNR, bitrate, and SF. A sample LoRa testbed was developed on the MATLAB simulation platform. The simulation was implemented by considering the following features: a network with 10 to 100 nodes, one gateway, and one network server. The nodes were distributed both randomly and uniformly with a minimum period of 100 s. SF, transmission power, and gateway transmission power were defined as per the protocol. The SNR value was determined from the simulation result. We classified the simulation into cases as follows: Case I: LoRa trades the transmission and reception data rate for sensitivity within a given channel bandwidth. As shown in Table 3, LoRa implements an adaptive data rate by the utilization of orthogonal SFs. This allows the user to minimize the power consumption and optimize the network performance for a given bandwidth. The receiver maintains the mode of operation downlink, gate power at 27 dB, node sensitivity at −124 dB, operating frequency at 868 MHz, antenna gain at 10 dB, and node noise and node antenna gain at 30 dB. After performing the simulation, the obtained results are presented in Table 4.
The results indicate that a change in antenna height from 1 to 7 m leads to significant changes in the coverage area. For the parameters, such as frequency of 868 MHz, node sensitivity of −124 dBm, gateway node power of 10 dB, and antenna gain of 27 dB, a relationship between the height of gateway and node with range is plotted in Figure 11.  For the parameters, such as frequency of 868 MHz, node sensitivity of −124 gateway node power of 10 dB, and antenna gain of 27 dB, a relationship betwe height of gateway and node with range is plotted in Figure 11. The experimental data shown in Table 5 provides a brief overview of the corr between the height of the gateway, the height of end nodes, and the range. Durin reception at the receiver, the data were interpreted; the table′s model signifies the link. The graph concludes that a constant link budget of 159 dBm range is directly p tional to the height of the end node and gateway. Thus, to achieve greater range cov it is considered that the end nodes should be mounted on cylindrical bars, as sho Figure 11.
Case II Figure 11. Gateway height versus range in meters.
The experimental data shown in Table 5 provides a brief overview of the correlation between the height of the gateway, the height of end nodes, and the range. During data reception at the receiver, the data were interpreted; the table s model signifies the downlink. The graph concludes that a constant link budget of 159 dBm range is directly proportional to the height of the end node and gateway. Thus, to achieve greater range coverage, it is considered that the end nodes should be mounted on cylindrical bars, as shown in Figure 11. Case II The establishment of the LoRa communication link significantly depends on the gateway height and the end node heights. Experimental data are presented in Table 5.
Here the node sensitivity is −124 dBm and the operating frequency is 868 MHz, and it can be observed that the signal coverage area changes in addition to the variation in heights of the gateway and end nodes. The end node height is 2 m from the ground. If the gateway height is adjusted from 1 to 5 m, the coverage area and signal strength change drastically change from 1319 to 2946 m. This signifies that maintaining all of the parameters at a certain value will enhance the link budget strength increases because there is less interference.
Case III: In this case, the following parameters were considered: node sensitivity at −137 dBm and operating frequency at 433 MHz. Now, changing the value of the gateway height significantly impacts the range. Maintained a link budget of 151 dBm, it is observed that SNR decreases because there is a low possibility of interference. The mode of operation during the experiment is downlink, i.e., data received at the receiver side. During the experiment, it was observed that at a fixed node sensitivity of −137 dBm and antenna gain of 10 dB, the custom-built sensor node varies the value of the link budget (in dB) with a change in the wide-area range coverage at a frequency of 433 MHz. This is shown in Table 6 and Figure 10. In Figure 12, a relationship between antenna gain, link budget, and range is plotted. The blue line graph shows increasing antenna gain increases the range, whereas the red line shows increasing the range in response to the link budget in LoRa. By maintaining all of the parameter values, antenna height is directly proportional to the coverage range. This signifies that deploying the LoRa receiver at a certain height can enable a strong communication link.  Case IV: Transmission signal strength is optimized by setting the antenna gain from 1 to 25 dB. Here, the transmission range and link budget of the LoRa transmitter module were evaluated with a change in antenna gain. The mode of operation is uplink, as presented in Table 7. Antenna gain was changed by writing the MATLAB code for interpreting the signal strength at a frequency of 433 MHz. When gateway noise remains at 10 dB and node sensitivity at −137 dBm, the link budget increases from 141 to 166 dBm. Hence, it is concluded that by changing antenna gain, we can improve the coverage area. Thus, it is preferred to use an antenna with high gain. Experimental parameters are presented in Table 8, and signify the importance of node sensitivity. We used a helical antenna in the design of the custom sensor node and gateway. Maintaining the uplink frequency at 433 MHz, by changing node sensitivity from −124 to −130 dBm, the sensor coverage distance increased from 945 to 3986 m. The data from Table 8 indicates that the change in node sensitivity is directly proportional to the range.  Case IV: Transmission signal strength is optimized by setting the antenna gain from 1 to 25 dB. Here, the transmission range and link budget of the LoRa transmitter module were evaluated with a change in antenna gain. The mode of operation is uplink, as presented in Table 7. Antenna gain was changed by writing the MATLAB code for interpreting the signal strength at a frequency of 433 MHz. When gateway noise remains at 10 dB and node sensitivity at −137 dBm, the link budget increases from 141 to 166 dBm. Hence, it is concluded that by changing antenna gain, we can improve the coverage area. Thus, it is preferred to use an antenna with high gain. Experimental parameters are presented in Table 8, and signify the importance of node sensitivity. We used a helical antenna in the design of the custom sensor node and gateway. Maintaining the uplink frequency at 433 MHz, by changing node sensitivity from −124 to −130 dBm, the sensor coverage distance increased from 945 to 3986 m. The data from Table 8 indicates that the change in node sensitivity is directly proportional to the range.
As the height of the gateway and sensor node changes, the range also varies. The variation in both gateway and end node height changes the range significantly during downlink mode at the receiver. In Figure 13, the red triangles denote the data rate, and black downward triangles signify the bit rate. Figure 14a,b shows the relation of bit error rate, packet error rate, and symbol error rate with the spreading factor. As the spreading rate increases, there is an increase in the bit error rate. When the spreading factor is changed from 7 to 12, the bit error is minimized at SF = 6. Thus, there is a loss of data packets. It is preferred to send the data with the spreading factor so that bit error and packet error rate are minimized. To conclude, it is preferred to minimize the SF value to reduce the bit rate error. To maintain minimal collision among data packets, a lower value SF is preferred.
After computing all of the essential communication parameters of LoRa, it was found that increasing SNR affects the PER, SER, and BER. At −30 dB of SNR, BER is almost 1, which is not considered. It was also observed that with a decrease in the value of SNR to 0 dB, the error rate decreases. As the height of the gateway and sensor node changes, the range also varies. The variation in both gateway and end node height changes the range significantly during downlink mode at the receiver. In Figure 13, the red triangles denote the data rate, and black downward triangles signify the bit rate.  Figure 14a,b shows the relation of bit error rate, packet error rate, and symbol error rate with the spreading factor. As the spreading rate increases, there is an increase in the bit error rate. When the spreading factor is changed from 7 to 12, the bit error is minimized at SF = 6. Thus, there is a loss of data packets. It is preferred to send the data with the spreading factor so that bit error and packet error rate are minimized. To conclude, it is preferred to minimize the SF value to reduce the bit rate error. To maintain minimal collision among data packets, a lower value SF is preferred. To calculate the data rate of LoRa, the input parameters such as CR, SF and BW are included in the equation. Figure 15 presents the data rate of LoRa from SF 7 to SF 12. The data rate is denoted in terms of bits per second (bps). In each SF, the data rate increases at BW 7, then increases exponentially after BW 8, and reaches a limit at BW 10. We can observe that SF 7 has an inverse effect on the data rate, because the data rate steadily decreases from SF 7 to SF 12. In SF 7, the data rate of the LoRa reached 22,000 bps, and in SF 12, the data rate was limited to 2000 bps. An increase in SF will lead to transmission of a low amount of data; thus, SF 7 is the optimal SF that needs to be considered for sending a large amount of data. After computing all of the essential communication parameters of LoRa, it was found that increasing SNR affects the PER, SER, and BER. At −30 dB of SNR, BER is almost 1, which is not considered. It was also observed that with a decrease in the value of SNR to 0 dB, the error rate decreases.
To calculate the data rate of LoRa, the input parameters such as CR, SF and BW are included in the equation. Figure 15 presents the data rate of LoRa from SF 7 to SF 12. The data rate is denoted in terms of bits per second (bps). In each SF, the data rate increases at BW 7, then increases exponentially after BW 8, and reaches a limit at BW 10. We can observe that SF 7 has an inverse effect on the data rate, because the data rate steadily decreases from SF 7 to SF 12. In SF 7, the data rate of the LoRa reached 22,000 bps, and in SF 12, the data rate was limited to 2000 bps. An increase in SF will lead to transmission of a low amount of data; thus, SF 7 is the optimal SF that needs to be considered for sending a large amount of data.

Results of the Experimental Setup
This section discusses the deployment of sensor nodes and the gateway in a real-time environment. We also present the sensor data recorded on the cloud server and compare previous studies with the proposed research in detail. To evaluate the coverage of LoRa, we deployed the sensor nodes in a testbed located in our university center. The gateway was placed at a distance of 1 km from the sensor nodes. To analyze the customized sensor

Results of the Experimental Setup
This section discusses the deployment of sensor nodes and the gateway in a real-time environment. We also present the sensor data recorded on the cloud server and compare previous studies with the proposed research in detail. To evaluate the coverage of LoRa, we deployed the sensor nodes in a testbed located in our university center. The gateway was placed at a distance of 1 km from the sensor nodes. To analyze the customized sensor node and gateway for crop field monitoring, the sensor node was deployed in the crop field, as shown in Figure 16a,b. The sensor node was embedded with sensors for temperature, humidity, soil moisture, and fire. A 433 MHz-based LoRa was embedded in the sensor node and gateway. LoRa is a form of transceiver communication. The LoRa-based gateway was positioned 1 km from the two sensor nodes. The gateway showed effective results in terms of accurately receiving the sensory data. The gateway was also embedded with an 8266 Wi-Fi modem to communicate the data over the cloud server through the Internet. The sensory data is visible in Figure 16c.
Agronomy 2021, 11, x FOR PEER REVIEW 21 Moreover, a hand-held device (or portable device) was also designed implemented in real-time scenarios, shown in Figure 16d. This hand-held devic assist farmers in checking the field from a remote location and is easy to use. A held device integrates LoRa communication and an ESP 8266 Wi-Fi module. Thes communication modules assist in receiving the crop data regarding from the sensor and gateway. The hand-held device is used to visualize the data of the crop field color LCD. The hand-held device shows the sensory data, including temper humidity, soil moisture, and fire detection. The gateway node logs the data on the server through the Internet. Here, we used the Blynk cloud server to record the se data of the sensor node. The data regarding temperature and humidity can be seen Blynk dashboard, and is presented in Figure 17.  Moreover, a hand-held device (or portable device) was also designed and implemented in real-time scenarios, shown in Figure 16d. This hand-held device will assist farmers in checking the field from a remote location and is easy to use. A hand-held device integrates LoRa communication and an ESP 8266 Wi-Fi module. These two communication modules assist in receiving the crop data regarding from the sensor node and gateway. The handheld device is used to visualize the data of the crop field on a color LCD. The hand-held device shows the sensory data, including temperature, humidity, soil moisture, and fire detection. The gateway node logs the data on the cloud server through the Internet. Here, we used the Blynk cloud server to record the sensory data of the sensor node. The data regarding temperature and humidity can be seen in the Blynk dashboard, and is presented in Figure 17.
Agronomy 2021, 11, x FOR PEER REVIEW A comparative analysis of previous research on LoRa link budgets is ble 9. Evaluation parameters are the microcontroller unit (MCU), the comm tocol used, customized hardware designed for the sensor node, the gatewa cepts, and simulation-based analysis used to validate the proposed study study has the advantages of a communication protocol that uses both Lo This means the data can be collected on a local platform and the cloud p designing sensor nodes, each sensor node and gateway were custom desi as per the requirements. Customization helped us to reduce the dimension ture of the device. A simulation-based analysis was carried out to validat study, and further validated on the LoRa testbed.   A comparative analysis of previous research on LoRa link budgets is depicted in Table 9. Evaluation parameters are the microcontroller unit (MCU), the communication protocol used, customized hardware designed for the sensor node, the gateway, proof of concepts, and simulation-based analysis used to validate the proposed study. The proposed study has the advantages of a communication protocol that uses both LoRa and Wi-Fi. This means the data can be collected on a local platform and the cloud platform. When designing sensor nodes, each sensor node and gateway were custom designed and built as per the requirements. Customization helped us to reduce the dimensions and architecture of the device. A simulation-based analysis was carried out to validate the proposed study, and further validated on the LoRa testbed.

Conclusions
IoT is transforming all applications due to its unique feature of real-time monitoring. In agriculture, IoT can enhance crop yields by integrating distance sensors and wireless communication protocols. In agriculture, implementing internet-based sensor nodes is challenging due to the unavailability of nearby agriculture fields. To overcome this, we proposed an IoT-based WSN architecture for real-time monitoring of agricultural fields. A custom sensor node and gateway were developed and implemented for sensing and communicating real-time agricultural data. In agriculture, the sensor node s battery life plays a significant role. We implemented an energy harvesting mechanism using solar energy and a wind turbine. A MATLAB simulation was performed to evaluate the correlation of distinct parameters, such as link budget, spreading factor, and receiver sensitivity, in a custom-built LoRa testbed. Moreover, this article discusses the role of localization for deploying the sensor nodes in agricultural fields. The MATLAB simulation indicated that hybrid range-based localization algorithms are more reliable and are scalable for deployment in agricultural fields. Finally, a real-time experiment was performed to analyze the performance of the custom sensor node and gateway.

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