Course Content
IoT Engineering Course using ESP32 with 12 Real-World Projects

🗑Smart Automatic Dustbin

🎯 Objective of This Project

The goal of this project is to build a Smart Automatic Dustbin that:

  1. Opens automatically when a hand is detected

  2. Detects whether the dustbin is full or not

  3. Works without touching the lid (Hygienic System)

This project uses:

  • Distance measurement

  • Servo motor control

  • ESP32 microcontroller logic


🌍 Real-World Application

  • Smart homes

  • Hospitals

  • Smart city waste management

  • Public places (malls, railway stations)

  • IoT-based garbage monitoring systems


🧩 Components Used in This Project


1️⃣ ESP32 Development Board

🔹 About ESP32

The ESP32 is a powerful microcontroller with:

  • Built-in WiFi

  • Built-in Bluetooth

  • Multiple GPIO pins

  • PWM support (for servo control)

🔹 Why We Use ESP32?

  • Future IoT upgrade possible

  • Fast processing

  • Ideal for smart automation projects


2️⃣ Ultrasonic Sensor (HC-SR04)

🔹 Function

Used to measure distance using sound waves.

🔹 How It Works

  1. Sends ultrasonic sound

  2. Sound reflects from object

  3. Time taken is calculated

  4. Distance is computed

🔹 In This Project

  • Sensor 1 → Detects Hand

  • Sensor 2 → Detects Garbage Level


3️⃣ Servo Motor (SG90)

🔹 Function

Rotates at specific angles (0°–180°).

🔹 In This Project

  • 0° → Lid Closed

  • 90° → Lid Open


4️⃣ Other Required Items

  • Breadboard

  • Jumper wires

  • External 5V supply (recommended)

  • Dustbin body

  • Mounting support for servo


🔌 Circuit Diagram & Connections

📌 Pin Configuration

🔹 Ultrasonic Sensor 1 (Hand Detection)

Sensor Pin ESP32 Pin
VCC 5V
GND GND
TRIG GPIO 5
ECHO GPIO 18

🔹 Ultrasonic Sensor 2 (Garbage Level)

Sensor Pin ESP32 Pin
VCC 5V
GND GND
TRIG GPIO 17
ECHO GPIO 16

🔹 Servo Motor

Servo Wire ESP32 Pin
Red 5V (External recommended)
Brown GND
Orange GPIO 13

⚠ Important: Connect ESP32 GND and Servo GND together.


🔧 Setup Guide (Step-by-Step)

Step 1 – Mount Servo on Lid

  • Fix servo motor near hinge area

  • Connect servo arm to lid using plastic rod

Step 2 – Install Ultrasonic Sensor 1

  • Place outside front of dustbin

  • Facing outward to detect hand

Step 3 – Install Ultrasonic Sensor 2

  • Place inside top of dustbin

  • Facing downward toward garbage

Step 4 – Make Circuit Connections

  • Connect sensors to ESP32

  • Double-check VCC & GND

  • Avoid loose connections

Step 5 – Power On & Test


⚙ Working Principle Summary

  1. Hand comes near dustbin

  2. Ultrasonic sensor detects object

  3. ESP32 processes distance

  4. Servo rotates and opens lid

  5. After delay → lid closes

  6. Second sensor continuously monitors garbage level

  7. If garbage reaches threshold → “Dustbin Full”

Scroll to Top