A comprehensive automated waste sorting system that uses computer vision, machine learning, and a servo mechanism to sort waste items into recycling and garbage. The system includes a web analytics dashboard and a database for tracking sorting history.
- Computer Vision Classification: Automatically identifies cans, recyclables, and garbage
- Automatic Sorting: Mechanically sorts items into appropriate bins using a servo-controlled platform
- Analytics Dashboard: Web interface to view statistics and sorting history
- Custom Model Training: Train your own classification model for better accuracy
- Data Tracking: Store images and sorting data for analysis
- Arduino Uno or compatible board
- High-torque servo motor (at least 15-20 kg-cm torque)
- Logitech Brio 4K webcam (or similar high-resolution camera)
- Computer with USB ports (Windows/Mac/Linux)
- 5V 3A power supply for servo
- Wood and acrylic materials for the physical platform
- Python 3.8 or newer
- TensorFlow 2.x
- OpenCV
- SQLite
- Flask (for web dashboard)
- Arduino IDE (for uploading firmware)
waste-sorting-system/
βββ arduino/ # Arduino firmware
β βββ waste_sorter_arduino.ino
βββ data/ # Data storage directory
β βββ counts.json # Counter values
β βββ sorting_data.db # SQLite database
βββ logs/ # Log files
βββ models/ # Trained models
β βββ latest_model.h5 # Latest model
β βββ class_mapping.json # Class mapping
βββ static/ # Static web files
β βββ css/
β βββ js/
β βββ img/
βββ templates/ # HTML templates
βββ training_data/ # Data for model training
β βββ can/
β βββ recycling/
β βββ garbage/
βββ app.py # Web dashboard Flask app
βββ database.py # Database module
βββ main.py # Main application
βββ train_model.py # Model training script
git clone https://github.com/BradleyNgu/cuHacking.git
cd cuHackingpip install -r requirements.txtOr manually install the following packages:
pip install tensorflow opencv-python numpy pillow pyserial flask matplotlib- Open Arduino IDE
- Load the firmware from
arduino/waste_sorter_arduino.ino - Connect your Arduino via USB
- Upload the firmware to the board
mkdir -p data logs models static/css static/js static/img templates training_data/can training_data/recycling training_data/garbage-
Wood:
- Base: 24" x 24" x 3/4" plywood
- Sides: 2x 24" x 16" x 1/4" plywood
- Back: 1x 24" x 16" x 1/4" plywood
-
Acrylic:
- Platform: 12" x 10" x 1/8" clear acrylic
- Side Rails: 2x 10" x 2" x 1/8" clear acrylic
-
Hardware:
- Metal Axle: 1/4" diameter steel rod, 14" long
- Ball Bearings: 2x flanged ball bearings for 1/4" shaft
- Mounting Brackets: 2x metal L-brackets for bearings
- Shaft Collars: 2x for securing axle
- Servo Horn: Extended servo horn (6-8")
- Screws, nuts, bolts, washers
-
Bins:
- 2x plastic bins (approximately 10" x 10" x 12")
-
Build the Frame:
- Assemble the U-shaped frame using the plywood pieces
- Secure with wood screws
- Ensure corners are square
-
Install the Pivot Mechanism:
- Mount the bearing brackets at the center height on both sides
- Insert the axle through both bearings
- Secure with shaft collars
-
Create the Tilting Platform:
- Cut the acrylic platform and side rails
- Attach side rails to the platform
- Mount platform on the axle
-
Install the Servo:
- Create a sturdy mount for the servo
- Attach the extended servo horn to the underside of the platform
- Position ~5" from the pivot point for best leverage
-
Mount the Camera:
- Create a bracket to hold the webcam above the platform
- Position it for a clear view of items
-
Connect Electronics:
- Connect the Arduino to your computer via USB
- Connect the servo to the Arduino (signal wire to pin 9)
- Connect servo power to external 5V power supply
python main.py- Select the Arduino port from the dropdown
- Select the camera from the dropdown
- Click "Connect"
For manual operation:
- Place item on the platform
- Click "Analyze Item"
- Click "Sort Item" once analysis is complete
For automatic operation:
- Check "Auto-Sort Mode"
- Place items on the platform one at a time
From the application menu:
- Go to Tools > Start Analytics Dashboard
Or start it separately:
python app.pyAccess the dashboard at http://localhost:5000
-
Collect images for each category:
- Place images in the appropriate folders under
training_data/ - Aim for at least 50-100 images per category
- Place images in the appropriate folders under
-
Launch the training dialog:
- From the main application, go to Tools > Model Training
- Set parameters and click "Start Training"
-
Restart the application to use the new model
- Ensure the correct port is selected
- Verify the Arduino has the correct firmware
- Check the USB cable connection
- Test with Tools > Test Arduino
- Verify the camera is connected
- Try a different USB port
- Test with Tools > Test Camera
- Check for other applications using the camera
- Calibrate the platform angles using the slider
- Ensure the servo has enough power (use external power supply)
- Make sure the platform surface is smooth
- Check if items are within the weight limit of the servo
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.