# Proposed Fuzzy-NN Algorithm with LoRa Communication Protocol for Clustered Irrigation Systems
## 3 Irrigation Systems Algorithms
### Proposed FITRA Algorithm Supporting the OWS Architecture
Based on the temperature readings an ancillary fuzzy algorithm is used, called Watering Temp Control algorithm (WTC). WTC algorithm uses five input sets (Very Low Temperatures, Low Temperatures, Medium Temperatures, Normal Temperatures and High Temperatures) as shown in Figure 4.  
Figure 4 shows the degree of membership [0, 1] of each fuzzy set over the crisp input temperature values. Based on the degree of membership (DOM) and using linear interpolation for the temperature value measured, the corresponding sets and the degree of membership is calculated. The maximum DOM value criteria are the assignment criteria for a crisp input to the most significant set. The watering decision control inference based on temperature (Watering Temp Control WTC) is performed as presented in Table 2:  
Each one of the \(N\) sensor value inputs is assigned to a specific distance level class. Each class signifies the sensor's distance from the actuator. The classes are the: (i) close to actuator (Close to Controller, \(CC\)); (ii) normal to actuator (Normal to Controller, \(NC\)); and (iii) the far from actuator (Distant from Controller, \(DC\)). The input classification is not so critical for a watering system of uniform pressure. However, for non-uniform pressurized systems it is quite important for the classification to be performed accurately. The classification is performed in a semi-automatic way by setting the distance of each input from the actuator in meters (m). Then the distance is normalized based on Equation (7):  
\[D_{i}=distance_{i}/\sum_{i=1}^{n}(distance_{i}) \tag{7}\]  
The \(distance_{i}\) metric values are measured in meters. If a sensor's distance is the maximum distance in the system and \(D_{i}>0.4\), then that sensor belongs to the far from actuator class (\(DC\)). The Close level Class the sensors belong to those that are in a close proximity of the vane. That is: \(D_{i}\leq 0.1\). In the normal level class all sensors are set to be at a normal level distance from the vane \(0.1<D_{i}\leq 0.4\). The number of sensors that belong to the normal level distance class can also be calculated as the remaining number of sensors: \(\mathrm{N}_{\mathrm{sensors}}^{\mathrm{NC}}=8-\mathrm{N}_{\mathrm{sensors }}^{\mathrm{DC}}-\mathrm{N}_{\mathrm{sensors}}^{\mathrm{CC}}\). In order to present the FITRA algorithm neural network (NN) process in a complete manner, the authors assume that both \(N=8\) sensors are functional and send measurements to the Application Server (AS). The steps described below are the steps performed by the FITRA neural process. The FITRA neural process forward steps are also depicted in Figure 5. The FITRA process includes one hidden layer and perceptions with no bias, where neural weights are calculated: Weight \(a_{i}\) and a P-distance indexed weight value \(p_{i}\). **FITRA NN Step 1:** FITRA synaptic weight values \(\mathrm{a}_{i}\), \(i=1\ldots N\) are calculated using a back-propagation process assisted by a selected watering dataset by the farmer for its satisfying watering results. Prior to \(a_{i}\) calculations and based to actuator distance classification process, all sensors are classified by the system into the three classes (\(CC\), \(NC\), \(DC\)). According to Figure 5, \(U_{1.8}\) are the values of the \(N=8\) sensors and \(a_{L}\), \(a_{N}\) and \(a_{C}\) are the mean \(u\) values of each one of the three classes \(DC\), \(NC\) and \(CC\) accordingly. These values are calculated based on Equations (8) and (9), where \(a_{th}\) is the fuzzy process _Athres_ value:  
\[a_{i} =u_{i}-a_{th}\forall i1.N \tag{8}\] \[\left\{ \begin{array}{l}\overline{a}_{C}=\frac{1}{l}\sum\limits_{ i=1}^{j}a_{i}i\subseteq(CC)\\ \overline{a}_{N}=\frac{1}{k}\sum\limits_{i=1}^{k}a_{i}i\subseteq(NC)\\ \overline{a}_{L}=\frac{1}{l}\sum\limits_{i=1}^{l}a_{i}i\subseteq(DC)\end{array} \right. \tag{9}\]  
The per-sensor \(a_{i}\) measured value classification control process sets \(a_{i}\) values into the following two categories:  
Category 1: \(0.1<\overline{a}>_{C|N|D}\leq|a_{i}|\leq 4\cdot<\overline{a}>_{C|N|D}\).