# Proposed Fuzzy-NN Algorithm with LoRa Communication Protocol for Clustered Irrigation Systems
## 3 Irrigation Systems Algorithms
### FITRA Communication Protocol
The RH_RF95 LoRaRadioHead physical header is shown in Figure 6b and includes the following fields:  
* [noitemsep,topsep=0 pt,parsep=0 pt]
* Preamble consisted of 1 octet for synchronization purposes. * LoRa concentrator destination address (1 octet), which is the address of the LoRa gateway device. The number of 0 xFF, while 0x00 is the network broadcast address. Since the address fields are 1 octet long there is a limitation of 253 devices under single LoRa radio channel concentrator control. For the three default channels of the 433 MHz band there can be used up to three gateways and a total of 759 devices. * Source address (1 octet). Figure 6: (a) LoRaWAN communication protocol packet structure for class A transmission over LoRa 868 MHz network [37]; (b) FITRA communication protocol packet structure for transmission over LoRa radio 433 MHz network; (c) FITRA concentrator communication protocol ACK packet structure for transmission over LoRa 433 MHz network. * Message ID (1 octet), used in order to differentiate different messages derived from LoRa devices. The Message ID field is set to 0x00 for the FITRA protocol implementation and the message differentiation was moved to the application layer FITRA protocol. * Flags (1 octet). Flags include one ACK bit, which indicates whether it is a normal or an acknowledgment frame, then there are 3 reserved bits for future use and the last 4 bits have the value of 0x08 that indicate that the payload that follows is part of the FITRA application protocol. * Frame CRC field (2 octet). On top of the physical header the authors implemented the FITRA application protocol as shown in Figure 6b. The FITRA Application protocol includes the following fields:  
1. **Application ID field** uniquely identifies all FITRA actuator controllers, controlled by a single-channel gateway. The purpose of the Application ID is to differentiate among controllers that are controlled by different gateways placed on the same agricultural area of interest. Gateways only respond to messages received from actuators with the same application ID. Application ID can also be characterized as network ID, giving the system the capability of maintaining up to 256 gateways on the same channel. 2. **Value ID** is a 1 octet field that uniquely identifies each actuator controller, controlled by a gateway. With reserved values of 0x00 and 0 xFF this identifier limits that number of actuators per gateway to 253 (a limit set by the physical layer RadioHead library. See source and destination address Figure 6a). 3. **Sequence number** is a 16-bit value, incremented by the actuator controller upon successful reception of an ACK FITRA frame. The initial sequence number is randomly generated. 4. **Valve status field** indicates the current valve status. A status value of 0x00 means that the actuator is at the \"off\" position and a value of 0x01 that the actuator is at the \"on\" position. A value above 0x01 indicates a partly open valve. Then the value corresponds to the rotation degrees that the valve is open (if the actuator is a servo actuator value then the rotation degree angle increases 0.7\({}^{\circ}\)/value) or the steps that the valve is open (if the actuator is a stepper one--up to 253 steps/180\({}^{\circ}\) rotation angles). 0 xFF value indicates an erroneous valve status. 5. **Sensors LEN field** indicates the number of sensor values included in the frame payload. It also indicates weather the sensor is in a disabled state. For example, a value of b00110101 indicates that the payload shall include 4 sensor values for sensors 1, 3, 5 and 6. The other sensors are in a disabled state either due to erroneous readings or non-existent ones. 6. **Sensor value vector field** is a variable-length field, whose length is determined by Sensors LEN field. In this vector the sensor values are placed and for each 10-bit sensor value a 2 octet value field is used. 7. **Monitor day field** is used to indicate the actuator's monitoring day.