PlastiScan is a Plastic Identification, Sorting and Impact Analysis System. This repository contains the backend server, AI model logic, and Arduino simulated code. The frontend interacts directly with this backend.
-
Get your Kaggle API key:
- Go to kaggle.com → log in → Profile → Settings → API → Create New Token
- Move the downloaded kaggle.json to C:\Users\YOUR_NAME.kaggle\
-
Run the setup script (does everything automatically): cd backend python setup_dataset.py
-
Wait for training to complete (30–60 minutes)
-
Start the app: python app.py
-
Open frontend/login.html in your browser
-
Install Python dependencies:
cd backend pip install -r requirements.txt -
Train the AI model (do this once):
cd model python train.py(Press Enter for dummy mode, or paste Kaggle dataset path for real accuracy) Wait for "Model saved" message.
-
Run the backend server:
cd backend python app.pyServer starts at http://127.0.0.1:5000
-
Open the frontend:
- Open
frontend/login.htmlin your browser - Login with any username and password
- You will see the dashboard
- Open
-
Start detection:
- Click "Detection" in sidebar
- Click "START DETECTION"
- Hold a plastic item in front of webcam
- System will identify and classify it
- Go to Wokwi and create a free account
- Click "New Project" → Select "Arduino Uno"
- Click the "sketch.ino" tab → Select all → Delete → Paste contents of
arduino/sketch.ino - Click the "diagram.json" tab → Select all → Delete → Paste contents of
arduino/diagram.json - Click the green ▶ Play button to start simulation
- LCD should show "PlastiScan" and "Ready..."
- In the Serial Monitor at the bottom, type
SORT:1and press Enter - You should see LED 1 light up, servo move, LCD update to "PET"
- Simulator is now ready. When your Python app runs, it connects here automatically.
| Method | Route | Description |
|---|---|---|
| GET | /stats |
Plastic counts and totals |
| GET | /detections |
All detections ordered latest first |
| GET | /analytics |
Environmental impact metrics |
| POST | /control/start |
Start webcam detection |
| POST | /control/stop |
Stop webcam detection |
| GET | /video_feed |
Live MJPEG webcam stream |
Parts needed:
- Arduino Uno board (~₹600)
- 1x Servo motor SG90 (~₹150)
- 5x LEDs different colors (~₹50)
- 5x 220Ω resistors (~₹20)
- Jumper wires (~₹100)
- Small cardboard box (free)
- USB cable for Arduino
Wiring:
- Servo signal wire → Arduino pin 9 (red wire = 5V, brown wire = GND)
- LED 1 (PET) → pin 2 → 220Ω resistor → GND
- LED 2 (HDPE) → pin 3 → 220Ω resistor → GND
- LED 3 (PVC) → pin 4 → 220Ω resistor → GND
- LED 4 (LDPE) → pin 5 → 220Ω resistor → GND
- LED 5 (PP) → pin 6 → 220Ω resistor → GND
- LCD SDA → Arduino A4
- LCD SCL → Arduino A5
- LCD VCC → 5V, GND → GND
Physical setup:
- Take a cardboard box
- Label 5 sections on it: PET | HDPE | PVC | LDPE | PP
- Mount the servo in the center with a pointer/arrow attached to the shaft
- Place one LED above each labeled section
- When sorted, servo points to the correct section and that LED lights up
- Connect Arduino to laptop via USB
- In
backend/serial_comm.py, set the correct COM port (check Device Manager on Windows)
Uploading code to real Arduino:
- Download Arduino IDE from https://www.arduino.cc/en/software
- Open
arduino/sketch.ino - Select board: Tools → Board → Arduino Uno
- Select port: Tools → Port → COM (your port number)
- Click Upload button