Milk adulteration is a critical public health concern, particularly in developing countries, where harmful substances such as water, urea, and detergent are commonly added to increase quantity and profit. Conventional detection methods rely on laboratory-based chemical analysis, which is time-consuming, expensive, and requires skilled personnel, creating a strong need for an automated, cost-effective, and portable solution for instant milk quality assessment. This paper presents a Smart Milk Adulteration & Dairy Fraud Detection System that integrates Internet of Things (IoT) and Machine Learning (ML) technologies to enable real-time detection. The system uses an Arduino UNO combined with pH, temperature (DHT11), and conductivity sensors to collect milk sample data, which is transmitted through an ESP8266 WiFi module to a Node.js backend and further processed by a Python Flask-based ML service. A Random Forest algorithm classifies milk into four categories -- Pure, Watered, Detergent, and Urea adulterated -- with results displayed instantly on an LCD screen and a React.js web dashboard, while all readings are stored in a MongoDB database. The proposed system achieves a cross-validation F1-macro score of 99.25%, with a total hardware cost under ?4,000, offering a reliable, low-cost, and scalable solution for real-time milk adulteration detection suitable for dairy farms, milk collection centers, and food safety monitoring.
Introduction
This study presents a Smart Milk Adulteration and Dairy Fraud Detection System that combines Internet of Things (IoT) technology and Machine Learning (ML) to detect common milk adulterants quickly and accurately. Milk adulteration with substances such as water, urea, and detergent poses significant health risks and economic losses. Conventional laboratory-based detection methods are accurate but expensive, time-consuming, and unsuitable for real-time or on-site testing, particularly in rural areas and small dairy collection centers.
The proposed system overcomes these limitations by integrating an Arduino UNO, ESP8266 Wi-Fi module, pH, conductivity, and temperature sensors, and a Random Forest machine learning model. Sensor data are collected and transmitted wirelessly to a backend server, where the ML model classifies milk samples into four categories: Pure, Watered, Detergent, and Urea-adulterated. The results are displayed instantly on a 16×2 LCD and a React.js web dashboard, while all measurements are automatically stored in a MongoDB database for historical analysis.
The system architecture consists of four layers: the hardware sensing layer, a Node.js/Express.js backend server, a Python Flask ML service, and a React.js frontend dashboard. The Arduino continuously acquires sensor readings, transmits them to the server, retrieves the classification results, and displays them locally. The dashboard provides real-time monitoring, historical records, and a "Test Now" feature for on-demand testing.
The Random Forest classifier, trained on a dataset of 400 samples representing four adulteration classes, achieved a cross-validation F1-macro accuracy of 99.25% (±1.51%), demonstrating excellent classification performance. Functional, integration, and unit testing confirmed reliable communication among all system components and accurate sensor operation. Results are generated in less than 10 seconds, significantly reducing detection time compared with conventional laboratory methods.
Conclusion
This paper presented a Smart Milk Adulteration & Dairy Fraud Detector that combines low-cost IoT hardware with machine learning for real-time dairy fraud detection. The system integrates an Arduino UNO with pH, conductivity, and temperature sensors, a Node.js/Express.js backend, a Flask-based Random Forest ML service, a MongoDB database, and a React.js dashboard, achieving 99.25% F1-macro accuracy at a hardware cost under ?4,000.
Future work includes retraining the model on real laboratory-collected samples across diverse seasons and regions, adding spoiled/curdled milk and additional adulterant detection (starch, salt, formalin), integrating WhatsApp/Telegram alerts, adding a standalone physical trigger button, and deploying the system to the cloud (Render and Vercel) with a companion mobile application for field inspectors.
References
[1] Sharma, R., & Rajput, Y. S., \"Detection of adulteration in milk -- A review,\" Indian Journal of Dairy Science, vol. 67, no. 3, pp. 1--10, 2014.
[2] Patel, S., & Sinha, A., \"IoT based milk quality monitoring system using sensors,\" Int. J. Eng. Research & Technology (IJERT), vol. 8, no. 5, pp. 112--116, 2019.
[3] Naila, A., Flint, S., Fletcher, G., Bremer, P., & Meerdink, G., \"Chemical indicators of hydrolytic rancidity in milk,\" Journal of Food Science, vol. 75, no. 6, pp. 105--111, 2010.
[4] Breiman, L., \"Random Forests,\" Machine Learning, vol. 45, no. 1, pp. 5--32, 2001.
[5] Pedregosa, F., et al., \"Scikit-learn: Machine Learning in Python,\" Journal of Machine Learning Research, vol. 12, pp. 2825--2830, 2011.
[6] Arduino, \"Arduino UNO Reference,\" 2024. [Online]. Available: https://docs.arduino.cc
[7] Espressif Systems, \"ESP8266 AT Instruction Set,\" 2024. [Online]. Available: https://www.espressif.com
[8] MongoDB, \"MongoDB Manual,\" 2024. [Online]. Available: https://www.mongodb.com/docs/manual
[9] React, \"React Documentation,\" 2024. [Online]. Available: https://react.dev
[10] FSSAI, \"Milk and Milk Products Standards,\" Food Safety and Standards Authority of India, 2023. [Online]. Available: https://www.fssai.gov.in