Smart Dust Bin: Automatic Wet and Dry Trash Sorting

Smart Dust Bin: Automatic Wet and Dry Trash Sorting

This project teaches students how to build a Smart Dust Bin using Arduino, which can automatically detect trash, identify whether it is wet or dry, and direct it to the correct compartment. It integrates an ultrasonic sensor, soil moisture sensor, and servo motor to create a fully functional, automated bin.


Project Overview

The smart dust bin system works as follows:

  1. Trash Detection
    • An ultrasonic sensor senses when trash is near the lid.
  2. Trash Type Detection
    • A soil moisture sensor checks whether the trash is wet or dry.
  3. Automatic Sorting
    • A servo motor opens the lid in the correct direction:
      • Left → Dry trash
      • Right → Wet trash
  4. Return Lid
    • After the trash is deposited, the servo returns the lid to the center.

This project introduces students to Arduino programming, sensors, and actuator control, while encouraging practical applications in environmental management.


Components Required

ComponentQuantityNotes
Arduino Uno1Can also use Nano or Mega
HC-SR04 Ultrasonic Sensor1Measures distance to trash
Analog Soil Moisture Sensor1Detects wet/dry trash
9G Servo Motor1Controls lid movement
Jumper Wires~10Male-to-female recommended
Breadboard1Optional for easy connections
5V Power Source1Arduino 5V or external supply

Pin Connections

Arduino PinComponentFunction
D2HC-SR04 EchoReceives ultrasonic signal
D3HC-SR04 TrigSends ultrasonic pulse
D4Servo SignalControls servo lid
A3Soil Moisture AOAnalog output for wet/dry detection
5VSensor VCCPower for sensor and servo
GNDSensor GNDCommon ground

Tip: Connect all grounds together to avoid erratic sensor readings.


Working Principle

  1. Ultrasonic Sensor
    • Sends a pulse and measures the time it takes to reflect back.
    • If an object is within 15 cm, it triggers moisture detection.
  2. Soil Moisture Sensor
    • Reads analog values:
      • Wet trash → lower analog value
      • Dry trash → higher analog value
    • Threshold (wetThreshold) separates wet and dry.
  3. Servo Motor
    • Moves to 30° for dry trash (left) and 150° for wet trash (right).
    • Waits 2 seconds for trash to fall, then returns to 90° (center).

Full Arduino Code

#include <Arduino.h>
#include <NewPing.h>
#include <Servo.h>

// ---------------- PIN DEFINITIONS ----------------
#define TRIG_PIN 3
#define ECHO_PIN 2
#define SERVO_PIN 4
#define SOIL_PIN A3  // Analog soil sensor pin

// ---------------- OBJECTS ----------------
NewPing ultrasonic(TRIG_PIN, ECHO_PIN, 200); // max distance 200 cm
Servo lidServo;

// ---------------- SERVO POSITIONS ----------------
int centerPos = 90;   // Lid closed
int dryPos    = 30;   // Left → Dry trash
int wetPos    = 150;  // Right → Wet trash

// ---------------- THRESHOLDS ----------------
int detectDistance = 15;   // cm, object detection range
int wetThreshold   = 500;  // adjust after testing

void setup() {
  Serial.begin(9600);

  lidServo.attach(SERVO_PIN);
  lidServo.write(centerPos); // start with lid closed

  pinMode(SOIL_PIN, INPUT);

  Serial.println("Smart Dust Bin System Started");
}

void loop() {

  // Step 1: Detect object with ultrasonic sensor
  int distance = ultrasonic.ping_cm();

  if (distance > 0 && distance <= detectDistance) {  // Trash detected

    // Step 2: Check soil moisture
    int moisture = analogRead(SOIL_PIN);

    Serial.print("Distance: ");
    Serial.print(distance);
    Serial.print(" cm | Moisture: ");
    Serial.println(moisture);

    // Step 3: Decide wet or dry and move servo
    if (moisture < wetThreshold) {
      // Wet trash → Right
      Serial.println("WET TRASH → Moving servo RIGHT");
      lidServo.write(wetPos);
    } else {
      // Dry trash → Left
      Serial.println("DRY TRASH → Moving servo LEFT");
      lidServo.write(dryPos);
    }

    // Step 4: Keep lid open for trash to fall
    delay(2000);

    // Step 5: Return lid to center
    lidServo.write(centerPos);
    delay(1000);
  }

  delay(300);  // Small delay before next reading
}

Testing and Calibration

  1. Ultrasonic Sensor
    • Place your hand near the sensor.
    • Serial monitor should display the distance.
  2. Soil Moisture Sensor
    • Place in dry trash → note analog value
    • Place in wet trash → note analog value
    • Adjust wetThreshold in code according to readings.
  3. Servo Motor
    • Ensure it moves smoothly left for dry and right for wet trash.
    • Adjust dryPos and wetPos if lid doesn’t align with compartments.

Tips for Students

  • Keep sensor pins clean and dry for accurate readings.
  • Use external power for servo if it jitters.
  • Test with different types of trash to ensure reliability.
  • Optionally, add LED indicators to show wet/dry trash.

Learning Outcomes

Students who complete this project will:

  • Understand how to integrate multiple sensors with Arduino.
  • Learn to control servo motors programmatically.
  • Gain experience building smart mechatronic systems.
  • Understand practical applications in waste management automation.

 

Share your love
EMMANUEL ADU DONKOR
EMMANUEL ADU DONKOR

Am Emmanuel ADU Donkor CEO of LEARN STEM AFRICA

Articles: 72