Skip to content

Dhenuka06/PlastiScan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PlastiScan Backend

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.

Quick Setup (Recommended)

  1. 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\
  2. Run the setup script (does everything automatically): cd backend python setup_dataset.py

  3. Wait for training to complete (30–60 minutes)

  4. Start the app: python app.py

  5. Open frontend/login.html in your browser

Setup & Run (Step by Step)

  1. Install Python dependencies:

    cd backend
    pip install -r requirements.txt
  2. 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.

  3. Run the backend server:

    cd backend
    python app.py

    Server starts at http://127.0.0.1:5000

  4. Open the frontend:

    • Open frontend/login.html in your browser
    • Login with any username and password
    • You will see the dashboard
  5. Start detection:

    • Click "Detection" in sidebar
    • Click "START DETECTION"
    • Hold a plastic item in front of webcam
    • System will identify and classify it

Arduino Simulator Setup (Wokwi)

  1. Go to Wokwi and create a free account
  2. Click "New Project" → Select "Arduino Uno"
  3. Click the "sketch.ino" tab → Select all → Delete → Paste contents of arduino/sketch.ino
  4. Click the "diagram.json" tab → Select all → Delete → Paste contents of arduino/diagram.json
  5. Click the green ▶ Play button to start simulation
  6. LCD should show "PlastiScan" and "Ready..."
  7. In the Serial Monitor at the bottom, type SORT:1 and press Enter
  8. You should see LED 1 light up, servo move, LCD update to "PET"
  9. Simulator is now ready. When your Python app runs, it connects here automatically.

API Reference

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

Hardware Assembly Guide (Physical)

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors