LoRa Based Sensor and Actuator Networks in Smart Livestock Farming Applications

— Fast growth of farming activities in Vietnam requires employment of new technologies in data acquisition, control, and communication to make them operate more efficiently. In livestock farming applications, environmental condition monitoring and control are essential to maintain good comfort for the animal, reduce the farmworker’s workload, and minimize the risk of disease spread. In this work, a wireless sensor and actuator system based on LoRa protocol is developed to deploy in hog farms. The ambient temperature and air quality information is acquired and processed. The data is then utilized for automated control of the cooling fans to comfort the animal in the barns. Besides, long term data collection can be also used to understand the system comprehensively and thus facilitate the farm owner to enhance the farming operation subsequently. A graphical user interface is also provided for the operator to supervise the system and intervene if necessary. Experimental results are provided to demonstrate the performance of the whole system


I. INTRODUCTION NDUSTRIAL automation in developing countries such as
Vietnam is accelerating rapidly.Its agriculture, once the main contributor to the economy, still plays a crucial role.However, the natural resources have become expensive, and the aggressive urbanization results in the decrement of farmland.Modernization of the agriculture is a must in order to optimize the limited resources and maximize the profit.Recent advanced technologies in communication and computation enable new trend of smart farming applications.A number of Wireless Sensor and Actuator Networks (WSANs) have been developed for the last decade and shown a great potential in agriculture as stated in [1][2][3].Wireless Sensor Networks (WSNs) consists of a number of nodes which can be deployed easily in various types of environment and cooperate well with each other to perceive required information [2,4].Actuators equipped with wireless communication modules and integrated in the WSNs make them WSANs in order to adjust the environmental conditions as desired.An example of ZigBee based WSANs is presented in for heating and cooling loads in buildings [5].The areas of interest in agriculture applications are usually much larger than office buildings or residential building systems.Authors in [6] developed a WSAN system to manage the cattle on the open I field.In close area such as greenhouses or livestock buildings, environmental quality monitoring and control are essential to provide healthy living space for the plant or animal [7].
Our work focuses on developing LoRa based WSANs to manage indoor conditions in livestock farming applications.LoRa is a low power wide area wireless network protocol which is often used in large scale applications.Cost effectiveness, long range and low energy consumption features of LoRa make it one of the most suitable candidates for smart city or smart farm applications [8][9][10][11].When being compared to other popular wireless protocols such as ZigBee, Bluetooth, and WiFi, the main advantages of LoRa are the lowest power consumption and the longest communication range [9].Although, a tradeoff is its low data rate, it is still sufficient for the slow process applications like farming systems.In these applications, parameters such as temperature, carbon dioxide (CO2) concentration, etc., which have great influence on the farming animal habitat [12], should be observed and managed carefully.The developed system would help to perceive the CO2 concentration and temperature values, and adjust the ventilation system when it is required, thus realizing low-cost automation.
The structure of this paper is as following: Section 1 introduced the background of this work, the overall system and requirements are provided in Section 2, Section 3 presents the system design and development, Section 4 provides the experiment results and discussion, and the paper is concluded in Section 5.

II. SYSTEMS DESCRIPTIONS
Overall system architecture is illustrated in Fig. 1.The WSAN is organized in sub networks.Each sub system consisting of several LoRa based sensor and actuator nodes is deployed in a barn.There are two types of nodes: a local control node which is unique in a barn and sensor nodes.Sensor nodes are equipped with sensing module to acquired environmental information.The local control node acts as a coordinator to collect the data from sensor nodes within the same barn, processes, and forwards to the central server.The local control node is also connected to a variable frequency drive (VFD) for controlling the ventilation fans.These fans help to pump fresh air into the barn as well as to cool down the indoor temperature during hot days.In some farms where the biogas is available for heating, the fans can also help to bring hot air inside the barn in winter faster.A supervisory software is employed at the control center to look over and provide the initial settings of the whole system.

III. SMART FARM MORNITORING AND CONTROL SYSTEM
A. LoRa based hardware platforms Sensor Node Hardware.The sensor nodes are equipped with a PIC microcontroller as a processing unit, a MHZ-16 sensors which can measure ambient temperature and CO 2 concentration.It also includes a real-time clock (RTC) unit and a LoRa module for sending data to the local control nodes.Fig. 2a shows the schematic of a sensor nodes without the CO 2 sensor which is connected to the UART pins via a short cable.
Local Control Node Hardware.Similar to the sensor nodes, the local control node also contains a RTC unit, a PIC microcontroller and a LoRa module.Besides, this node is equipped with a LCD and buttons for getting user inputs locally and displaying the measurement on demand.An EEPROM is integrated to store the operation settings.The local control node is able to change fan speed set point by setting via 4 I/O digital pins.The mainboard schematic of this node is shown in Fig. 2b and has the options of being equipped with a LCD interface and buttons placed on its casing.

