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 19
ECHO GPIO 04

πŸ”Ή 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