An automated waste segregation system developed during SPARC (St. Xavier's Prototyping, Automation and Robotics Club) Hackathon that uses ESP32, ultrasonic sensors, and servo motors to classify and sort waste items into appropriate bins.
The Garbage Classifier is a comprehensive AI-powered waste segregation system that combines computer vision, machine learning, and robotics to automatically classify and sort waste items. The complete system consists of three main components:
The system creates a seamless workflow where users simply take a photo of waste items, the AI model classifies them as Bio or Non-Bio, and the ESP32 automatically sorts them into appropriate bins using servo-controlled mechanisms.
The system integrates multiple technologies to create a seamless waste classification experience:
The complete system implements a three-tier architecture with the following workflow:
#include <ESP32Servo.h>
#include <WiFi.h>
#include <HTTPClient.h>
// Wi-Fi credentials
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
// URL to fetch the value
const String url = "http://172.16.2.88:8000/display.txt";
// Servo setup
Servo myServo;
const int servoPin = 13;
// Ultrasonic sensor pins
#define TRIG_PIN 4
#define ECHO_PIN 2
void setup() {
Serial.begin(115200);
// Servo initialization
myServo.attach(servoPin);
myServo.write(90);
Serial.println("Servo initialized to 90 degrees");
// Ultrasonic sensor pin setup
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
// Wi-Fi connection
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected");
Serial.print("ESP32 IP: ");
Serial.println(WiFi.localIP());
}
float readDistanceCM() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
long duration = pulseIn(ECHO_PIN, HIGH, 30000);
float distance = duration * 0.034 / 2;
if (duration == 0) {
Serial.println("Ultrasonic timeout");
return 999;
}
return distance;
}
void loop() {
float distance = readDistanceCM();
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
if (distance < 50.0) {
if (WiFi.status() == WL_CONNECTED) {
WiFiClient client;
HTTPClient http;
http.begin(client, url);
http.addHeader("User-Agent", "ESP32");
int httpResponseCode = http.GET();
if (httpResponseCode == 200) {
String value = http.getString();
value.trim();
Serial.print("Received value: ");
Serial.println(value);
if (value == "0") {
myServo.write(70);
Serial.println("Servo set to 0 degrees");
delay(1000);
myServo.write(90);
} else if (value == "1") {
myServo.write(150);
Serial.println("Servo set to 180 degrees");
delay(1000);
myServo.write(90);
} else {
Serial.println("Invalid value in text file");
}
} else {
Serial.print("HTTP error: ");
Serial.println(httpResponseCode);
}
http.end();
} else {
Serial.println("WiFi not connected.");
}
delay(2000);
}
delay(500);
}
The system uses a combination of sensors and actuators to create an automated waste classification system:
Live demonstration at SPARC Fest 2025 showing the automated waste segregation system in action
Team "Built diff" receiving the SPARC Fest 2025 Category Winner award for Environmental Sustainability
The project was developed during the SPARC Fest 2025 event with limited time constraints:
The Garbage Classifier project successfully demonstrated the potential of AI, IoT, and robotics in environmental sustainability. The complete system was able to: