Machine learning-assisted self-powered ear tag for animal welfare Authors: Xiaoyu Su, Peidi Fan, Ying Liu, Jianfeng Ping, Xunjia Li, Yuxiang Pan Published: 2026 ABSTRACT AbstractMetabolic health serves as a crucial indicator of animal welfare, yet nutritional imbalances in intensive farming diets often induce metabolic dysregulation. ‌However, precise identification of metabolically abnormal animals within intensive production systems remains challenging. Here we report a machine learning-assisted self-powered ear tag that enables streamlined large-scale deployment in livestock production, providing continuous monitoring of ion homeostasis. The ear tag is powered by a hybrid energy harvesting module based on a triboelectric nanogenerator and a solar cell, sustaining energy-autonomous operation through an optimized duty-cycled strategy. Leveraging a microneedle-based multiplexed biosensing module, the system facilitates minimally invasive and time-resolved monitoring of pH, K+, and Ca2+ fluctuations in interstitial fluid. By implementing a machine learning pipeline to decode the coordinated dynamics of these multi-ionic markers, the platform effectively distinguishes among five distinct welfare-related states with an average classification accuracy over 95%. This performance is rigorously validated via leave-one-animal-out cross-validation across 5399 sampling windows from three independent animals. By bridging energy-autonomous operation with intelligent metabolic profiling capabilities, the self-powered ear tag establishes a scalable technological paradigm for next-generation precision livestock health monitoring and welfare management.Subject terms: Electrical and electronic engineering, Biosensors Introduction Abnormal ion homeostasis caused by improper feed formulations is one of the common welfare impairments of intensively farmed animals1–3. Although precision feeding strategies are designed to mitigate metabolic disorders, actual livestock production is frequently compromised by suboptimal nutrition driven by economic pressures, fluctuating ingredient quality, and environmental stressors. These challenges are further intensified for high-value animals, which exhibit heightened susceptibility to metabolic imbalances during critical physiological transitions, such as late gestation or heat stress. Metabolic states induced by inappropriate feeding, including acid load, ketoacid load, alkali load, and calcium depletion, are intrinsically linked to systemic ion levels (Fig. 1A)4,5. However, ion disorders often remain subclinical in their early stages6. Traditionally, ion analysis relies on frequent, invasive blood sampling, which is difficult to scale for the high-throughput needs of intensive farming. Moreover, the time-intensive manual sample processing (typically several hours) potentially masks early ionic fluctuations, missing the critical window for intervention before metabolic disturbances lead to permanent physiological damage7–9. Therefore, there is an urgent need for a dynamic and sustainable monitoring method for livestock metabolic ions. iSPET platform for animal metabolic assessment. A Representative metabolic abnormalities caused by improper diet. B The exploded view of the iSPET platform. C Hybrid self-powered module composed of the TENG and solar cell. D Multiplexed biosensing module for pH, K+, and Ca2+. E ML pipeline for classification of normal, acid load, ketoacid load, alkali load, and calcium depletion. In human healthcare, wearable electrochemical detection of electrolytes and metabolites in sweat or interstitial fluid (ISF) has revolutionized the early diagnosis of metabolic disorders10–13. In contrast, while metabolic sensing for livestock is currently dominated by offline laboratory analysis, wearable biochemical sensing remains in its infancy. Existing solutions are largely confined to specific biological niches, such as in-line milk progesterone assays or rumen pH probes. While effective for their intended purposes, these localized methods cannot capture the broader metabolic fluctuations of animals14–16. Notably, ear tags, originally developed for animal identification, are the most ubiquitous wearables in livestock, with almost every cow, sheep and pig equipped with ear tags17,18. This universality offers an opportunity to re-engineer the ear tag as a continuous metabolic monitoring platform in high-density livestock production. Applying wearable biosensing technologies to livestock requires overcoming sustainable energy challenges. Traditional wearable biosensors rely on lithium batteries with limited lifespans, making them unsuitable for long-term application in farming19,20. Recent studies of livestock wearables reveal that the frequent battery charging or replacement limits the field autonomy. Such limitations highlight the urgent necessity for maintenance-free power solutions capable of autonomous operation in complex farm environments21. Solar cells have been explored as alternatives, but their output is constrained by irregular illumination22,23. Given the unpredictable behavior of livestock, single-source energy harvesting is typically insufficient for continuous operation24,25. Triboelectric nanogenerators (TENGs) harvest random yet sustained human motion for self-powered wearables via contact electrification and electrostatic induction26–28. Extending this concept to livestock, frequent head and ear movements provide a stable yet underutilized biomechanical energy source29–31. Notably, these motions typically occur within the range of 0.5–5 Hz, which aligns with the optimal operating frequency window of TENGs, thereby enabling a reliable, duty-cycled power supply for wearable electronics in intensive farming systems32. In this study, we propose an easily deployable, self-powered, intelligent ear tag platform for continuous metabolic monitoring that enables real-time welfare management in livestock. To accommodate the complex behavior patterns of livestock and rearing environments, a hybrid self-powered module integrating TENG and solar cell is designed for efficient energy harvesting. The customized power management circuit integrates the two energy sources and dynamically balances the energy input. Under indoor conditions, the average output power of TENG and solar cell reaches 7.3 and 28.9 μW/g, respectively. This output ensures that the iSPET platform can operate autonomously via an optimized duty-cycled strategy. This power system supports a lightweight, multiplexed microneedle (MN) biosensing array mounted on the ear tag head, enabling the real-time monitoring of pH, K+, and Ca2+ in ISF. The in vivo experiments on Bama minipigs confirm a strong correlation (Pearson r > 0.86) between the ISF analytes and the serum measurements. Crucially, we implemented a machine learning (ML) pipeline to decode physiological states by extracting engineered features from the coordinated dynamics of these multi-ionic signals. As a result, the iSPET accurately identifies five metabolic categories ranging from normal homeostasis to multifaceted acid-base imbalances and calcium depletion, achieving a 95.26% average accuracy over 5,399 sampling windows. Rigorous leave-one-animal-out cross-validation confirms the reliability of this decoding process. By integrating autonomous energy harvesting with intelligent metabolic profiling, this platform provides a scalable pathway for transitioning toward proactive, data-driven animal welfare management. Results Design of iSPET platform The iSPET integrates a hybrid self-powered module and a multiplexed biosensing module. Inspired by the architecture of commercial ear tag, the self-powered module and biosensing module were ingeniously designed in ear tag body and head (Fig. 1B). Benefiting from the particular split design of body and head of the ear tag, the iSPET could be stably fixed on the ear of livestock. The self-powered module composed of TENG and solar cell was skillfully designed on the ear tag body. The solar cell could operate in indoor or outdoor conditions, and the TENG cell could collect the mechanical energy generated by the swinging of livestock heads (Fig. 1C). Within the ear tag head, the multiplexed biosensing module composed of functionalized MN electrode arrays enabled minimally invasive access to dermal ISF analytes, allowing continuous acquisition of pH, K+, and Ca2+ (Fig. 1D). To achieve electrical conduction between the self-powered module and multiplexed biosensing module, the copper column and the circuit were designed in the ear tag body (Supplementary Fig. 1). Assisted by a ML pipeline, the iSPET platform could evaluate normal, acid load, ketoacid load, alkali load, and calcium depletion states, thus guiding reasonable dietary adjustments for animal welfare (Fig. 1E). All signal processing, wireless transmission and energy management were integrated on a designed printed circuit board to reduce the overall mass of the ear tag and improve the wearable comfort (Supplementary Figs. 2 and 3). Characterization of hybrid self-powered module The TENG cell was designed with a multi-unit architecture consisting of an ear tag frame, polytetrafluoroethylene (PTFE) ball, and Cu electrodes (Fig. 2A and Supplementary Fig. 4). Under movement, the PTFE ball reciprocated within tunnels, inducing charge redistribution via electrostatic induction33. Rolling toward the right electrode, the positive charge was redistributed, driving electron flow from right to left in the circuit, and the reversal of PTFE ball motion produced the opposite current (Fig. 2B). Finite element analysis (FEA) using COMSOL confirmed potential distribution trends consistent with the TENG operating mechanism (Fig. 2C). To optimize energy output, electronegative materials including polyoxymethylene (POM), polypropylene (PP), PTFE, and polyamide (PA) were compared, the PTFE exhibited the superior output due to its high electronegativity and tribo-charge affinity (Fig. 2D and Supplementary Fig. 5)34. Among different ball sizes, 2 mm yielded high open-circuit voltage (VOC) and short-circuit current (ISC) with minimal weight (Fig. 2E and Supplementary Fig. 6). Optimal performance was achieved with a 2 mm electrode gap and 16 balls per unit (Supplementary Figs. 7-8). To further improve the output efficiency of the TENG, a multi-unit structure was designed. The TENG was assembled from one to seven units and connected in parallel, and the VOC and ISC increased with the number of units (Fig. 2F and Supplementary Fig. 9). Given the power-to-weight ratio of the ear tag, seven units were selected for further use (Supplementary Fig. 10). Design and optimization of TENG and solar cell. A A photograph of the TENG cell. Scale bar, 1 cm. Working principle B and FEA C of the TENG cell. Output performance of the TENG cell with different electronegative material types (D), sizes (E), and unit number (F). Output current of the TENG cell under different motion frequency (G) and angle (H). I Charging curves of different capacitors powered by the TENG cell. J Resistance dependence relationship on the output power density and voltage of the TENG cell. K Photograph of ear tag with installed solar cell. Scale bar, 1 cm. L Current–voltage curves of a single solar cell and two solar cells connected in series. Voltage (M) and current (N) of the solar cell under different indoor lighting conditions. O Power of the solar cell under full simulate sunlight and indoor lighting conditions in 24 h. P Charging curves of different capacitors powered by the solar cell. Error bars in (D–F and H) represent standard deviation (SD) of three independent experiments (n = 3). Data are presented as mean ± SD. Source data are provided as a Source Data file. The energy harvesting performance was significantly influenced by the head movement frequency of the livestock. At low frequencies, output was negligible due to insufficient ball motion. With the increase in frequency, the VOC and ISC showed a rapid rising tendency until reaching saturation at 3 Hz, stabilizing at 76.5 V and 392 nA, respectively. (Fig. 2G and Supplementary Fig. 11). Additionally, the relative humidity in the environment strongly influenced the charge transfer behavior of the friction surface (Supplementary Fig. 12). Under actual circumstances, the PTFE ball probably did not always coincide with the direction of the electrode due to the irregular movement of livestock, so different motion angles were investigated. When the motion angle was the same as the swing angle, the VOC and ISC reached maximum (Fig. 2H and Supplementary Fig. 13). Moreover, the TENG presented stable charge and VOC in 3 h (Supplementary Fig. 14). The charging curves of different capacitors showed that the 100 μF capacitor could be charged to 2 V within 200 s (Fig. 2I). The voltage-power relationship of the TENG cell component revealed a maximum peak power density of 7.3 μW/g at a load resistance of 1.0 × 10⁷ Ω (Fig. 2J). The thin-film solar cell was composed of amorphous silicon and adopted a typical p-i-n structure (Supplementary Figs. 15 and 16). To meet the energy supply demands of the ear tag under indoor conditions (500 Lux), two large-area cells were connected in series to increase the output voltage (Fig. 2K, L and Supplementary Fig. 17). Under simulated indoor lighting, both voltage and current increased proportionally with light intensity from 0 to 1000 Lux, indicating good sensitivity to ambient variation (Fig. 2M and N). Considering practical deployment, where ear tags typically hang perpendicular to the ground, the impact of tilt angles (0°, 30°, 60°, and 90°) was investigated (Supplementary Fig. 18). While the vertical orientation showed a slight decrease compared to the optimal 30° position, it still maintained sufficient electrical output. Any variation caused by angles was mitigated through the designed intermittent sensing mechanism, as the efficiency decline merely extended the energy accumulation interval without affecting functional integrity35. The solar cell maintained stable output without degradation after 24 h of continuous indoor or simulated sunlight exposure, achieving a peak power density of 28.9 μW/g (Fig. 2O). Additionally, a 470 μF capacitor could be charged to 0.45 V within 120 s under indoor light (Fig. 2P). Due to the relatively high internal resistance of the TENG, it was not directly compatible with the solar cell, necessitating a dedicated energy management circuit36–38. The energy management circuit comprised two components: a rectification circuit and a step-down circuit (Fig. 3A). The rectification circuit for TENG was composed of four high-voltage diodes (2CL72), converting alternating current into a stable direct current output, and then the current flowed to capacitor C1 (100 pF). The step-down circuit included a transient voltage suppressor D1 (TVS, P6KE440A), silicon-controlled rectifier (SCR, EC103M1), inductor L1 (1 mH), capacitor C2, and an ultrafast diode D2 (MUR460). Once the voltage on C1 exceeded the clamping threshold of D1, a surge current triggered the thyristor, allowing the stored energy to transfer into L1. In the subsequent stage, the current oscillated through L1, C2, and D2, effectively conditioning the output voltage to power downstream electronics. This energy management circuit was connected in parallel with the solar cell and a high-voltage diode (2CL72) to jointly supply power to the overall system. Hybrid energy management and evaluation. A Schematic of the energy management circuit for the hybrid module. B Charging curves of a 470 μF capacitor powered by the TENG, solar cell, and hybrid module. C Voltage curves of the 50 mAh lithium battery powered by the hybrid module. D Output voltage curves of the TENG and hybrid module under indoor (500 Lux) and outdoor (7000 Lux) lighting. E Output voltage curves of the solar cell and hybrid module under varying illumination. Real-time output voltage responses corresponding to typical livestock activities: walking (F), feeding (G), head-shaking (H), and standing (I). J 12 h voltage profile of the integrated supercapacitor while the iSPET was fixed on a Bama minipig. Source data are provided as a Source Data file. Figure 3B displayed charging curves of a 470 μF capacitor powered by the TENG, solar cell and hybrid module. Initially, the solar cell dominated the charging process, but its rate slowed over time, while the contribution from the TENG became more prominent in the later stage. This suggests that the high output voltage of the TENG allows the hybrid module to surpass the maximum voltage limit typically imposed by standalone solar cells39. Meanwhile, the high output power of solar compensates for the TENG’s limitations in driving high-power electronics. With active circuit management, a 50 mAh lithium battery was successfully charged from initial 3.0 (low state of charge) to 3.3 V under indoor 500 Lux using a 3 Hz and 180° motion profile within 30 min. This voltage increase corresponds to a stored energy of approximately 50 J, demonstrating the feasibility of sustained operation enabled by energy harvesting (Fig. 3C). The output performance of the TENG and hybrid module was further evaluated under both indoor (500 Lux) and outdoor (7000 Lux) lighting conditions, with the hybrid module consistently exhibiting superior output (Fig. 3D). Across both lighting scenarios, the hybrid module outperformed either individual cell, highlighting the complementary nature of the TENG and solar cell (Fig. 3E). During the operation, harvested energy was stored in an ultracapacitor with logic-controlled discharge. When the voltage reached 3 V, the control circuit activated the system, causing the supercapacitor voltage to drop to 2 V (Supplementary Fig. 19). To explore the energy harvesting of the hybrid module for the daily activities of livestock, the voltage signal was measured under four typical activity states: walking, feeding, head-shaking, and standing (Fig. 3F-I). System-level power consumption was analyzed under a 3 V supply, revealing three typical states: advertising mode, pairing initiation, and paired mode, with an average power consumption in paired mode of ~0.66 mW (Supplementary Fig. 20). The harvested energy was sufficient to support these operation modes (Supplementary Table 1). The 12-hour voltage profile showed that the system maintained a duty-cycled operation every 30 min under indoor lighting, while achieving sustained and stable operation under outdoor conditions (7000 Lux) without the need for duty cycling (Fig. 3J). During periods of reduced illumination or animal activity, such as nighttime, the system utilizes a lower sampling frequency. This adaptive, intermittent sampling strategy prevents energy depletion and supports stable, long-term operation without battery even in the absence of solar input (Supplementary Fig. 21). Characterization of multiplexed biosensing module The multiplexed biosensing module consisted of four functionalized MN arrays, including a potentiometric pH sensor electrode, a K+ sensor electrode, a Ca2+ sensor electrode, and a shared reference electrode (RE) (Fig. 4A). The shape of the MN was conical, with a height and base diameter was about of 1000 μm and 500 μm respectively (Fig. 4B). SEM characterization demonstrated that the MN exhibited sharp tip with a radius of ~10 μm (Supplementary Fig. 22). Optical profiling revealed the surface roughness of MN was about 3.23 μm (Supplementary Fig. 23). Mechanical characterization studies validated that MNs exhibited sufficient mechanical strength for reliable stratum corneum penetration and dermal ISF extraction (Fig. 4C and Supplementary Fig. 24), with porcine skin insertion requiring only 0.32 N/needle (Fig. 4D). Mechanical durability of the MN was evaluated through repetitive insertion into pig ear skin. After 10 consecutive insertions, the MN maintained their structural integrity without observable mechanical failure (Supplementary Fig. 25). Simulation results further confirmed the high mechanical stability and robustness of MN-based multiplexed biosensing module (Supplementary Fig. 26). Design and characterization of multiplexed biosensing module. A Schematic of multiplexed biosensing module. B Ultra-depth three-dimensional microscope image of the MN. Compression C and penetration tests D of the MN. E Mechanism for pH sensing. F Stepwise modify of the MN/Au/PANI electrode. G OCP response of the pH sensor (inset: calibration plot with a linear fit). H Anti-interference performance of the pH sensor. I Mechanism for K+ sensing. J Stepwise modify of the MN/Au/PEDOT:PSS/K+-ISM electrode. K OCP response of the K+ sensor (inset: calibration plot with a linear fit). L Anti-interference performance of the K+ sensor. M The mechanism for Ca2+ sensing. N Stepwise modify of the MN/Au/PEDOT:PSS/Ca2+-ISM electrode. O OCP response of the Ca2+ sensor (inset: calibration plot with a linear fit). P Anti-interference performance of the Ca2+ sensor. Source data are provided as a Source Data file. For long-time monitoring, the RE must be insensitive to fluctuations in ion concentration and exhibit high stability40. Polyvinyl butyral (PVB) coating was utilized to enhance the stability of the RE, and the MN/Ag-AgCl/PVB presented excellent stability compared with MN/Ag-AgCl. Furthermore, with the concentration alteration of NaCl, the MN/Ag-AgCl/PVB still presented a good stability, indicating that the PVB coated RE had an admirable ion insensitivity (Supplementary Fig. 27). To simulate in vivo conditions, the RE was evaluated at 37 °C in different KCl solutions (0.01, 0.10, and 0.50 M). Open circuit potential (OCP) was monitored continuously for 24 h, and the potential drift was well controlled in 0.38 mV/h (Supplementary Fig. 28). For pH determination, the polyaniline (PANI) layer was electropolymerized on the MN/Au, where the protonation and deprotonation of emeraldine salt (PANI-ES) and emeraldine base (PANI-EB) could realize pH sensing (Fig. 4E and Supplementary Fig. 29). In Cyclic voltammetry (CV), the redox peak of MN/Au showed an increasing tendency compared with bare MN (Fig. 4F), proving it to be a satisfactory electrochemical interface (Supplementary Figs. 30-32)41. Subsequently, benefiting from the effective electropolymerization of PANI on the MN/Au, the redox peak of MN/Au/PANI continued to increase. Within the range of pH 4 to 8, a robust linear relationship between the pH and potential was observed, with a calculated sensitivity of 56.1 mV/pH (Fig. 4G). Negligible fluctuations in the response signal of the pH were observed upon the addition of interfering ions, demonstrating excellent selectivity. (Fig. 4H and Supplementary Fig. 33). For K+ determination, the ionophores in K+-ion selective membrane (K+-ISM) only allow K+ to pass through due to the cavity in ionophores and K+ was highly matched, thus forming a complex to achieve K+ sensing (Fig. 4I). In CVs, the redox current of MN/Au/PEDOT:PSS increased compared with MN/Au due to the high conductivity of PEDOT:PSS (Supplementary Fig. 34). Owing to the non-conductivity of K+-ISM, a downward trend can be observed in the redox current of MN/Au/PEDOT:PSS/K+-ISM (Fig. 4J). With the K+ from 1 to 32 mM, the OCP exhibited an upward tendency, and the sensitivity was calculated as 57.8 mV/dec (Fig. 4K). With the addition of interfering ions, the OCP response of K+ did not present obvious variation, indicating acceptable selectivity (Fig. 4L and Supplementary Fig. 35). For Ca2+ determination, the Ca2+-ion selective membrane (Ca2+-ISM) preferentially formed a stable complex with Ca2+, and led to the ion exchange between the membrane and solution, realizing Ca2+ analysis (Fig. 4M). Similar to the K+ selective electrode, the stepwise modification of MN/Au/PEDOT:PSS/Ca2+-ISM presented ideal results (Fig. 4N). With the Ca2+ levels from 0.5 to 16 mM, the OCP appeared an upward tendency, with the sensitivity was calculated as 28.4 mV/dec (Fig. 4O). Addition of other common interferents did not cause significant changes in the Ca2+ signal (Fig. 4P and Supplementary Fig. 36). Repeatability studies (n = 5) of pH, K+, and Ca2+ sensors showed satisfactory consistency, with mean ± SD values of 52.06 ± 5.71 mV/pH, 53.86 ± 3.57 mV/dec, and 25.28 ± 2.55 mV/dec. Long-term stability exploration over 7 days demonstrated the sensitivity of pH, K+, and Ca2+ sensor maintained at 84.3%, 83.4%, and 88.7% compared with day 1 (Supplementary Figs. 37-39). In vivo monitoring and ML-assisted animal metabolic assessment The iSPET featured a lightweight design (<20 g total mass) for minimally invasive attachment to porcine auricular tissue (Fig. 5A, Supplementary Figs. 40 and 41). The deployment of iSPET followed established commercial ear-tagging protocols, utilizing purpose-designed applicators for precise attachment to Bama minipigs within 2 seconds (Fig. 5B). H&E staining confirmed that the MN penetrated the dermal layer, with micropore dimensions precisely matching the MN geometry (Fig. 5C and Supplementary Fig. 42). Following withdrawal, the skin micropores closed completely within 30 minutes (Fig. 5D). Biocompatibility was further validated through normal human dermal fibroblast assays. High cell viability and consistent fluorescence staining confirmed that the sensors are safe for prolonged wearable applications (Supplementary Fig. 43). Crucially, H&E sections obtained after the full 14-day trial revealed that the MN remained securely and properly seated within the dermis. This persistent penetration confirmed that the iSPET maintained a stable, long-term sensing interface despite the active movements of the animal (Supplementary Fig. 44). In vivo monitoring of metabolic fluctuations. A Front and back images of iSPET fixed on the Bama minipig. Scale bar, 1 cm. B The fixing process between ear tag body and head. C H&E staining before and after MN penetration. Scale bar, 100 µm. The experiments were repeated three times with similar results. D The recovery before and after MN insertion. Spaghetti plots of pH, K+, and Ca2+ levels over 14 days across four induction states of three pigs, including acid load (E), ketoacid load (F), alkali load (G), and calcium depletion (H). I Correlation and Bland-Altman analysis of iSPET and biochemical analyzer (n = 36 for each ion). The shaded regions represent 95% confidence interval. Source data are provided as a Source Data file. Building on demonstrated biocompatibility, we evaluated the capability of iSPET to track metabolic fluctuations critical to animal welfare. Over a 14-day induction period, Bama minipigs were fed specific nutritional formulations to simulate common metabolic welfare impairments, including acid load, ketoacid load, alkali load, and calcium depletion. Longitudinal profiling was performed at baseline (Day 0), interim (Day 7), and endpoint (Day 14) to capture the dynamics of metabolic ion homeostasis (Supplementary Movie 1). Considering inter-animal variability, spaghetti plots were employed to visualize the physiological shifts for each animal. The overall group trends remained consistent, and the detailed data were provided in Supplementary Figs. 45-48. Under acid load and ketoacid load, the pH decreased significantly on Day 14, accompanied by an increasing tendency in K+ due to H+-K+ exchange. Conversely, alkali load induction led to a corresponding increase in pH and a decrease in K+. In the calcium depletion group, Ca2+ concentration significantly decreased (Fig. 5E-H). To ensure ISF monitoring reliably captures metabolic fluctuations, iSPET results were compared with gold-standard blood analysis. The data showed high correlation between ISF and blood measurements (Pearson r > 0.86), while Bland-Altman analysis further quantified the agreement by reporting the mean bias and 95% limits of agreement, with the majority of data points falling within these limits (Fig. 5I). ML-integrated ear tags have shown great promise in predicting animal states, such as decoding motion data to track reproductive windows in cattle42. To enhance animal welfare through proactive health monitoring, a ML pipeline was developed to decode a favorable connection between the metabolic status and the ion levels of Bama minipigs. Window cutting and feature extraction of the electrochemical data were carried out after each experiment, with all signals calibrated and normalized to eliminate the adverse effects caused by singular sample43. We implemented the Extreme Gradient Boosting (XGBoost) algorithm, utilizing 11 physiologically informed features and leave-one-animal-out cross-validation. This approach achieved exceptional binary classification, distinguishing healthy from abnormal metabolic states with 97.22% and 100.00% accuracy, respectively (Fig. 6A). ML-assisted metabolic assessment. A Confusion matrices of normal and abnormal states. B Confusion matrices of normal, acid load, ketoacid load, alkali load, and calcium depletion. C Sankey diagram of SHAP analysis of 11 features from pH, K+, and Ca2+ to different metabolic states. SHAP analyses and feature importance of all classes for binary classification D and five-class classification (E). Error bars in Fig. 6D and E represent 95% confidence intervals estimated by bootstrap resampling (n = 500). Data are presented as mean values with 95% confidence intervals. Source data are provided as a Source Data file. We expanded our predictive framework to distinguish five distinct welfare-related states, leveraging the synergistic information within the multi-ion feature set. The identification accuracy of normal, acid load, ketoacid load, alkali load, and calcium depletion was 98.16%, 94.63%, 93.70%, 94.61%, and 95.20%, respectively (Fig. 6B). To demystify the model’s decisions, Shapley Additive Explanation (SHAP) analysis was employed to quantify feature contributions. Sankey diagram of SHAP analysis depicted how the 11 features linked with pH, K+, and Ca2+ drive specific metabolic classifications (Fig. 6C). The importance of separate each class signatures was further detailed using radar plots (Supplementary Fig. 49). Calibration curves and Brier scores further indicated that the model maintained stable, well-calibrated probability estimates despite physiological drift across the 14-day trial (Supplementary Table 2 and Supplementary Fig. 50). Detailed SHAP analysis of binary classification and five-class classification confirmed that model decisions relied on coordinated contributions from all 11 features rather than single markers (Fig. 6D, E and Supplementary Fig. 51). For instance, the acid and alkali load states were primarily driven by pH drift and pH and K+ ratio44–46. In contrast, ketoacid load involved a more complex interplay between pH temporal offsets and K+ relative mean, while calcium depletion was characterized by Ca2+-related features coupled with state-dependent K+ dynamics47. These results validated the multi-ion coupling as a key mechanism underlying metabolic state discrimination. Additional validation analyses, including bootstrapped performance metrics, probability calibration, and domain-shift robustness, were provided in the Supplementary Note 6. Unlike conventional ear tags limited to behavioral or thermal tracking, iSPET introduces a direct biochemical dimension through in-situ sensing of pH, K+, and Ca2+. This platform represents the ear-tag system to integrate multi-ion biochemical sensing with self-powered operation, eliminating the need for stressful, repeated blood sampling (Supplementary Table 3). By harvesting energy from animal motion, the system reduces both total mass and maintenance requirements, enabling extended monitoring intervals with minimal human intervention. While most reported wearable electrochemical sensors are constrained by battery life to operation windows of several hours to one week, iSPET demonstrated 14 days of continuous in vivo biochemical monitoring (Supplementary Table 4). This combination of a lightweight, affordable design and high-fidelity metabolic sensing offers a scalable, low-maintenance pathway for enhancing animal welfare in precision livestock farming. Discussion We present an easily deployable, sustainable iSPET platform for proactive animal welfare assessment. The platform can continuously and painlessly monitor the pH, K+ and Ca2+ in ISF through MN-based electrochemical technology, addressing the key limitations of traditional discontinuous invasive methods, capable of early detection and intervention of metabolic disorders. The design of hybrid energy harvesting system combines TENG and solar cells, overcoming the persistent power challenges in the agricultural environment and ensuring uninterrupted operation in livestock production scenarios. Benefiting from metabolic ion dynamics and artificial intelligence algorithms, the platform demonstrated an average recognition accuracy of over 95% in discriminating five metabolic states in Bama minipigs. Despite these advancements, maintaining the long-term stability of in vivo electrochemical interfaces remains a challenge, and future work will focus on interface engineering to further extend operational lifetime. Beyond ionic monitoring, expanding the library of biochemical targets and integrating multimodal sensors could provide a more comprehensive view of animal metabolism. Rather than replacing existing technologies, iSPET serves as a biochemical extension to current behavioral ear tags. This complementary sensing approach enables the early detection of metabolic shifts, providing a more comprehensive framework for real-time animal welfare assessment. While initially designed for agriculture, we envision adapting this platform for companion animal health to broaden the scope of animal welfare. Overall, this work establishes a robust framework for self-powered biochemical ear tags and outlines a practical pathway toward scalable metabolic monitoring in livestock. Methods Ethics statement All animal experiments were conducted in accordance with relevant ethical regulations and were approved by ZJU-Laboratory Animal Welfare and Ethics Review Committee (Approval number: ZJU20240169). Three clinically healthy Bama minipigs (30 ± 5 kg) were provided from Hangzhou Hebei Technology Co., LTD (China). The sample size was determined based on the feasibility requirements and ethical considerations for large-animal metabolic research. Design and fabrication of the MN arrays The multiplexed biosensing module comprising four MN arrays for electrochemical sensing, each 1 mm thick and featuring eight conical projections. The MN arrays were designed using SolidWorks software and fabricated by micromachining process. The vertical dimension, basal diameter, and inter-needle spacing were 1 mm, 500 μm, and 900 μm, respectively. Poly(methyl methacrylate) (PMMA) was chosen as substrate material due to its mechanical properties and biocompatibility. The fabricated MN were installed on the 3D-printed ear tag heads, which were made of polyethylene terephthalate-I, and the detailed dimensions and tolerances were provided in the CAD drawings (Supplementary Fig. 52). Subsequently, magnetron sputtering was employed to deposit conductive layers onto the MN surfaces. (Supplementary Note 4). Preparation of the pH, Ca2+, and K+ sensors Before the functionalization, all the working electrodes were firstly modified with gold nanoparticles in a 2.5 M NH4Cl solution containing 10 mM HAuCl4. Electrodeposition was performed at − 0.8 V for 60 s to form MN/Au substrate. For the pH sensor, polyaniline (PANI) nanostructures were electropolymerized onto the MN/Au via cyclic voltammetry in an aqueous solution containing 0.1 M aniline and 1 M HCl, with the potential window of −0.2 to 1.0 V. This process yielded uniform MN/Au/PANI architecture, providing a stable electrochemical interface for pH sensing. For the K+ and Ca2+ sensors, a homogeneous Poly(3,4-ethylenedioxythiophene):polystyrene sulfonate (PEDOT:PSS) conductive polymer layer was grafted on the MN/Au substrate by applying a constant current of 14 μA for 10 min in precursor solution containing 0.01 M EDOT and 0.1 M NaPSS. All electrochemical modification procedures (Au, PANI, and PEDOT:PSS) were carried out under stirring at 500 rpm in room temperature, with an effective electrode area of approximately 6.5 mm2. The K+-ISM was prepared by dissolving a 100 mg mixture, including valinomycin (2%, w/w), DOS (64.7%, w/w), PVC (32.7%, w/w), and NaTPB (0.5%, w/w) in 350 μL of cyclohexanone. The K+-ISM was uniformly dropped on MN/Au/PEDOT:PSS and left at room temperature to form the MN/Au/PEDOT:PSS/K+-ISM. Similarly, the Ca2+-ISM was prepared by dissolving a 100 mg mixture, including ETH 129 (0.46%, w/w), NaTPB (0.48%, w/w), PVC (33.02%, w/w), and NPOE (66.04%, w/w) in 1 mL tetrahydrofuran, and modified onto the MN/Au/PEDOT:PSS substrate to yield MN/Au/PEDOT:PSS/Ca2+-ISM. Both ion-selective electrodes were dried in room temperature for 24 h, resulting in a membrane thickness of ~100 μm. Before measurements, the electrodes were conditioned overnight in 0.01 M KCl (K+-ISM), 0.01 M CaCl2 (Ca2+-ISM) or 0.01 M HCl (H+-ISM), respectively, to equilibrate the ion-exchange sites and stabilize the membrane potential. Sensors maintained stable performance in two weeks when stored at 4 °C. For RE preparation, the Ag layer was firstly modified on MN by multi-current electrodeposition in a solution containing 0.5 M NaHSO3, 0.25 M AgNO3, and 0.75 M Na2S2O3. The current steps were −0.01 mA for 150 s, −0.02 mA for 50 s, −0.05 mA for 50 s, −0.08 mA for 50 s, and −0.1 mA. The electrode surface was then treated with 0.1 M FeCl3 for 30 s to form the Ag/AgCl layer. A reference membrane cocktail, prepared by dissolving 79.1 mg PVB and 50 mg NaCl in 1 mL methanol, was deposited onto the MN/Ag-AgCl and dried to produce the MN/Ag-AgCl/PVB electrode. Morphological characterization confirmed the successful modification of the pH, K+, and Ca2+ sensors (Supplementary Figs. 53–59). Before implantation, each pH, K+ and Ca2+ sensor was calibrated at 37 °C in three standard solutions (pH 6.8/7.4/8.0, K+ 3.0/5.0/8.0 mM, and Ca2+ 0.5/1.0/1.5 mM) with a 3 min stabilization period. During in vivo monitoring, an adaptive baseline normalization strategy was adopted instead of repeated wet recalibrations. All measurements were referenced to the first reading of each day to compensate for baseline drift, thermal fluctuations and batch-to-batch offsets without disturbing the animals. Fabrication of the TENG cell The multi-tunnel TENG cell was designed using SolidWorks software and fabricated via FDM 3D printer (X1 Carbon, Bambu Lab, China) with TPU as the printing material. The TENG cell comprised seven parallel tunnels (length: 42 mm; width: 4.3 mm). Copper foil (thickness: 30 μm, purity: ≥ 99.9%) were affixed along the parallel grooves to form the electrodes. Commercial virgin PTFE balls (diameter: 2 mm) were placed within each tunnel unit to enable contact electrification. Conductive circuits were deposited onto the back of the ear tag body using thermal evaporation to electrically connect the electrochemical and energy harvesting module. Fabrication of the solar cell Initially, the stainless-steel substrate was cleaned within a vacuum chamber using plasma sources. A reflector layer was then deposited via magnetron sputtering. Subsequently, core amorphous silicon (a-Si) and amorphous silicon-germanium (a-SiGe) absorber layers (total thickness: 500 nm) were deposited using plasma-enhanced chemical vapor deposition (PECVD, TRP450, China). During PECVD, the substrate temperature was maintained at 200 °C, with gas flow rates of SiH4 (20 sccm), H2 (100 sccm), and GeH4 (5 sccm). An indium tin oxide transparent conductive oxide layer (thickness: 100 nm) was sputtered next. The large-area sheet undergone laser scribing for sizing and edge isolation, followed by silicon nitride passivation (thickness: 80 nm) applied via PECVD. Finally, the negative and positive electrodes were formed through laser welding to complete the solar cell assembly. Animal models and experimental design Three clinically healthy male Bama minipigs (Sus scrofa domesticus, 6 months old, 30 ± 5 kg) were used in this study. Sex was not considered as a variable, as all animals used in this study were male. Animals were housed individually in climate-controlled cages (18–26 °C, 50–60% RH) under a 12 h light/12 h dark cycle, and allowed exploratory behavior and visual contact with adjacent pigs through pen dividers to maintain social interaction while preventing aggression. Daily monitoring of appetite, body posture, ambulation, skin condition, and ear tag tolerance was performed by trained staff, and weekly body weight was recorded. For the dietary induction experiments, each animal was sequentially subjected to four distinct dietary induction phases. Following the completion of each 14-day induction, a 7-day recovery period under standard feeding conditions was implemented to ensure full physiological recovery and a return to baseline metabolism before the subsequent induction. Metabolic states were induced as follow: (1) Acid load: basal diet supplemented with 5% ammonium chloride (NH4Cl, w/w); (2) Alkali load: basal diet with 3% sodium bicarbonate (NaHCO3, w/w); (3) Calcium depletion: low-calcium diet (Ca2+ ≤ 0.3%) with 1.5% phytic acid as a calcium chelator; (4) Ketoacid load: a high-fat, low-carbohydrate basal diet, in which the fat content was increased to 8–10% (w/w) and starch content was reduced to 3–5% (w/w). In vivo monitoring and validation Before experiment, the skin was disinfected with povidone-iodine, and a single iSPET was secured to the ear. To ensure a stable sensing microenvironment, the device remained at the same location throughout the 14-day period. Following a 2 h stabilization period, electrochemical recordings were performed using a standardized 1 h sampling block starting at 9:00 AM at baseline (Day 0), mid-study (Day 7), and end-of-study (Day 14) to minimize circadian effects and ensure longitudinal comparability. The insertion site was examined daily for erythema, edema, bleeding, or adverse skin reactions. To validate sensing accuracy against gold-standard blood analysis, blood samples were collected on Days 0, 7, and 14. During blood sampling procedures, general anesthesia was induced with 5% isoflurane and maintained at 1–3% to ensure animal immobility and minimize discomfort. Animal procedures were approved by the Institutional Animal Care and Use Committee and complied with AVMA euthanasia guidelines. After completion of all experimental procedures, the animals were humanely euthanized by intravenous administration of sodium pentobarbital (100 mg/kg). Machine learning analysis A supervised ML pipeline was established to classify metabolic states based on pH, K+, and Ca2+ signals. Raw potentials were first converted to concentrations using pre-deployment calibration curves. To mitigate baseline drift, temperature variation and batch-to-batch offsets during long-term recording, an adaptive normalization strategy was implemented, where all daily measurements were referenced to the initial reading of each animal for that day. To prepare the dataset, continuous recordings were segmented into fixed-length temporal windows of 100 samples (20 s) with a stride of 150 samples (30 s). From each window, we extracted 11 physiologically informed features across the three sensing channels, including baseline-referenced relative mean values, temporal offset, and coefficient of variation, alongside cross-channel ratios and synchronization features designed to capture coordinated ionic dynamics (Supplementary Table 5). To ensure animal-level independence and prevent temporal or inter-animal data leakage, model evaluation was conducted using leave-one-animal-out cross-validation. The data from one animal were held out for testing while data from the remaining animals were used for training. Normalization was performed on a per-animal basis to avoid leakage of animal-specific information. XGBoost was employed as the classifier due to its robustness to nonlinear feature interactions. A comprehensive Data Statement summarizing the window counts per animal (n = 3) and metabolic state was provided in Supplementary Table 6. To ensure reproducibility, the full preprocessing scripts, cross-validation logic, and random seeds could be made available in a public code repository upon publication. Reporting summary Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article. Supplementary information Supplementary Information Description of Additional Supplementary Files Supplementary Movie 1 Reporting Summary Transparent Peer Review file Source data Source Data Author contributions Y.P., X.L., and X.S. conceived the project. Y.P. and X.L. supervised the project. X.S., P.F., and Y.L. led the experiments and collected the overall data. X.S. analyzed the data and wrote the manuscript. J.P., Y.P., and X.L. checked and revised the manuscript. All authors substantially contributed to the research and reviewed the manuscript. Peer review Peer review information Nature Communications thanks Taeil Kim and the other anonymous reviewer(s) for their contribution to the peer review of this work. A peer review file is available. Funding This work was supported by Natural Science Foundation of Zhejiang Province, China (LZ24C130002 to Y.P.), National Natural Science Foundation of China (32401683 to X.L.), and China Postdoctoral Science Foundation Funded Project (No. 2023M743089 to X.L.). Data availability All data supporting the findings of this study are available within the article and its supplementary files. Any additional requests for information can be directed to and will be fulfilled by the corresponding authors. Source data are provided with this paper. Code availability The data collected by the iSPET from Bama minipigs and all codes used for implementation of the data augmentation and classification are available from GitHub (https://github.com/Xiaoyu-408/ear-tag-ml) and Zenodo (10.5281/zenodo.19430077). Competing interests The authors declare no competing interests. Footnotes Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Contributor Information Xunjia Li, Email: lixunjia@zju.edu.cn. Yuxiang Pan, Email: panyuxiang@zju.edu.cn. Supplementary information The online version contains supplementary material available at 10.1038/s41467-026-73651-7. References Associated Data Supplementary Materials Supplementary Information Description of Additional Supplementary Files Supplementary Movie 1 Reporting Summary Transparent Peer Review file Source Data Data Availability Statement All data supporting the findings of this study are available within the article and its supplementary files. Any additional requests for information can be directed to and will be fulfilled by the corresponding authors. Source data are provided with this paper. The data collected by the iSPET from Bama minipigs and all codes used for implementation of the data augmentation and classification are available from GitHub (https://github.com/Xiaoyu-408/ear-tag-ml) and Zenodo (10.5281/zenodo.19430077).