An Inexpensive AI-Powered IoT Sensor for Continuous Farm-to-Factory Milk Quality Monitoring
Abstract
1. Introduction
- An inexpensive milk quality monitoring system at milk farms that continuously measures the fat and protein content of raw milk in the tanks of the milk suppliers, the pickup trucks and depots across any milk supply chain. It combines commercially available IoT hardware with ML.
- An in-tank IoT device that combines an inexpensive spectrometer, LED lights, an IoT Arduino microcontroller, and an MB-IoT network card. The device houses these electronics in a food-safe, semi-transparent polypropylene enclosure, which is specifically fabricated for milk tanks.
- An ML algorithm that helps translate spectroscopy milk measurements to fat and protein measurements.
- An experimental evaluation of the proposal using hundreds of samples of raw milk from different dairy farms shows that the proposed sensor provides a measurement accuracy of ±0.14% for fat and ±0.07% for protein.
2. Related Work
3. Milk Quality Sensor System Design
3.1. Milk Quality Sensor System Architecture
- The proposed milk quality sensor system and its components can be easily deployed and used via any available IoT platform in the market. The in-tank IoT device and the IoT software components communicate via the MQTT protocol over narrowband (NB-IoT). The sensors in-tank and software components are described in more detail in Section 3.1 and Section 3.2, respectively.
- The proposed sensor can easily adapt to ensure other milk quality parameters, such as somatic cell count (SCC), lactose, and Solids Not Fat (SNF), by using a different converter. This will require retraining the ML algorithm by pairing the relevant ground truth data with the same milk sensor observations to generate the corresponding training dataset, which can then be used to develop an appropriate ML translator to replace the ones used for milk fat and protein here.
3.2. In-Tank IoT Device Component
3.3. IoT Software Component
- Creation of dataset for ML algorithm training: To create the ML algorithm training dataset, we collected fresh farm milk samples directly from dairy farms. The actual fat and protein contents of these samples were determined through independent laboratory testing, which served as ground truth data. Simultaneously, spectral measurements were captured using an in-tank IoT device in a university lab setting and correlated with the ground truth data to create the training dataset for the ML algorithm.
- Training and evaluating the ML algorithm: We experimented with multiple ML algorithms, including decision trees, random forests, and linear regression. Separate ML algorithms were trained for estimating fat and protein values, with the spectral measurements corresponding to the 18 channels as the input features. These algorithms were evaluated using rigorous testing and cross-validation techniques to identify the best-performing algorithm. The results showed that while decision tree and random forests are promising, linear regression emerged as the most accurate and reliable method for predicting fat and protein content in raw milk due to its ability to handle the variations in fat and protein content in farm milk.
- Deploying the ML algorithm: After training and evaluation, we incorporated the optimized linear regression algorithm in our IoT software component of the proposed milk quality sensor. The spectral measurements are read every 1 s. Each spectral measurement is provided as input to the “Translator” component, allowing for milk quality values to be updated every second.
- The continuous ingestion of spectral measurements into the trained machine learning algorithm, which produces instant predictions of fat and protein content, enabling the rapid and reliable quality assessment of milk.
- The periodic retraining of the ML algorithm using a larger number and variety of samples that will allow further improvement in the accuracy and resilience of the milk quality sensor.
4. Milk Quality Sensor System Evaluation
- Collected more than 600 pairs of raw milk samples from more than 80 dairy farms across Victoria, Australia. Each pair of samples was marked with a unique identifier.
- Sent the first of the first sample from each farm to our laboratory and the second milk sample to BVAQ—a commercial lab that is used by the Australian dairy industry to test their milk supply.
- Used the in-tank IoT device to measure the fat and protein content of the milk samples we send to our laboratory. Over 600 samples were tested this way.
- BVAQ provided their milk testing reports for the samples they measured the protein and fat content using their specialized laboratory process, machines, and technicians. The over 600 milk testing reports we received from BVAQ provided the ground truth.
- Correlated the protein and fat measurement we obtained from the in-tank IoT device in (3) and the ground truth from the BVAQ milk testing reports in (4) using the unique identifier from (1).
- Trained the ML algorithm using the correlated dataset in (5).
- Assessed the accuracy of the translator of the milk quality sensor using the remaining data from (3) that were not used in training the ML algorithm.
5. Conclusions and Future Research
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Appendix A
Spectroscopy Channels | Fat | Protein |
---|---|---|
Ch1 | 0.028879 | −0.02064466 |
Ch2 | −0.02161235 | 0.06879262 |
Ch3 | −0.01461645 | 0.03216482 |
Ch4 | −0.00213582 | 0.00036747 |
Ch5 | 0.01519708 | −0.05223435 |
Ch6 | 0.06608016 | 0.00698689 |
Ch7 | −0.06186486 | 0.0209115 |
Ch8 | −0.09539753 | −0.03128069 |
Ch9 | −0.06232195 | −0.04209589 |
Ch10 | −0.01646882 | 0.01167448 |
Ch11 | 0.07641843 | 0.01654799 |
Ch12 | 0.02896871 | 0.00783537 |
Ch13 | −0.0186936 | 0.00219042 |
Ch14 | −0.09573338 | −0.0127194 |
Ch15 | −0.11991515 | −0.02106304 |
Ch16 | −0.03782334 | 0.02359651 |
Ch17 | −0.00463765 | 0.00677463 |
Ch18 | −0.045751 | −0.01391183 |
Intercept | 6.22671706 | 2.7979688 |
References
- Augustin, M.A.; Udabage, P.; Juliano, P.; Clarke, P.T. Towards a more sustainable dairy industry: Integration across the farm-factory interface and the dairy factory of the future. Int. Dairy J. 2013, 31, 2–11. [Google Scholar] [CrossRef]
- Chandan, R.C. Dairy Processing and Quality Assurance: An Overview. In Dairy Processing and Quality Assurance; Wiley: Hoboken, NJ, USA, 2015. [Google Scholar] [CrossRef]
- Sodini, I.; Remeuf, F.; Haddad, C.; Corrieu, G. The Relative Effect of Milk Base, Starter, and Process on Yogurt Texture: A Review. Crit Rev Food Sci Nutr. 2004, 44, 113–137. [Google Scholar] [CrossRef] [PubMed]
- Delikanli, B.; Ozcan, T. Improving the Textural Properties of Yogurt Fortified with Milk Proteins. J Food Process Preserv. 2017, 41, e13101. [Google Scholar] [CrossRef]
- Tamime, A.Y.; Processing, M.; Management, Q. Milk Processing and Quality Management; Wiley: Hoboken, NJ, USA, 2009. [Google Scholar] [CrossRef]
- Law, B.A.; Tamime, A.Y. Technology of Cheesemaking: Second Edition. In Technology of Cheesemaking, 2nd ed.; Wiley-Blackwell: Hoboken, NJ, USA, 2010. [Google Scholar] [CrossRef]
- Sel, Ç.; Bilgen, B.; Bloemhof-Ruwaard, J. Planning and scheduling of the make-and-pack dairy production under lifetime uncertainty. Appl. Math. Model. 2017, 51, 129–144. [Google Scholar] [CrossRef]
- Arduino-Home. Available online: https://www.arduino.cc/ (accessed on 8 July 2024).
- Quality and Testing. Available online: https://www.fao.org/dairy-production-products/products/quality-and-testing/en (accessed on 26 June 2025).
- Poghossian, A.; Geissler, H.; Schöning, M.J. Rapid methods and sensors for milk quality monitoring and spoilage detection. Biosens Bioelectron. 2019, 140, 111272. [Google Scholar] [CrossRef] [PubMed]
- Khan, M.A.A.; Butt, J.; Mebrahtu, H.; Shirvani, H.; Sanaei, A.; Alam, M.N. Integration of Data-Driven Process Re-Engineering and Process Interdependence for Manufacturing Optimization Supported by Smart Structured Data. Designs 2019, 3, 44. [Google Scholar] [CrossRef]
- Chakraborty, M.; Biswas, K. Hardware Platform to Detect Fat Percent in Milk Using a Lipase Immobilized PMMA-Coated Sensor. IEEE Trans. Instrum. Meas. 2019, 68, 4526–4534. [Google Scholar] [CrossRef]
- Chakraborty, M.; Biswas, K. Limit of Detection for Five Common Adulterants in Milk: A Study with Different Fat Percent. IEEE Sens. J. 2018, 18, 2395–2403. [Google Scholar] [CrossRef]
- Fresh Phyllanthus emblica (Amla) Fruit Supplementation Enhances Milk Fatty Acid Profiles and the Antioxidant Capacities of Milk and Blood in Dairy Cows. Available online: https://www.mdpi.com/2076-3921/11/3/485 (accessed on 15 April 2025).
- Chidmi, B.; Murova, O. Measuring market power in the supermarket industry: The case of the Seattle-Tacoma fluid milk market. Agribusiness 2011, 27, 435–449. [Google Scholar] [CrossRef]
- Zhang, T.; Wu, X.; Wu, B.; Dai, C.; Fu, H. Rapid authentication of the geographical origin of milk using portable near-infrared spectrometer and fuzzy uncorrelated discriminant transformation. J. Food Process. Eng. 2022, 45, e14040. [Google Scholar] [CrossRef]
- Wang, Y.; Zhang, K.; Shi, S.; Wang, Q.; Liu, S. Portable Protein and Fat Detector in Milk Based on Multi-Spectral Sensor and Machine Learning. Appl. Sci. 2023, 13, 12320. [Google Scholar] [CrossRef]
- Milk Moovement|Dairy Supply Chain Software for Co-Ops. Available online: https://www.milkmoovement.com/ (accessed on 16 April 2025).
- Kazancoglu, Y.; Ozbiltekin-Pala, M.; Sezer, M.D.; Kumar, A.; Luthra, S. Circular dairy supply chain management through Internet of Things-enabled technologies. Environ. Sci. Pollut. Res. 2022, 1, 1–13. [Google Scholar] [CrossRef] [PubMed]
- Riu, J.; Gorla, G.; Chakif, D.; Boqué, R.; Giussani, B. Rapid Analysis of Milk Using Low-Cost Pocket-Size NIR Spectrometers and Multivariate Analysis. Foods 2020, 9, 1090. [Google Scholar] [CrossRef] [PubMed]
- Lucas, A.; Rock, E.; Chamba, J.F.; Verdier-Metz, I.; Brachet, P.; Coulon, J.B. Respective effects of milk composition and the cheese-making process on cheese compositional variability in components of nutritional interest. Lait 2003, 86, 21–41. [Google Scholar] [CrossRef]
- Lucey, J.A. Cultured dairy products: An overview of their gelation and texture properties. Int. J. Dairy Technol. 2004, 57, 77–84. [Google Scholar] [CrossRef]
- Daurai, B.; Ramchiary, S.S.; Gogoi, M. Comparison of Sparkfun TRIAD AS7265x Spectroscopy Sensor Device with a Spectrophotometer for Qualitative and Quantitative Analysis. In Proceedings of the 2023 4th International Conference on Computing and Communication Systems (I3CS), Shillong, India, 16–18 March 2023. [Google Scholar] [CrossRef]
- eCFR::21 CFR 177.1520—Olefin Polymers. Available online: https://www.ecfr.gov/current/title-21/chapter-I/subchapter-B/part-177/subpart-B/section-177.1520 (accessed on 21 June 2025).
- Polypropylene|Engineering Plastics, Stug Australia. Available online: http://www.stug.com.au/materials/engineering-plastics/polypropylene.php (accessed on 21 June 2025).
- Cumulocity|Cumulocity. Available online: https://www.cumulocity.com/ (accessed on 21 June 2025).
- Spina, A.A.; Ceniti, C.; De Fazio, R.; Oppedisano, F.; Palma, E.; Gugliandolo, E.; Crupi, R.; Raza, S.H.A.; Britti, D.; Piras, C.; et al. Spectral Profiling (Fourier Transform Infrared Spectroscopy) and Machine Learning for the Recognition of Milk from Different Bovine Breeds. Animals 2024, 14, 1271. [Google Scholar] [CrossRef] [PubMed]
- Predictive Insights for Optimizing Milk Collection in Dairy Supply Chains. Available online: https://www.milkmoovement.com/blog-holder/predictive-insights-for-optimizing-milk-collection-in-dairy-supply-chains (accessed on 21 June 2025).
- Hansen, B.; Li, Y.; Sun, R.; Schei, I. Forecasting Milk Delivery to Dairy–How Modern Statistical and Machine Learning Methods Can Contribute. Available online: https://www.sciencedirect.com/science/article/pii/S0957417424003403?casa_token=V9VTcUv4cKAAAAAA:M4msfT94E8I0P85EJ6PX_tuJdkC4QZ6WdnRAoO9fPWouPhYIq1b56FsopIsBlRpfsgWLxtC7FDN7 (accessed on 21 June 2025).
Machine Learning Algorithm | Fat | Protein |
---|---|---|
Linear Regression | 0.143376 | 0.075953 |
DT Regression | 0.207111 | 0.107925 |
Random Forest Regression | 0.179536 | 0.089263 |
KNN Regression | 0.205551 | 0.109128 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Fizza, K.; Banerjee, A.; Georgakopoulos, D.; Jayaraman, P.P.; Yavari, A.; Dawod, A. An Inexpensive AI-Powered IoT Sensor for Continuous Farm-to-Factory Milk Quality Monitoring. Sensors 2025, 25, 4439. https://doi.org/10.3390/s25144439
Fizza K, Banerjee A, Georgakopoulos D, Jayaraman PP, Yavari A, Dawod A. An Inexpensive AI-Powered IoT Sensor for Continuous Farm-to-Factory Milk Quality Monitoring. Sensors. 2025; 25(14):4439. https://doi.org/10.3390/s25144439
Chicago/Turabian StyleFizza, Kaneez, Abhik Banerjee, Dimitrios Georgakopoulos, Prem Prakash Jayaraman, Ali Yavari, and Anas Dawod. 2025. "An Inexpensive AI-Powered IoT Sensor for Continuous Farm-to-Factory Milk Quality Monitoring" Sensors 25, no. 14: 4439. https://doi.org/10.3390/s25144439
APA StyleFizza, K., Banerjee, A., Georgakopoulos, D., Jayaraman, P. P., Yavari, A., & Dawod, A. (2025). An Inexpensive AI-Powered IoT Sensor for Continuous Farm-to-Factory Milk Quality Monitoring. Sensors, 25(14), 4439. https://doi.org/10.3390/s25144439