B. Supervisory and actuation schemes
Local Control Node Information perceives by all the sensor nodes in the same barn is aggregated at the local controller and only the average values are forwarded to control center so that the traffic load in the network is reduced.In order to avoid packet collision within the sub network, a communication scheme similar to time division multiple access (TDMA) is adopted.Initially, local control node broadcasts a message to perform time synchronization amongst the nodes and set value of the RTC.The sensor nodes are also allocated time slots to send data to the local control node.Operation settings of the sub network can be provided by users locally via LCD and buttons on the local control node or sent from the control center software.Based on this input information and the measurements from the sensor node, the local control node makes decision on how the ventilation fans should be controlled.
Control Center Software.The software includes a graphical user interface (GUI) and a MySQL database which stores all the historical data.The GUI is designed and developed with PyQT5 to supervise the whole system.It enables the user to monitor the farm parameters as well as to input settings remotely at the management room in real-time.Initially, the settings of the desire conditions in the farm such as range of temperature or CO 2 concentration are sent from control center room.The settings are then recorded in local control node's EEPROM.In case the system is restarted and no input from the control center is provided, those store values in EEPROM will be used.All the system information as well as acquired data are recorded in the MySQL database with a schema consisting the barn information, the settings and the collected measurements as shown in Fig. 4. simplified control scheme is adopted to regulate the fan speed.The fan speed is calculated as the following: From ( 1) and ( 2), we get: The final fan speed value is computed as: The calculated value is then set to the VFD to adjust the fans via 4 digital input pins.This setting mechanism allow 16 levels of the speed from 0 to 15 with respected to 0% to 100% full speed linearly.The closest level to the calculated value is selected as VFD set point.If both 2 measured CO and measured T are lower than the 2 min CO and min T , fans are turned off.On the other hand, if any measurement is greater than the highest threshold, fan speed is set at full speed.

IV. SYSTEM OPERATION AND EXPERIMENTAL RESULTS
The system in this work is designed for but not limited to a farm of 9 hog barns with different area as shown in Fig. 5.The average dimension of each barn is 50m×18m.A management room is located around 150-200m away from the furthest barn.There are 4 or 6 ventilation fans with rated power is around 0.8-1.2kWinstalled in each barn.An energy efficient long range low cost LoRa based wireless sensor and actuator network is presented for the application of smartly managing indoor conditions in livestock farming application.Temperature and carbon dioxide measurement data are continuously collected and displayed at the control center room.These real-time data are used to compute the required variation in the fan speed setting in a farm with multiple barns, so as to pump fresh air into the barn as well as to cool down the indoors to improve comfort of the livestock.Our practical results from deployment show that the systems are able to facilitate the farm operation reliably and efficiently.Future work includes enhancements to customize the control scheme using the livestock information such as quantity, age or weight of the livestock in each barn.Internet of Things (IoT) edge computing and blockchain technologies [13,14] can also be explored and integrated.Thus, they can provide holistic solutions for modernization of livestock applications.

Fig 1 .
Fig 1. LoRa based sensor and actuator system in hog barns

Fig 2 .
Fig 2. Schematic of (a) sensor node and (b) the local control node The designed system mainly consists of 3 main components: Sensor Node, Local Control Node and Control Center.These components connect wirelessly to each other, transmit data via the Lora wireless communication protocol.Each cage consists of multi sensor circuits collects data from sensors through the RS485 communication standard and send it to the Local Control Circuits located in the cage.The local control circuits process the data and send control signals to the drive to control fan speed.In addition, the Local Control also has the function to send the collected parameters to the Control Center.Control Center can be a

Fig 3 .
Fig 3. Hardware platform of (a) sensor node and (b) the local control nodeKey components of the two nodes are listed in Table1.The high energy consuming components are the PIC microcontroller, MHZ-16 sensor modules and the LCD at the local control node.In the deployment area, the nodes are supplied by main power via AC/DC converters, thus energy is not yet a concern.However, to reduce energy consumption, especially when main power is hard to reach at some location inside the barn and nodes are supplied by batteries, the LCD is kept turned off most of the time and is energized only if a user touches the buttons on the local control node.Similarly, other components are put in sleep or

Fig 4 .
Fig 4. Database scheme diagram Actuation Scheme.The system is constantly monitored and controlled remotely to ensure the proper living environment for animals.Key operation settings include threshold of parameters such as maximum and minimum feasible fan speed, max SP and min SP ; maximum and minimum temperature, max T and min T ; maximum and minimum CO2 concentration 2 max CO and 2 min CO .A

Fig 5 .
Fig 5.The livestock farm layout At testing phase, a sub network of 2-5 nodes is deployed in each barn.Each node is set to perceive measurement values and send to the local control node every minute in sequence.The local control node then gathers the information, process and forward the average values to the control center in the next one minute.The GUI displays are illustrated in Fig 6. and Fig. 7. Various parameters of the system are shown in Fig. 6 include real-time measurements of average temperature and CO2 concentration in each barn as well as extra information of the livestock in the barn like the quantity, average age and weight.Historical data of the CO2 and temperature can be extracted from the database and displayed as shown in Fig. 7 together with the operation settings.

Fig 6 .
Fig 6.Main screen of the GUI

Fig 8 .Fig 9 .
Fig 8. Average temperature and CO2 measurements aggregated by the local control node

TABLE I .
MAIN COMPONENTS OF THE HARDWARE PLATFORMS )