An autonomous dual-gate waste sorting system powered by YOLOv11, Raspberry Pi, and 8 precision servos.
Designed to identify and sort waste into “Recyclable” or “Landfill” bins in real time.
The Automated YOLOv11 Waste Sorter combines AI-based object detection, embedded hardware control, and mechanical automation.
A custom YOLOv11 model detects items through the Pi Camera, and a Finite State Machine (FSM) controls servo-driven gates and bins to sort waste automatically.
This system ensures continuous, one-by-one item processing using two alternating gates for uninterrupted operation.
- Detects and classifies waste instantly using a custom-trained YOLOv11 model.
- Powered by Ultralytics YOLOv11 and optimized for Raspberry Pi.
- Two alternating gates (
Gate 1,Gate 2) ensure non-stop item flow. - While one gate is closed and detecting, the other prepares for the next item.
| Component | Servos | Purpose |
|---|---|---|
| ♻️ Recyclable Bin | 2 | Balanced lid lift |
| 🗑️ Landfill Bin | 2 | Balanced lid lift |
| 🚪 Gate 1 | 2 | Hold and release items |
| 🚪 Gate 2 | 2 | Hold and release items |
| State | Description |
|---|---|
| CLOSED | Detect & classify object |
| WAITING_CLEAR | Wait for object to leave view |
| OPENING | Open active gate for next item |
| OPEN | Hold open, close, and toggle gate |
- Uses
RPi.GPIOfor precise hardware control. - Uses
picamera2for efficient image streaming. - Lightweight and fully compatible with Raspberry Pi 4/5.
| Component | Quantity | Description |
|---|---|---|
| Raspberry Pi 5 | 1 | Main controller |
| Pi Camera Module | 1 | For image detection |
| SG90 Servo Motors | 8 | 4 for bins, 4 for gates |
| Ultrasonic Sensor HC-SR04 | 1 | Optional object sensing |
| Jumper Wires | — | GPIO connections |
| Wood, Formex, Cardboad | - | Prototype |
| Component | Servo | GPIO Pin |
|---|---|---|
| ♻️ Recyclable Bin | Servo 1 | GPIO 17 |
| Servo 2 | GPIO 5 | |
| 🗑️ Landfill Bin | Servo 1 | GPIO 18 |
| Servo 2 | GPIO 6 | |
| 🚪 Gate 1 | Servo A | GPIO 19 |
| Servo B | GPIO 16 | |
| 🚪 Gate 2 | Servo A | GPIO 22 |
| Servo B | GPIO 23 |
git clone https://github.com/Rie109/Hackathon.git
cd Hackathonpip install ultralytics opencv-python-headless RPi.GPIO picamera2If picamera2 fails to install:
sudo apt update
sudo apt install -y python3-picamera2Place your trained model file best.pt at:
/home/harry/Hackathon/best.pt
Or modify this line in the script:
MODEL_PATH = '/your/path/to/best.pt'Execute the main script:
python waste_sorter.pyYou’ll see this startup menu:
RASPBERRY PI WASTE DETECTION SYSTEM - BALANCED BIN VERSION
===========================================================
1. Run detection (with display)
2. Run detection (headless - no display)
3. Run detection + servo control (with display)
4. Run detection + servo control (headless)
0. Exit
💡 Tip:
- Use 1 or 2 to test camera and detection accuracy.
- Use 3 or 4 for full sorting system with all 8 servos.
Tweak angles and timings at the top of the script:
SERVO_CLOSED_ANGLE = 90
SERVO_OPEN_ANGLE = 45
GATE_CLOSED_ANGLE = 90
GATE_OPEN_ANGLE = 45
bin_open_duration = 2.5 # seconds
clear_wait_time = 1.0 # seconds- Current version uses
time.sleep()in servo control, causing short camera freeze periods. - Next iteration: implement non-blocking timers for smoother detection.
- Future goal: add more waste categories and adaptive gate control for improved accuracy.
(Insert a GIF or image of the system in action here)
Sample Output:
[INFO] Gate 1 - Object Detected: ♻️ Recyclable
[INFO] Opening Recyclable Bin...
[INFO] Item Sorted Successfully!
[INFO] Switching to Gate 2...
| Name | Role | Focus Area |
|---|---|---|
| Harry Nguyen | Developer | Camera Installation, YOLOv11 Integration |
| Tran Phuoc Dung Dang | Developer | State Machine, Servo Installation |
| Huy Le | Designer | Prototype Design, Testing |
| Jayden Dong | Full-stack Developer | Waste-Tracking App Development |
Bochkovskiy, A., Wang, C. Y., & Liao, H. Y. M. (2024). Ultralytics YOLO11: Redefine what’s possible in AI [Software]. Ultralytics. Retrieved from https://docs.ultralytics.com/models/yolo11/ :contentReference[oaicite:0]{index=0}
Dwyer, B., Nelson, J., Hansen, T., et al. (2025). Roboflow (Version 1.0) [Software]. Retrieved from https://roboflow.com/ :contentReference[oaicite:1]{index=1}
Bradski, G. (2000). “The OpenCV Library.” Dr. Dobb’s Journal of Software Tools. :contentReference[oaicite:2]{index=2}
Croston, B. (n.d.). RPi.GPIO: A Python module to control the GPIO on a Raspberry Pi [Software]. Retrieved from https://sourceforge.net/p/raspberry-gpio-python/wiki/Examples/ :contentReference[oaicite:3]{index=3}
Raspberry Pi Ltd. (n.d.). Picamera2: The libcamera-based Python interface for Raspberry Pi cameras [Software]. Retrieved from https://github.com/raspberrypi/picamera2 :contentReference[oaicite:4]{index=4}