Food freshness is a critical factor influencing public health, food safety, and the reduction of food waste across domestic, commercial, and industrial environments. Traditional freshness assessment methods based on visual inspection, odor perception, and expiration labels are often subjective, inconsistent, and incapable of detecting early stages of spoilage. This study presents a Real-Time Food Freshness Detector that integrates MQ-series gas sensors, a DHT11 temperature and humidity sensor, an ESP32 microcontroller, and Machine Learning techniques for intelligent food quality monitoring. The system continuously measures volatile organic compounds (VOCs), ammonia, ethanol, and environmental parameters emitted during food degradation. Sensor readings undergo preprocessing, noise filtering, normalization, and feature extraction before being analyzed using a Random Forest-based prediction model. Freshness levels are estimated as a percentage and categorized into Fresh, Near-Spoilage, and Spoiled conditions. Real-time data transmission to an IoT dashboard enables remote monitoring, graphical visualization, historical logging, and automated spoilage alerts. Experimental evaluation demonstrates high prediction accuracy, low latency, and reliable performance across multiple food categories. The proposed system provides a cost-effective, scalable, and intelligent solution for proactive food quality assessment and spoilage prevention.
Introduction
The study presents a Real-Time Food Freshness Detection System that uses IoT, gas sensors, and Machine Learning to monitor food quality and detect spoilage before visible signs appear. Food spoilage causes significant economic losses, environmental impacts, and health risks, while traditional methods based on appearance, smell, texture, or expiry dates are often inaccurate. During decomposition, food releases gases such as volatile organic compounds (VOCs), ammonia, and ethanol, which can be measured to assess freshness.
The proposed system integrates MQ-series gas sensors, a DHT11 temperature-humidity sensor, and an ESP32 microcontroller to continuously collect data related to food degradation. The ESP32 performs data acquisition, preprocessing, filtering, and wireless communication. A Machine Learning model (Random Forest) analyzes gas concentrations and environmental conditions to estimate freshness percentage and classify food as Fresh, Near-Spoilage, or Spoiled. Results are displayed on an IoT dashboard that provides real-time monitoring, historical trend analysis, and spoilage alerts.
The literature review highlights various food freshness monitoring approaches, including IoT-based systems, machine learning, deep learning, electronic noses, wireless sensor networks, and smart packaging technologies. Previous studies demonstrated that combining gas sensors with AI techniques can significantly improve freshness prediction accuracy and reduce dependence on manual inspection.
The methodology consists of six stages: sensor data acquisition, preprocessing and feature extraction, machine learning model development, ESP32-based edge processing and communication, dashboard visualization, and automated alert generation. Gas sensors detect spoilage-related emissions, while temperature and humidity data help compensate for environmental effects. Sensor readings are filtered and normalized before being analyzed by the machine learning model. The ESP32 transmits processed data to a cloud-based dashboard, enabling remote monitoring and decision-making.
The experimental prototype includes an ESP32, gas sensor module, DHT11 sensor, and LCD display connected to a food storage container. The system continuously monitors food conditions, predicts freshness levels, and generates alerts when spoilage thresholds are reached.
Conclusion
In this research, a Real-Time Food Freshness Detector was successfully designed and developed using MQ-series gas sensors, a DHT11 temperature and humidity sensor, an ESP32 microcontroller, and Machine Learning techniques. The system continuously monitored spoilage-related gases and environmental conditions to evaluate food quality accurately and efficiently. Sensor data was collected, preprocessed, and analyzed using a Random Forest-based prediction model to determine freshness levels and classify food conditions. The integration of IoT technology enabled real-time monitoring, visualization, and alert generation, allowing users to identify spoilage before it became visibly apparent. Experimental results demonstrated reliable performance, high prediction accuracy, and effective detection of freshness variations across different food samples. The proposed system offers a low-cost, scalable, and intelligent solution for reducing food waste, improving food safety, and supporting better storage management. Future work can focus on deploying Machine Learning models directly on the ESP32 for offline operation and faster decision making. Additional gas sensors may be incorporated to improve sensitivity and support a wider range of food products. The system can also be enhanced through mobile application integration, cloud-based analytics, advanced deep learning models, and large-scale deployment in smart kitchens, cold storage facilities, supermarkets, and food supply chain monitoring environments for practical real-world applications.
References
[1] A. Chatterjee and S. Roy, “Food Freshness Detection Using Smart Machine Learning Classification,” International Journal of Intelligent Food Monitoring Systems, vol. 12, no. 3, pp. 145-154, 2023.
[2] M. Al-Hassan and R. Abdullah, “IoT Based Meat Freshness Classification Using Deep Learning,” IEEE Access, vol. 12, pp. 25487-25498, 2024.
[3] P. Kumar and R. Sharma, “Freshness of Food Detection Using IoT and Machine Learning,” International Journal of Advanced Computing and Applications, vol. 15, no. 4, pp. 221-230, 2024.
[4] A. Xu and T. Cai, “Food Odor Recognition via Multi-step Classification,” IEEE Sensors Letters, vol. 5, no. 10, pp. 1-5, 2021.
[5] H. Beshai and G. Sarabha, “Freshness Monitoring of Packaged Vegetables Using Intelligent Sensing Technologies,” Journal of Food Engineering and Preservation, vol. 8, no. 2, pp. 88-97, 2020.
[6] D. S. Anisimov and A. A. Abramov, “Food Freshness Measurements Electronic E-Nose Based on Organic Field Effect Transistors,” Sensors, vol. 23, no. 14, pp. 1-18, 2023.
[7] D. Nag and A. Chatterjee, “Random Forest Classifier for Gas Sensor-Based Tomato Ripeness Detection,” IEEE Sensors Journal, vol. 20, no. 11, pp. 5897-5905, 2020.
[8] B. Johnson and M. Clarke, “Wireless Sensor Networks for Food Quality and Safety Monitoring,” IEEE Internet of Things Journal, vol. 8, no. 15, pp. 12045-12056, 2021.
[9] C. Lee and J. Kim, “Deep Learning Approaches for Food Quality and Freshness Assessment,” Journal of Artificial Intelligence in Agriculture, vol. 6, pp. 45-57, 2022.
[10] C. Bhuvan and K. Chinmay, “Food Freshness Detection Using IoT,” International Journal of Emerging Technologies and Innovative Research, vol. 10, no. 6, pp. 112-120, 2023.
[11] Anusha K. and Uma R., “IoT Based Food Spoilage Detection Using Machine Learning,” International Journal of Scientific Research in Computer Science and Engineering, vol. 12, no. 2, pp. 75-84, 2024.
[12] R. Chowdhury and S. Das, “Automated Food Spoilage Detection Using Deep Learning,” in Proceedings of the International Conference on Next Generation Computing and Intelligent Machines (NCIM), IEEE, pp. 210-216, 2025.