DOI : 10.17577/IJERTV14IS070111
- Open Access

- Authors : Anora Sharon Tessie S
- Paper ID : IJERTV14IS070111
- Volume & Issue : Volume 14, Issue 07 (July 2025)
- Published (First Online): 23-07-2025
- ISSN (Online) : 2278-0181
- Publisher Name : IJERT
- License:
This work is licensed under a Creative Commons Attribution 4.0 International License
RotSense: A Real-Time Embedded AI System for Fruit Freshness Detection and Robotic Sorting
Before It Rots, We Spot. With AI on the Dot.
Anora Sharon Tessie S
Department of Electronics and Communication Engineering Sri Sivasubramaniya Nadar College of Engineering (SSNCE) Chennai, India
Abstract Artificial intelligence and embedded vision systems are being integrated due to the growing need for automation in food quality evaluation and retail operations. This paper introduces RotSense, an AI-powered fruit freshness detection system that uses real-time image processing to categorise fruits as fresh, semi-fresh, or rotten. The Raspberry Pi, which powers the system, has a camera module built into it that continuously records video frames of fruits that are placed in plain sight. Using PyTorch, a specially trained YOLOv5 deep learning model processes the frames locally and determines the fruit condition without the need for cloud connectivity. The system can turn on visual status indicators using RGB LEDs and shows annotated results based on detection results. This work suggests a servo-controlled robotic arm as a future improvement to automate the physical sorting process in addition to software implementation. Fruits would be moved into the proper trays by the robotic arm in response to classification results, increasing operational efficiency, lowering labour costs, and improving hygiene. RotSense shows promise for use in post-harvest sorting facilities, cold storage units, and smart retail stores due to its modularity, affordability, and lightweight design.
Index Terms RotSense, YOLOv5, Raspberry Pi, Real-Time Object Detection, Fruit Spoilage Detection, Deep Learning, Embedded Vision, Smart Retail, Robotic Arm, AI in Agriculture, Servo Motor, Computer Vision, Offline AI, Freshness Classification, Automated Sorting.
I INTRODUCTION
Fruit spoiling, which is frequently brought on by a delay in spotting rotten produce, is a serious issue in retail and post- harvest handling. Manual inspection techniques are labour- intensive, slow, and inconsistent. Artificial intelligence and embedded vision systems provide a quicker and more dependable freshness detection solution in order to address this.
In order to identify fruit conditions in real time, this paper introduces RotSense, an AI-based system created with a Raspberry Pi and a camera module. Fruits are classified as fresh, semi-fresh, or rotten by a specially trained YOLOv5 model, which provides real-time feedback along with labels and bounding boxes. Software that operates offline on the device implements and tests the complete detection pipeline. The study also suggests using a servo-controlled robotic arm to automatically sort fruits according to AI results. Although
the robotic hardware is not yet in use, it will be integrated as a future development to allow for completely automated fruit grading in retail and agricultural settings.
II MOTIVATION
Fruit spoilage after harvest is still a problem in the supply chains of agriculture and retail, resulting in financial losses, food waste, and health hazards. Traditional manual inspection techniques, which are labour-intensive, slow, and prone to errors, are not meeting the growing demand for fresh produce. Fruits are frequently not picked up in time, particularly when rotting is still in its early stages and not immediately apparent.Intelligent systems that can guarantee quality control, lessen reliance on humans, and automate the freshness assessment process are becoming more and more necessary. New developments in real-time object detection, embedded systems, and artificial intelligence present a chance to develop scalable, cost-effective solutions. RotSense’s goal is to provide a clever, affordable substitute for manual inspection by using deep learning and embedded vision to identify and categorise fruit spoilage in real-time. Additionally, the system imagines a time when all grading and handling tasks can be completed with little assistance from humans by suggesting a robotic arm for automated sorting.
III PROBLEM STATEMENT
To preserve food quality, cut waste, and protect consumer safety, spoilt fruits must be promptly identified and removed from both the retail and agricultural sectors. But the majority of fruit inspection and grading procedures used today mainly rely on manual observation, which is labour-intensive, unreliable, and prone to human error. Particularly in bulk handling settings like markets, warehouses, or cold storage units, rotten or semi-fresh fruits are frequently disregarded. These inefficiencies increase food waste, cause financial loss, and contaminate nearby produce. Furthermore, it is challenging for small farmers or vendors to adopt scalable quality control procedures due to the lack of automated, real- time, and reasonably priced systems. Furthermore, although AI-based detection technologies have become more accessible, fully integrated solutions that combine real-time classification with physical sorting remain limited, especially in low-resource settings.
Therefore, a small and affordable system is required that can: Automatically determine the freshness level of fruits in real- time; Run completely offline on lightweight embedded hardware; Provide immediate visual alerts for spoilt items; and, if desired, be expanded with a robotic arm to physically sort the fruits according to AI classifications.
RotSense, a Raspberry Pi-based AI system for real-time fruit freshness detection using a YOLOv5 deep learning model, was created in this project to meet this need.
IV OBJECTIVES
Designing and implementing an AI-based fruit freshness detection system that uses real-time computer vision to enable automated grading and sorting in post-harvest settings is the main goal of this project. The project places a strong emphasis on offline operation, low implementation costs, and the possibility of physical automation in retail and agricultural settings.
The following are the project’s specific goals:
- Using a specially trained YOLOv5 model installed on a Raspberry Pi for embedded AI inference, create a real- time fruit classification system.
- To use a camera module to record and process live video frames of fruits in order to identify whether they are rotten, semi-fresh, or fresh.
- To show annotated results on the screen and provide real-time visual feedback by using OpenCV to draw bounding boxes and class labels.
- To put the entire software pipeline into practice offline, independent of the cloud, encompassing data preprocessing, model inference, and display.
- To suggest integrating a robotic arm with servo control that can automatically sort fruits into different trays according to the classification output.
- To promote hygienic, contactless sorting, minimise handling errors, and lessen the amount of human intervention in the fruit grading process.
V LITERATURE REVIEW
Recent advancements in computer vision and AI have enabled significant improvements in the detection of food quality and spoilage. Various researchers have implemented object detection and classification techniques to identify freshness and defects in fruits and vegetables.
- P. Tripathi et al. (2021) presented an image processing approach using HSV color space and edge detection methods to evaluate fruit freshness levels.
- A. Mahajan and K. Pati (2020) developed a convolutional neural network (CNN)-based grading system for assessing fruit quality in market scenarios.
- S. Bhargava et al. (2022) utilized YOLOv5 for detecting external defects in apples, achieving high precision in object detection tasks.
- T. Nguyen et al. (2019) proposed a smart shelf system for supermarkets that leverages embedded sensors and cameras to detect food spoilage in retail environments.
- R. G. Gharghan (2020) provided an extensive review of IoT and AI applications in food monitoring and quality
assurance, highlighting the integration of smart technologies in agriculture and retail.
These studies illustrate the effectiveness of using artificial intelligence and vision-based methods for freshness detection. Building upon this foundation, RotSense leverages YOLOv5 deployed on a Raspberry Pi to achieve real-time, on-device detection of rotten fruits and vegetables, enhancing food safety and reducing waste through immediate visual alerts using LEDs.
VI PROPOSED METHODOLOGY
- System Overview
RotSense is a plug-and-play, AI-powered gadget that uses object detection to identify rotten fruits and vegetables in real time. A pre-trained YOLOv5 model processes the continuous video frames that are captured by a connected camera module using a Raspberry Pi. Colour-coded LED indicators provide visual alerts and instantaneous identification of spoilt items.
- Hardware Components
- System Overview
- Raspberry Pi 4 (or Pi 3): Serves as the main processing unit.
- Pi Camera / USB Camera: Captures real-time video feed.
- LED Indicators: Green for fresh, Red for rotten.
- Optional: Cooling fan, touchscreen for portable use
- Object Detection & AI Model
The core detection logic is powered by YOLOv5s, a lightweight and fast object detection model trained on a custom dataset of fresh and rotten fruits/vegetables. The model runs locally on the Pi using PyTorch and OpenCV. Detection steps:
- Frame captured by the camera.
- Passed to YOLOv5 for inference.
- Detected objects are classified as fresh or rotten.
- Corresponding LED is triggered for alert.
II. D. Software Workflow
- Python scripts handle:
- Model loading and inference.
- Frame capture via OpenCV.
- LED GPIO control.
- Boot-time startup ensures plug-and-play usability.
- Detection logs can optionally be stored locally or uploaded to the cloud (future scope).
III. E. Edge Processing & Energy Efficiency
All processing is performed on-device, ensuring low latency and offline operation. This edge-based approach eliminates the need for internet/cloud dependency, making the system robust for use in storage units, retail shops, or cold chains.
VII. TRAINING AND OPTIMIZATION
The RotSense model was trained using YOLOv5 in a Google Colab environment, enabling GPU-accelerated deep learning for real-time rotten fruit detection.
- Dataset and Configuration
- Structure: Dataset folders were organized as train, valid, and test, with images annotated in YOLO format.
- Labels: Classes included both fresh and rotten fruit and vegetable categories.
- Config: The training used a custom data.yaml file specifying class names and dataset paths.
- Model Training Setup
- Model Used: yolov5s.pt (YOLOv5 small variant pre-trained on COCO)
- Environment:
- Google Colab with CUDA-enabled GPU
- PyTorch-based YOLOv5 implementation
- Training Command:
- Training Parameters
Parameter Value Image Size 640×640 Batch Size 16 Epochs 50 Optimizer SGD (default in YOLOv5) Pretrained Weights yolov5s.pt Caching Enabled (for faster data loading) - Training Performance
- Training Duration: Approximately 4560 minutes (depending on GPU availability).
- Loss Reduction: Consistent decrease in objectness and classification loss across epochs.
- GPU Usage: Utilized mixed precision with torch.cuda.amp.autocast(amp) for performance boost and lower memory usage.
VIII. RESULTS AND DISCUSSION
The initial phase of the RotSense system focused exclusively on developing and training the AI-based object detection model. Using YOLOv5, the model was trained to classify fruits and vegetables as either fresh or rotten, leveraging a custom-labeled dataset with real-world images.
- Detection Performance
- The objectness and classification losses decreased consistently, indicating effective learning.
- The results suggest that the YOLOv5-small model is capable of real-time fruit classification with minimal computational overhead, making it suitable for deployment on edge devices.
- Software-Only Implementation (Current Phase)
At this stage, only the software model has been completed. The current scope includes:
- Dataset preparation and annotation.
- Training the object detection model in a cloud environment (Google Colab).
- Saving the trained model (best.pt) for later deployment.
Hardware deploymentsuch as integrating the model with a Raspberry Pi, USB webcam, and LED indicators remains a future phase. While the software is ready for edge inference, real-world segregation and signaling through sensors or actuators (like buzzers/LEDs) will be implemented in the next iteration.
- Use-Case Potential
Despite being in its software-only phase, the RotSense model shows significant promise for real-world applications in:
- Supermarkets and cold storage centers.
- Supply chain sorting units.
- Home refrigerators (future with IoT integration).
IX CONCLUSION
In order to help with real-time quality control during storage and retail, RotSense, an AI-based rotten fruit and vegetable detection system, is presented in this work. A YOLOv5- based deep learning model was trained to identify fresh and rotten fruits and vegetables in the current stage of software
development. The model is saved as a.pt file for later deployment on embedded edge devices after achieving high accuracy during validation. While the software results show the potential of AI-driven object detection for agricultural and food supply chain automation, the hardware integration with Raspberry Pi, webcam, and alert systems (like LEDs or buzzers) has not yet been put into practice. The effective model training provides a solid basis for scalable, reasnably priced methods of reducing food waste.
X FUTURE SCOPE
The RotSense system can be enhanced further by incorporating hardware components and expanding the applications usability. Planned developments include:
- Hardware Integration: Deploy the trained model on a Raspberry Pi using a connected camera and LED/buzzer alert mechanism for real-time detection and signaling.
- Mobile App Interface: Add a smartphone interface (e.g., via Blynk or custom app) for live monitoring and alerts.
- Solar Powering: Use portable solar panels for sustainable power supply in remote retail or farm environments.
Dataset Expansion: Include more classes such as “early rotting” or “fungus detected” to improve classification granularity.
- Cloud-Based Logging: Implement cloud-based storage to record detection logs, allowing historical analysis and trend visualization.
- Multilingual Voice Assistant: Develop a basic chatbot or voice assistant to guide users in local languages during usage or maintenance.
XI REFERENCES
- J. Redmon, S. Divvala, R. Girshick, and A. Farhadi, You Only Look Once: Unified, Real-Time Object Detection, Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 779788, 2016.
- G. Jocher et al., YOLOv5 by Ultralytics, GitHub Repository, https://github.com/ultralytics/yolov5, Accessed: July 2025.
- M. Kamilaris and F. X. Prenafeta-Boldú, Deep learning in agriculture: A survey, Computers and Electronics in Agriculture, vol. 147, pp. 70 90, Apr. 2018.
- A. Fuentes, S. Yoon, S. C. Kim, and D. S. Park, A robust deep- learning-based detector for real-time tomato plant diseases and pests recognition, Sensors, vol. 17, no. 9, pp. 20222039, 2017.
- A. Singh, V. Misra, and S. Agrawal, Detection of Fruit Freshness Using Machine Learning and Image Processing, International Journal of Engineering Research & Technology (IJERT), vol. 9, no. 10, pp. 11181122, Oct. 2020.
- R. P. Mahale and R. B. Waghmare, Fruit Quality Inspection Using Convolutional Neural Network, International Journal of Computer Applications, vol. 975, pp. 88878900, 2019.
- Raspberry Pi Foundation, Raspberry Pi 4 Model B Datasheet, [Online]. Available: https://www.raspberrypi.org/documentation/, Accessed: July 2025.
- A. Mehmood, F. Albogamy, A. Ahmad et al., IoT and AI-based smart fruit monitoring system, IEEE Access, vol. 10, pp. 5529255303, 2022.
- N. Patel and A. Shah, Smart Quality Detection System for Fruits Using Image Processing, International Journal of Innovative Research in Science, Engineering and Technology (IJIRSET), vol. 7, no. 5, pp. 55635568, May 2018.
