# An IoT-Based Solution for Intelligent Farming +
## 3 IoT-Based Stack Architecture for Intelligent Farming Solutions
### WSM and M2M Components  
The WSN is composed of mobile nodes for animal monitoring and fixed nodes for farming sensing, for instance, temperature sensors, weather forecast stations, humidity sensors and light sensors. Animal sensors (e.g., neck inclination, distance to ground) are implemented on a collar coupled to the animals' neck. Besides monitoring and condition the animals' behaviour locally, the sensed data is reported to the network through a radio transceiver. Further details on collar's operation and design are given in [74]. The fixed nodes, dubbed beacons, besides implementing the needed farming monitoring sensors (adjustable accordingly to the specific needs of the farm), act as infrastructural networking devices. Consequently, they are responsible for collecting the data sent from sheep sensors and for relaying it through neighboring beacons in order to ensure its delivery to one or more aggregating points (gateways). Additionally, they ensure the network synchronization and their periodic communications are designed to allow the establishment of a RSSI-based localization mechanism [74]. The M2M communications within our WSN are implemented by a protocol stack (illustrated in Figure 4) specifically designed to satisfy the SheepII requirements [22; 24]. Despite having this particular project in mind, the stack design was driven by more general goals, aggregating the traffic requirements of several applications related to farming management and supervision. Our approach follows a four-layer architecture (Physical Layer, MAC Layer, Transportation Layer and Application Layer) since it is the one that enables a straightforward match between the defined requirements and each one of the layers. Below, we outline the layers that compose the stack as well as their purpose. Regarding the Physical Layer, the major constraints are associated to the wine-growing and similar lands, mainly in the Douro's region (Portugal) where the terrain is very rugged, with a set of valleys and irregularities carved in the landscape. Such constraints stopped us from considering existing communication standards with Physical Layers based on higher frequencies (e.g., IEEE 802.11, BLE and some implementations of IEEE 802.15.4 and ZigBee). As, theoretically, lower frequencies (and thus higher wavelengths) present better propagation performance, our Physical Layer is based on radio transceivers operating preferably at the ISM band of 433 MHz. Even so, and due to the popularity of the 868 MHz band, we recently added this option. The MAC Layer was an object of careful design due to its implication on the power consumption and consequent autonomy of networking devices, particularly in the case of mobile nodes (sheep collars). The strategy proposed approaches a Time-Triggered (TT) architecture, which means that relevant tasks and communications are executed following a predetermined scheduling. Hence, this scheduling may be defined aiming at optimizing the entire system's operation. Regarding the wireless communications, considering that most of the communications are periodic in nature and in order to avoid collisions, packets losses and consequent waste of bandwidth and energy consumption with retransmissions, permanent-state communications are TDMA-based. This communication scheme  
Figure 4: Intelligent farming Machine-to-Machine (M2M) Stack. is complemented with CSMA-based sporadic communications, used for events such as device's registration on the network (after a system boot, after a reset or after a long period of non-reporting). To this end, a periodic-based structure is used, on which a sequence of micro-cycles (\(\upmu\)C) form a Macro-Cycle (MC) that is repeated over time. Each type of \(\upmu\)C has a particular purpose and, accordingly to that purpose, a TDMA/CSMA MAC policy. As depicted in Table 2, three types of \(\upmu\)C are currently defined, albeit more can be easily added if required.