240 Precision Livestock Farming ’22
Sow posture and feeding activity monitoring in a farrowing pen using
J. R. Codling1, Y. Dong2, A. Bonde3, A. Bannis3, A. Macon4, G. Rohrer5, J. Miles5, S. Sharma4, T. Brown-Brandl4,
H.Y. Noh 2, P. Zhang1
1Electrical Engineering and Computer Science Department, University of Michigan, Ann Arbor, Michigan, USA
2Civil and Environmental Engineering Department, Stanford University, Stanford, California, USA
3Department of Electrical and Computer Engineering, Carnegie Mellon University–Silicon Valley, Moffet Field,
4Biological Systems Engineering Department, University of Nebraska–Lincoln, Lincoln, Nebraska, USA
5USDA-ARS U.S. Meat Animal Research Center, Clay Center, Nebraska, USA
Automated monitoring of sow welfare and behaviors is a crucial tool in precision swine
farming, giving farmers access to continuous streams of sow health information. Moni-
toring the activity of the sows helps farmers detect stress, sickness and signs of farrow-
ing, which enables the farmers to provide timely care. Prior work in swine monitoring
frequently uses video cameras, which have lighting and large storage and processing
requirements. Alternatively, other work has used wearable sensors, which have limited
longevity due to durability and battery requirements and suffer from scalability chal-
lenges due to the need for individual sensors worn by each sow.
The objective of the study was to determine the effectiveness of geophone sensors
mounted under the ﬂoor that measure the structural vibration of a farrowing pen to
determine posture changes and animal feeding activity. A total of 6 farrowing/lactat-
ing sows and litters have been used in these studies. The data were collected from
a minimum of 3 days before farrowing to approximately 25 days post-farrow. Up to ﬁve
geophones were used for activity classiﬁcation. Machine learning classiﬁcation meth-
ods are used to detect the position and feeding activity of the sow and her piglets, in-
cluding tree classiﬁers and principal component analysis. Accuracies of over 95% were
achieved in sow posture and feeding activity classiﬁcation, indicating the potential of
monitoring ground vibration as a source of health information.
Keywords: swine monitoring, structural vibrations, geophones, feeding, posture
Precision swine farming requires means to continuously monitor pig health informa-
tion. While manual intervention and observation by farmers and veterinarians remains
the ideal, increasing productivity demands increasing scalability. Thus, numerous
sensing approaches are being developed to observe more ﬁne-grained details which
can allow swine farmers to optimize the care of their animals.
The period between farrowing and weaning is a particularly sensitive time where pigs
must be closely monitored. Currently, the average preweaning mortality in US swine
industry is nearly 18% (Stalder, 2017). Illness, piglet size, and parent-induced injury all
contribute to this issue (Alonso-Spilsbury et al., 2007; Baxter et al., 2011). These issues
Precision Livestock Farming ’22 241
can be improved if addressed by caregivers in a timely manner. Thus, this period is es-
pecially crucial for continuous pig health monitoring.
Prior work to continuously monitor swine utilizes video cameras or wearable sensors,
each with their own drawbacks. Wearables face cost, application on the animals, bat-
tery life, and data transfer challenges which hamper true scalability (Lao et al., 2016;
Graña Possamai et al., 2020). Video cameras can monitor whole farrowing pens at once,
but at the cost of large bandwidth, storage, and data processing requirements (Chen et
al., 2008; Leonard et al., 2019; Condotta et al., 2020). In most cases, this leads to crucial
health information only being available to farmers after weaning when this data can
be retrieved and processed.
Ground and ﬂoor vibrations have shown promise as a means to monitor health and
behavior of humans and animals. Instead of directly applying a sensor to the pigs, this
approach instruments the farrowing pen structure (Alwan et al., 2006; Jia et al., 2016;
Pan et al., 2019). Activity and motion on that structure then create vibrations, which
we measure to indirectly observe the activities that caused them. In humans, this has
enabled indirect measurement of weight, pulse, gait, and overall activity level (Jia et al.,
2016; Fagert et al., 2020; Bonde et al., 2021; Codling et al., 2021).
Applying structural vibration monitoring to swine farming comes with its own set of
unique challenges. Since these sensors both need contact with the structure on which
the pigs reside, and need to avoid damage from the pigs, they are mounted underneath
the farrowing pen. This location prevents the pigs from damaging the sensors directly
but creates its own challenges. First, the location exposes sensors to refuse and spillage
that falls through the pen ﬂoor necessitating increased device ruggedness. The sensors’
location beneath the pen also makes them inaccessible while the pens are occupied and
thus the system needs to be manageable and conﬁgurable remotely. Finally, the location
creates obstacles between the sensors and data receiver, making Wi-Fi communication
unreliable (Ariyadech et al., 2019; Bonde et al., 2021; Codling et al., 2021).
Figure 1: Sensor Network Data Flow Diagram
This paper evaluates the utility of geophone sensors on the ﬂoor for automated pig
health monitoring, using feeding activity and posture recognition as example applica-
tions. We present the design strategy of the novel geophone monitoring approach to
address the challenges of corrosion, remote management, and unreliable communica-
tions. First, the experimental deployment setup will be presented, evaluating the over-
all system in terms of longevity, data volume, and survivability in the farm environ-
ment. Then, the machine learning and signal processing tools will be outlined which
Off-Site Stor age
active piglets active piglets
242 Precision Livestock Farming ’22
allow observation of feeding behavior and posture using the collected vibration signals.
Finally, the resulting recognition accuracy will be discussed with its implications for
future development of piglet and sow monitoring systems.
Figure 2: Geophone instrumentation of a farrowing pen. On the left, green boxes indicate the
location of each sensor node, while the right shows a photo of an instrumented pen with a pregnant
sow in it. One sensor is not visible because the sow is directly on top of it
Material and methods
Data collection was performed in accordance with federal and institutional regulations
regarding proper animal care practices and was approved by the U.S. Center for Animal
Research Institutional Animal Care and Use Committee as EO#143.0.
Sensing System for Farrowing Pens
To provide a continuous stream of pig health information, a semi-autonomous net-
work of custom-built vibration sensors is deployed in the farrowing pens. These sen-
sors use geophones to collect the vibrations in the pen structure which are caused by
the movements of pigs, workers, equipment, and other environmental sources. The sig-
nal content of these vibrations is unique depending on pig, location, and structural pa-
rameters, allowing us to differentiate activities and the pigs’ body posture from them.
This sensor network is based on a design originally proposed for deployment in rural
Thailand (Ariyadech et al., 2019), then reﬁned to improve system reliability (Bonde et
al., 2021; Codling et al., 2021). Figure 1 shows the ﬂow of data in the current iteration.
Vibration information travels left to right, starting at the physical sources in the far-
rowing pen, collected by the sensors, transmitted to the aggregator, then uploaded for
processing away from the farm environment. The only data ﬂowing back into the sys-
tem is management information, such as conﬁguration changes and monitoring con-
nections, enabling the network to run with minimal interaction when combined with
Configur at ion
active piglets active piglets
Precision Livestock Farming ’22 243
For evaluation, we deployed this network in 3 adjacent farrowing pens with 5 sensors
in each, laid out as shown in Figure 2. Since the ideal placement of these sensors in the
farrowing pen is unknown, they are spread so as to cover the entire pen equally. The
experiments were repeated twice, starting data collection at least 3 days pre-farrow
and weaning up to 25 days post-farrow according to the normal schedule followed at
USMARC. The right side of Figure 2 shows a pregnant sow within 3 days of farrowing in
a pen instrumented for this study.
Sow Posture and Feeding Activity Monitoring
After collecting the ground vibration data, the signals and predict the sow postures and
feeding activities were analyzed through machine learning. Ground vibrations induced
by the sow and the piglets are ﬁrst preprocessed to reduce environmental and sensor
noises. Combination of a low-pass ﬁlter (200Hz) with a Wiener ﬁlter that adapts to
different noise thresholds removes noises and higher frequency content that are less
related to the pig activities in the signals. This allows activities which cause lower am-
plitude signals, such as nursing, to be observed in the ground vibrations.
After noise ﬁltering, ground vibration signals, such as those shown in Figure 3, are seg-
mented into 5-second sliding windows for feature extraction. In this study, the length
of 5 seconds is chosen based on the observations of the minimum duration of the sow
maintaining a single posture (speciﬁcally sitting, which typically serves as a transition
between kneeling and standing). These sliding windows are overlapped by 50%, which
allows any temporal dependency between adjacent windows to be captured.
To monitor the posture and feeding activities of the sow and piglets over time, vibration
signal features that are representative of their motions are extracted. These features
include the mean, variance, the maximum and the minimum value of signal magni-
tudes in the time and frequency domains, which are found to be effective in classifying
different types of activities in prior works.
Time- and frequency-domain features are extracted to represent the sow postures and
activities. The time-domain signal features, such as the voltage at each sample from
the geophone, typically contain information about the intensity of the movements,
which allows us to separate activities from the heavier sow from those of the light-
er piglets. Frequency-domain signal features, such as the Discrete Fourier Transform
(DFT) magnitudes of the time domain signal, provide valuable information about the
types of forces that the sow or piglets exert on the ﬂoor. For example, the sow’s stand-
ing posture results in vibration data that have a wide frequency band because of the
sow’s stepping impulses. As a result, a total of 60 features were extracted.
The features extracted above are compressed through principal component analysis
(PCA). A preliminary test shows that the ﬁrst 10 components cover 98% of variances in
a sample day of vibration data.
The postures of the sow are divided into three categories: standing, sitting/kneeling
and lying, as shown in Figure 5. To predict these postures, we use a gradient boosted
tree classiﬁer with the compressed features. The gradient boosted tree is chosen be-
cause it automatically handles missing data due to hardware disconnections. In our
244 Precision Livestock Farming ’22
model, the maximum depth of each tree estimator is 3 and the total number of esti-
mators is 100. This enables non-linear ﬁtting through the combination of many weak
learners. The classiﬁer is trained and tested through a 5-fold cross validation with the
data collected during the deployment.
In order to remove the outlier windows that are ﬁlled with environmental disturbanc-
es or sudden excitement from the piglets, the predicted results are then smoothed
through a moving majority vote algorithm over 5 windows. As shown in Figure 6, the
noisy windows from the original predictions are corrected by their adjacent windows.
Figure 3: A sample of raw ground vibration signals. Periods of piglet activity and nursing are marked,
showing a marked change in signal between these states
Figure 4: Pictures of sows in different postures
Figure 5: Photos of sow ingesting and nursing during the sensor deployment
The feeding activities include sow ingestion and piglet nursing. Figure 5 shows photos
deﬁning each of the activities we predicted based on the geophones’ data. Sow inges-
tion activities are detected through the vibration of the feeding trays and the water
Configur at ion
active piglets active piglets
Configur at ion
active piglets active piglets
Precision Livestock Farming ’22 245
nozzles, for eating and drinking respectively. These components have different materi-
als and shapes and therefore generate different vibration signals that propagate to the
ground. Nursing activities are characterized by a collection of short, high frequency im-
pulses from different piglets superimposed. Ingestion activity is then detected through
a random forest classiﬁer, which gave the best performance during the preliminary
testing with one day’s data.
Results and Discussion
These results are drawn from performance data from deployment at the U.S. Meat An-
imal Research Center. The sensor layouts were described in the methods section, and
cameras were installed above the pens to provide ground truth. These results are based
on the ﬁnal of several experiment repetitions but are indicative of the full study. Each
repetition monitored a different trio of sows in the same conditions over the same time
period relative to farrowing.
Sensing System Applicability for Farrowing Pens
The applicability of the geophone sensor network is evaluated based on reliability and
data efﬁciency. The sensors are powered by wall plugs, obviating the traditional power
constraints of wireless sensor systems. However, reliability remains a concern because
of the environment under the ﬂoor and the obstructions for Wi-Fi communication.
The number of sensors active during a given hour was tracked over the course of each
repetition to determine the overall reliability of the sensor network. While up to half
of the sensors experienced errors simultaneously, all sensors recovered eventually,
and all pens retained at least one functioning node during the entire farrowing period.
These temporary faults are most likely due to ﬁrmware errors and wireless interfer-
ence which prevented data transmission. Using Wi-Fi unfortunately creates an opening
for such interference, trading off bandwidth improvement and central management for
the possibility of intermittent connection loss due to the metallic building.
Data efﬁciency is a concern for precision farming applications due to the remote and
rural locations of farms. With low frame rate and high compression, cameras produce
upwards of 600 MB of data per hour, which then requires large capability processing to
extract information from the image stream. These geophone sensors, in contrast, gen-
erate approximately 3.6 MB per hour per sensor before compression with our typical
sample rate of 500 Hz. This suggests that a geophone-based system will be easier to
adapt to applications within the data constraints of the farm environment.
Posture and Activity Monitoring Results
The gradient boosted tree classiﬁer used to determine sow posture achieved 99.9%,
95.5%, and 100% test accuracy in detecting lying, sitting/kneeling, and standing respec-
tively. Figure 7a shows the confusion matrix for this result. It is noted that most confu-
sions occur between lying and sitting, which makes sense given the similarity in load
distribution between the lying sow and a sitting or kneeling sow.
Our smoothing method, described above, reduces the errors caused by data sam-
ples when the sow is not moving. During such periods there is less vibration, so the
246 Precision Livestock Farming ’22
variations in structure response caused by changing sow posture are difﬁcult to detect.
The majority vote smoothing uses knowledge of the sow’s movement speed to ﬁll in
these low-signal periods with information from the surrounding time windows. Figure
6 shows plots of the posture prediction as a dotted line, compared with a solid line for
ground truth. We can see a close match between the predicted and observed postures
over the course of the 4.5-hour period shown.
Figure 6: A sample series of sow posture changes compared between ground truth and predictions
from geophone data. The solid plot above is the ground truth, observed from video footage
The gradient boosted tree classiﬁer used to determine sow posture achieved 99.9%,
95.5%, and 100% test accuracy in detecting lying, sitting/kneeling, and standing re-
spectively. Figure 7a shows the confusion matrix for this result. It is noted that most
confusions occur between lying and sitting, which makes sense given that similarity
in load distribution between the lying sow and a sitting or kneeling sow.The system
achieved 96% F1-score in sow ingestion, matching the confusion matrix in Figure 7b.
From observing the 10 features used by the ingestion classiﬁer, the mean and variance
of magnitudes in lower frequency bands are signiﬁcantly more important in detecting
the ingestion activity. This indicates that the ground vibration induced by the sow feed-
ing equipment concentrates in the 0-50 Hz frequency bands. Since eating and drinking
have rhythms of movement, the variance of these bands is also important.
For piglet nursing activities, the system has an average 91.3% F1-score, which is much
lower than the activities induced by the sow. The confusion matrix for this classiﬁca-
tion is shown in Figure 7c. There are two main reasons under consideration for this
drop in accuracy. First, the piglet’s activities have much smaller intensity than the sow
due to their age and smaller size, so their movements are harder to detect. Secondly,
the nursing activity is an irregular pattern of relatively low amplitude vibration pulses
(see Figure 3). which can easily be mistaken for the case where some piglets are moving
around while others sleep. Future work will investigate these two challenges to seek
algorithmic means to improve recognition accuracy.
Precision Livestock Farming ’22 247
Figure 7: Confusion matrixes for each of the vibration data classiﬁers. (a) shows the accuracy in
predicting sow posture, (b) for sow ingestion, and (c) for nursing
This paper has evaluated ground vibrations as an alternative modality for precision
swine farming. Sow posture, feeding, and nursing detection in a farrowing crate were
explored as example applications to demonstrate the potential of this new approach.
This evaluation in a research farm shows that a vibration-based system can provide
a continuous stream of pig health information without the overhead inherent in ex-
isting approaches. This suggests that vibration sensing can provide a scalable, reliable,
and accurate source of health information to aid farmers in caring for their livestock.
This work was funded in part by Google, CMKL University, AiFi, Cisco, and the US Na-
tional Science Foundation (under grant numbers NSF-CMMI-2026699 and DGE 1745016).
The views and conclusions contained here are those of the authors and should not
be interpreted as necessarily representing the ofﬁcial policies or endorsements, either
express or implied, of any University, the National Science Foundation, or the United
States Government or any of its agencies.
USDA is an equal opportunity employer.
Alonso-Spilsbury M., Ramirez-Necoechea R., Gonzlez-Lozano M., Mota-Rojas D., Trujillo-Ortega M.E.
(2007) Piglet Survival in Early Lactation: A Review. Journal of Animal and Veterinary Advances
Alwan M., Rajendran P.J., Kell S., Mack D., Dalal S., Wolfe M., Felder R. (2006) A smart and passive
ﬂoor-vibration based fall detector for elderly. In: 2006 2nd International Conference on Information &
Communication Technologies. IEEE, pp. 1003–1007
Ariyadech S., Bonde A., Sangpetch O., Woramontri W., Siripaktanakon W., Pan S., Sangpetch A., Noh
H.Y., Zhang P. (2019) Dependable Sensing System for Pig Farming. In: 2019 IEEE Global Conference
on Internet of Things (GCIoT). IEEE, Dubai, United Arab Emirates, pp. 1–7
Baxter E.M., Jarvis S., Sherwood L., Farish M., Roehe R., Lawrence A.B., Edwards S.A. (2011) Genetic
and environmental effects on piglet survival and maternal behaviour of the farrowing sow. Ap-
plied Animal Behaviour Science 130, 28–41
248 Precision Livestock Farming ’22
Bonde A., Codling J.R., Naruethep K., Dong Y., Siripaktanakon W., Ariyadech S., Sangpetch A., Sang-
petch O., Pan S., Noh H.Y., Zhang P. (2021) PigNet: Failure-Tolerant Pig Activity Monitoring System
Using Structural Vibration. In: Proceedings of the 20th International Conference on Information Process-
ing in Sensor Networks (co-located with CPS-IoT Week 2021). ACM, Nashville TN USA, pp. 1–13
Chen P., Ahammad P., Boyer C., Huang S.-I., Lin L., Lobaton E., Meingast M., Oh S., Wang S., Yan P.,
Yang A.Y., Yeo C., Chang L.-C., Tygar J.D., Sastry S.S. (2008) CITRIC: A low-bandwidth wireless
camera network platform. In: 2008 Second ACM/IEEE International Conference on Distributed Smart
Cameras. pp. 1–10
Codling J.R., Bonde A., Dong Y., Cao S., Sangpetch A., Sangpetch O., Noh H.Y., Zhang P. (2021) MassHog:
Weight-Sensitive Occupant Monitoring for Pig Pens using Actuated Structural Vibrations. In: Ad-
junct Proceedings of the 2021 ACM International Joint Conference on Pervasive and Ubiquitous Computing
and Proceedings of the 2021 ACM International Symposium on Wearable Computers. Association for
Computing Machinery, New York, NY, USA, pp. 600–605
Condotta I.C.F.S., Brown-Brandl T.M., Pitla S.K., Stinn J.P., Silva-Miranda K.O. (2020) Evaluation of
low-cost depth cameras for agricultural applications. Computers and Electronics in Agriculture 173,
Fagert J., Mirshekari M., Pan S., Zhang P., Noh H.Y. (2020) Structural Property Guided Gait Parameter
Estimation Using Footstep-Induced Floor Vibrations. In: Pakzad S. (ed) Dynamics of Civil Structures,
Volume 2. Springer International Publishing, Cham, pp. 191–194
Graña Possamai C., Ravaud P., Ghosn L., Tran V.-T. (2020) Use of wearable biometric monitoring de-
vices to measure outcomes in randomized clinical trials: a methodological systematic review.
BMC Medicine 18, 310
Jia Z., Alaziz M., Chi X., Howard R.E., Zhang Y., Zhang P., Trappe W., Sivasubramaniam A., An N. (2016)
HB-Phone: A Bed-Mounted Geophone-Based Heartbeat Monitoring System. In: 2016 15th ACM/
IEEE International Conference on Information Processing in Sensor Networks (IPSN). pp. 1–12
Lao F., Brown-Brandl T.M., Stinn J.P., Teng G., Liu K., Xin H. (2016) Sow lying behaviors before, during
and after farrowing. In: 2016 ASABE Annual International Meeting. ASABE, St. Joseph, MI, pp. 1
Leonard S.M., Xin H., Brown-Brandl T.M., Ramirez B.C. (2019) Development and application of an
image acquisition system for characterizing sow behaviors in farrowing stalls. Computers and
Electronics in Agriculture 163, 104866
Pan S., Berges M., Rodakowski J., Zhang P., Noh H.Y. (2019) Fine-Grained Recognition of Activities of
Daily Living through Structural Vibration and Electrical Sensing. In: Proceedings of the 6th ACM
International Conference on Systems for Energy-Efﬁcient Buildings, Cities, and Transportation. ACM, New
York NY USA, pp. 149–158
Stalder K.J. (2017) 2016 Pork industry productivity analysis. National Pork Board, Des Moines, IA USA