Low-cost IoT-based System to Monitor Cows’ Behavior

Low-cost IoT-based System to Monitor Cows’ Behavior

Published: 2019.11.22
Accepted: 2019.11.22
234
Electronics and Telecommunication Faculty, University of Engineering and Technology, Vietnam
Institute of Information Technology, Vietnamese Academy of Science and Technology, Vietnam
Faculty of Electrical and Electronic Engineering, Phenikaa University

ABSTRACT

Cow farming is very popular in Vietnam. In fact, 95% of dairy cows in the country have been scattered raised in small barns. Thanks to the application of modern techniques, the management of barns gets easier and easier. Cow monitoring is necessary to help farmers take a comprehensive view of the cow’s health and estrus time. However, the issue is there is not enough time to manually supervise the cattle. Therefore, this paper aims to build a low-cost device which can detect the status of cows. The sensing component of this device is made up of three axis acceleration sensors ADXL345. The acceleration data are used to classify four kinds of activities: lying, standing, feeding, and walking. A simple and effective decision tree algorithm is developed for the classification. Furthermore, we can extend to identify some of cattle health events like lameness and estrus cycle.

Keywords: Acceleration, behavior, sensors, classification

INTRODUCTION

Generally, demand for clean beef and cow's milk in the world and in Vietnam in particular is increasing. To meet this demand, dairy farming requires a high technique and large investments. However, farmers encounter a lot of difficulties because of small, scattered breeding, unskilled, full households and using traditional breeding methods. This is the main reason why the costs of production is high. Therefore, dairy breeding needs to apply modern technology in the world to improve productivity and product quality. Aware of the importance of this issue, some of milk processing companies in Vietnam have implemented advanced technologies such as TH true milk applying Israel’s technology (AFIMILK). With the advantages of being small in size and lightweight, accelerometers have been widely used to monitor cow behavior. Nevertheless, the interpretation of the data collected by such sensors when characterizing the type of behavior still brings major challenges for developers, related to the complexity of activities (i.e., certain behaviors contain similar gestures).

In the study of Schwager Mac, et al. 2007, the authors measured the pitch angle of the neck of the animal and categorized their behavior in active (grazing or looking for the grass) and inactive modes (lying down or ruminating). In 2019, the authors used accelerometers to classify four behavioral modes of cows. Methods recently proposed for automatic behavior classification in animals are mainly based on different machine learning algorithms such as decision-trees (Phung Cong Phi K., et al., 2019), k-means (Bidder, Owen R., et al., 2014), HMMs (Langrock, Roland, et al., 2012), and SVM (Hoang, Q.T., et al., 2018). In this study, we develop a decision-tree (DT) that uses tri-axial accelerometer data from the cow’s neck and leg. The cow monitoring systems collect and analyze sampled data on each cow, to forecast some activities in a long time. It will provide farmers the necessary information to recognize health problems, diseases, and the estrus status of the cows. In the study of Gray, H.G., et al., 1984, the heat detection is used to monitor the active level of cows. If the cows get excited, their activity levels will increase and if the cows are sick or lame, the activity will be significantly reduced. In our research, we would like to extend the DT algorithm to detect the walking and estrus status, which is also a typical  activity of cows. Thus, our DT algorithm can detect four states of cow behavior: lying, standing, feeding, and walking. Furthermore, we can extend this work to identify some of cattle health events like lameness and estrus cycle.

In this paper, we choose the decision tree algorithm to classify behavioral state of cows because we can embed the classification process in the device (we do not need to send the acceleration data to the server). Moreover, it also offers other advantages such as automatic feature selection, little data prep effort, handles data non-linearity, and is easy to interpret. We consider four important activities of cows: standing, lying, feeding and walking.

MONITORING AND CLASSIFICATION USING THREE-DIMENSIONAL ACCELEROMETERS

Figure 1 shows a block diagram of the analyzing system. We use this device to receive the acceleration data, extract two features and run behavioral classification in real-time manner.

Accelerometer ADXL345

The ADXL345 is a 3-DOF acceleration sensor with a selectable measurement range of ±2 g, ±4 g, ±8 g, or ±16 g with g = 9.81 m/s2. This sensor is used to measure both dynamic and static accelerations. Figure 2 shows a photo of ADXL345 sensor.

IoT based device

The UNO is a microcontroller board which integrates ATmega328P. Figure 3 shows the photos of the device before packaging. The sensor is connected to the microcontroller through an I2C interface.

EMBEDDED ALGORITHM

Machine learning provides an effective solution to categorize the data sets. Decision Tree (DT) is a non-parametric supervised learning method which is used for classification. First, we extract the features from the raw or pre-processing data. Secondly, we create a model which can predict the output value of a target variable using learning decision. DT works well with large datasets, and it can handle both categorical and numerical data. There are many kinds of DT algorithms such as ROC, ID3, C4.5, CART, and CHAID. In this study, we use ROC to define three thresholds for our classification (Khanh, P.C.P., 2018). The DT algorithm is used in order to detect four cow activities (standing, lying, feeding, and feeding). In our work, we also extend this work to detect the estrus status, which is also a typical activity of cows. Thus, we proposed to use the algorithm flow chart as shown in Figure 4. First, the raw acceleration data from the neck is pre-processed by a moving average for smoothing. The feature characteristics are then estimated to detect if the cow is on high or low activity. In our research, the high activity consists of the feeding and walking activities. The estrus status is detected if the excessed steps are determined threshold for a period of time. The low activity consists of standing and lying activities, which is determined by SCAY (i.e. static component of the acceleration in the y-axis) and the vector of the dynamic body acceleration (VeDBA).

To classify data, we can use two thresholds corresponding to VeDBA and SCAY in the DT algorithm. In our research, we will use three thresholds corresponding to VeDBA, SCAY, and the vector of the dynamic body acceleration obtained from the device attached to the cow’s leg (V_leg). Based on the counting of the number of steps in a given period of time, we can also detect the estrus status. Furthermore, using V_leg will improve distinguishing between the standing and lying states.

We also used an accelerometer ADXL345 for step counting. This sensor is attached to the cow’s leg. Using acceleration data from this sensor can not only detect the estrus state of the cows, but also distinguish between their feeding and walking activities. Figure 5 illustrates a walking activity which consisted of 8 steps. A step is confirmed if there is an acceleration curve crosses below the dynamic threshold.

RESULTS AND DISCUSSIONS

Figure 6 illustrates a cow which wears two devices on the leg and the neck. The activities of cows are also monitored by cameras (see Figure 7). The information from cameras is used to evaluate the system’s performance.

Figure 8 shows the raw acceleration data from our experiment. It can be seen that in low dynamic activities (i.e. standing and lying), the variation of acceleration components is small. In the high dynamic activity (i.e. feeding), these variations are obvious. 

Figure 9 shows the estimation of SCAY and VeDBA derived from our corresponding acceleration data. These estimated data are needed for the DT (see Figure 4).

As shown in Figure 4, the characteristic VeDBA is compared to a threshold (threshold_A) in order to determine if the cow is in a high activity or low dynamic one. After that, the characteristic SCAY is compared to another threshold (threshold_B) in order to determine if the cow is standing or lying. These thresholds can be chosen by using ROC curve. In our experiment, threshold_A and threshold_B are chosen at 0.065 g and -0.372 g, respectively. These parameters are used in the program which is embedded into the microcontroller for real-time classification. The system’s performance of our system is shown in the Table 1.

In order to highlight this work, Figure 9 shows the estimation of VeDBA (on the neck) and the vector of the dynamic body acceleration obtained from the cow’s leg (V_leg). It can be seen that using VeDBA cannot distinguish the walking activity from feeding one. However, it is very easy to use V_leg to separate the two activities by setting a threshold (threshold_C) of 0.3 g (see Figure 9).

CONCLUSION

Our work has shown that accelerometers can be used to recognize some important behavior pattern in cows as: lying, standing, feeding, and walking. The step counting function is also tested successfully. The simple DT classification algorithm was useful in the classification of measured behavior pattern. The classification can run in the microcontroller, we do not need to send the acceleration data to the server. Thus, it is a low-cost solution which can be applied to small livestock farms.

REFERENCES

Schwager, M., Anderson, D. M., Butler, Z., and Rus, D. 2007. Robust classification of animal tracking data. Computers and Electronics in Agriculture, 56(1):46-59.

Phung Cong Phi, K., Nguyen Thi, K., Nguyen Dinh, C., Tran Duc, N., and Tran Duc, Tan. 2019. Classification of cow’s behaviors based on 3-DoF accelerations from cow’s movements. International Journal of Electrical and Computer Engineering, 9(3):1656-1662.

Bidder, O. R., Campbell, H. A., Gómez-Laich, A., Urgé, P., Walker, J., Cai, Y., and Wilson. 2014. Love thy neighbour: automatic animal behavioural classification of acceleration data using the k-nearest neighbour algorithm. PloS one, 9(2):e88609.

Langrock, R., King, R., Matthiopoulos, J., Thomas, L., Fortin, D., and Morales, J. M. 2012. Flexible and practical modeling of animal telemetry data: hidden Markov models and extensions. Ecology, 93(11): 2336-2342.

Hoang, Q. T., Phung, C. P. K., Bui, T. N., Chu, T. P. D., and Tran, D. T. 2018. Cow Behavior Monitoring Using a Multidimensional Acceleration Sensor and Multiclass SVM. International Journal of Machine Learning and Networked Collaborative Engineering, 2(3):110-118.

Gray, H.G., and Varner, M.A. 1984. Signs of estrus and improving detection of estrus in cattle. Fact Sheet IRM 6, West Virginia University.

Khanh, P. C. P., Long, T. T., Chinh, N. D., & Duc-Tan, Tan. 2018. Performance evaluation of a multi-stage classification for cow behavior. in International Conference on Recent Advances in Signal Processing, Telecommunications and Computing, Hanoi City, Vietnam, 121-125.

Date submitted: October 24, 2019
Reviewed, edited and uploaded: November 22, 2019

Comment