An Edge AI-powered waste classification system using ESP32-CAM with on-device machine learning inference. Features a retro-styled Arcade dashboard for real-time monitoring with live video streaming and prediction visualization.
🎮 Retro Arcade-style Dashboard with live camera feed and real-time predictions
[Add your dashboard screenshot here]
- 9 Waste Categories: Battery, Biological, Cardboard, Clothes, Glass, Metal, Paper, Plastic, Shoe
- On-Device Inference: ML model runs directly on ESP32-CAM (no cloud required)
- 60% Confidence Threshold: Only high-confidence predictions are reported
- 3-Second Inference Interval: Balanced between responsiveness and performance
- MJPEG Stream: Real-time video from ESP32-CAM at 320x240
- Snapshot Endpoint: On-demand image capture
- Low Latency: Direct camera-to-dashboard streaming
- Retro Gaming Aesthetic: CRT scanline effects, neon colors, pixel-style fonts
- Live Camera Feed: Embedded video stream with overlay
- Real-time Predictions: Animated category display with confidence bars
- Statistics Panel: Total counts, category distribution, session stats
- Prediction History: Color-coded scrolling list of recent detections
- Connection Status: Visual indicators for ESP32 and stream connectivity
- WiFi Auto-Reconnection: Robust connectivity handling
- HTTP API: RESTful endpoints for predictions and status
- CSV Logging: Automatic prediction logging for analysis
- Serial Commands: Runtime control via serial monitor
- Status LED: Visual feedback on ESP32-CAM
┌─────────────────────────────────────────────────────────────────┐
│ ESP32-CAM │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Camera │→ │ Edge AI │→ │ Async Web Server │ │
│ │ OV2640 │ │ Inference │ │ - /stream (MJPEG) │ │
│ └─────────────┘ └─────────────┘ │ - /snapshot (JPEG) │ │
│ │ - /status (JSON) │ │
│ └───────────┬─────────────┘ │
└────────────────────────────────────────────────┼────────────────┘
│
WiFi Network │
│
┌────────────────────────────────────────────────┼────────────────┐
│ Arcade Dashboard (Python) │ │
│ ┌─────────────────┐ ┌───────────────────────▼──────────────┐ │
│ │ HTTP Server │ │ Video Thread │ │
│ │ (Port 5000) │ │ - MJPEG Stream Consumer │ │
│ │ - Predictions │ │ - Frame Queue Management │ │
│ └────────┬────────┘ └──────────────────────────────────────┘ │
│ │ │
│ ┌────────▼────────────────────────────────────────────────┐ │
│ │ Arcade Game Window │ │
│ │ - Live Video Panel - Stats Panel │ │
│ │ - Prediction Display - History List │ │
│ │ - CRT Effects - Connection Status │ │
│ └──────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
| Component | Requirement |
|---|---|
| Hardware | ESP32-CAM (AI-Thinker), USB-to-Serial adapter |
| Software | Python 3.8+, PlatformIO (VS Code extension) |
| Network | 2.4GHz WiFi (ESP32 doesn't support 5GHz) |
git clone https://github.com/SarangPratap/Waste_Classification.git
cd Waste_ClassificationEdit WiFi and backend settings in src/main.cpp:
#define WIFI_SSID "Your_WiFi_Name"
#define WIFI_PASSWORD "Your_WiFi_Password"
#define BACKEND_HOST "192.168.1.100" // Your PC's IP address
#define BACKEND_PORT 5000# Using PlatformIO CLI
pio run --target upload
# Monitor serial output (115200 baud)
pio device monitor -b 115200Note: After uploading, press the reset button on your ESP32-CAM.
cd dashboard
pip install -r requirements_arcade.txtEdit dashboard/config.json:
{
"esp32_ip": "YOUR_ESP32_IP",
"stream_port": 80,
"http_port": 5000,
"confidence_threshold": 0.6,
"window_width": 1400,
"window_height": 900,
"enable_scanlines": true,
"max_history": 20
}Tip: Find ESP32's IP from the Serial Monitor output after WiFi connects.
cd dashboard
python arcade_dashboard.py🎉 Done! The dashboard will open with live video and predictions.
| Category | Icon | Color | Examples |
|---|---|---|---|
| Battery | 🔋 | Gold | AA/AAA batteries, power cells, lithium batteries |
| Biological | 🍎 | Lime Green | Food waste, fruit peels, organic matter |
| Cardboard | 📦 | Brown | Boxes, packaging, corrugated cardboard |
| Clothes | 👕 | Purple | Textiles, fabrics, garments |
| Glass | 🫙 | Turquoise | Bottles, jars, glass containers |
| Metal | 🔩 | Gray | Cans, foil, metal objects, screws |
| Paper | 📄 | Sky Blue | Documents, newspapers, notebooks |
| Plastic | 🍾 | Blue | Bottles, containers, plastic bags |
| Shoe | 👟 | Orange | Footwear, sneakers, sandals |
Waste_Classification/
├── 📄 platformio.ini # PlatformIO build configuration
├── 📄 README.md # This file
│
├── 📂 src/
│ └── main.cpp # ESP32-CAM firmware (WiFi, Camera, ML, Web Server)
│
├── 📂 include/
│ ├── config.h # Hardware configuration
│ └── camera_pins.h # ESP32-CAM pin definitions
│
├── 📂 lib/
│ └── Waste_classification_inferencing/ # Edge Impulse ML model
│ ├── src/
│ │ ├── edge-impulse-sdk/ # EI SDK
│ │ ├── model-parameters/ # Model config
│ │ └── tflite-model/ # TensorFlow Lite model
│ └── examples/ # Platform examples
│
├── 📂 dashboard/
│ ├── arcade_dashboard.py # Python Arcade dashboard application
│ ├── config.json # Dashboard configuration
│ ├── requirements_arcade.txt # Python dependencies
│ ├── predictions_log.csv # Logged predictions (auto-generated)
│ └── dashboard.log # Application logs (auto-generated)
│
├── 📂 docs/
│ ├── SETUP.md # Detailed setup guide
│ ├── API.md # API documentation
│ ├── EDGE_IMPULSE_INTEGRATION.md # ML model integration guide
│ └── WIFI_SETUP.md # WiFi troubleshooting
│
└── 📂 test/ # Test files
| Endpoint | Method | Description |
|---|---|---|
/stream |
GET | MJPEG video stream |
/snapshot |
GET | Single JPEG image |
/status |
GET | System status (JSON) |
| Endpoint | Method | Description |
|---|---|---|
/api/prediction |
POST | Receive prediction from ESP32 |
{
"status": "running",
"wifi": true,
"ip": "192.168.1.50",
"category": "plastic",
"confidence": 0.87
}| Define | Default | Description |
|---|---|---|
WIFI_SSID |
- | Your WiFi network name |
WIFI_PASSWORD |
- | Your WiFi password |
BACKEND_HOST |
- | Dashboard PC's IP address |
BACKEND_PORT |
5000 | Dashboard HTTP port |
CONFIDENCE_THRESHOLD |
0.6 | Minimum confidence (0.0-1.0) |
INFERENCE_INTERVAL |
3000 | Time between inferences (ms) |
CAMERA_QUALITY |
12 | JPEG quality (0-63, lower=better) |
| Key | Default | Description |
|---|---|---|
esp32_ip |
- | ESP32-CAM's IP address |
stream_port |
80 | ESP32 web server port |
http_port |
5000 | Dashboard prediction server port |
confidence_threshold |
0.6 | Display threshold |
window_width |
1400 | Dashboard window width |
window_height |
900 | Dashboard window height |
enable_scanlines |
true | CRT scanline effect |
max_history |
20 | Prediction history length |
Control ESP32-CAM via Serial Monitor (115200 baud):
| Command | Description |
|---|---|
pause |
Pause ML inference |
resume |
Resume ML inference |
status |
Show system status |
reset |
Restart ESP32-CAM |
| Problem | Solution |
|---|---|
| WiFi won't connect | Verify credentials, ensure 2.4GHz network, check power supply (500mA min) |
| Camera init failed | Check PSRAM, verify pin connections, try lower quality setting |
| Brownout detected | Use better power supply, add capacitor, reduce WiFi transmit power |
| Upload fails | Connect GPIO0 to GND during upload, use shorter USB cable |
| Problem | Solution |
|---|---|
| Can't connect to stream | Verify ESP32 IP in config.json, ensure same WiFi network |
| Stream disconnects | Check WiFi signal strength, reduce inference interval |
| Window won't open | Install/update graphics drivers, check arcade installation |
| Unicode errors in logs | Windows console issue, logs still work in file |
| Problem | Solution |
|---|---|
| Predictions not received | Check BACKEND_HOST matches your PC's IP |
| High latency | Reduce CAMERA_QUALITY, increase INFERENCE_INTERVAL |
| Connection refused | Ensure dashboard is running before ESP32 sends predictions |
- ESP32-CAM (AI-Thinker module with OV2640 camera)
- USB-to-Serial Adapter (FTDI FT232RL or CP2102)
- Multi-camera support
- Cloud dashboard deployment
- Mobile app companion
- Physical sorting mechanism integration
- Voice announcements
- Advanced analytics & reporting
- Model retraining interface
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Sarang Pratap - GitHub
- Edge Impulse - ML model training and deployment
- Espressif - ESP32 platform
- PlatformIO - Development environment
- Arcade Library - Python game framework for dashboard
If you find this project useful, please give it a ⭐ on GitHub!
Found a bug? Open an issue
Made with ❤️ for a cleaner planet 🌍
Reduce • Reuse • Recycle • Classify