An ESP32-based Smart Dustbin that provides automatic lid control, hand detection, waste-level monitoring, LED status indication, and buzzer alerts.
The project is developed using C++, Arduino Framework, and PlatformIO, with the complete circuit tested and simulated using Wokwi.
The Smart Dustbin Embedded System is designed to make waste disposal more convenient and hygienic.
The system uses two ultrasonic sensors:
- One sensor detects a hand or object near the dustbin.
- The second sensor monitors the waste level inside the dustbin.
When a hand is detected within the configured distance, the servo motor automatically opens the lid. After a short delay, the lid closes automatically.
The waste-level sensor continuously measures the distance between the sensor and the waste. The system calculates the approximate fill percentage and indicates the bin status using LEDs and a buzzer.
- 🖐️ Contactless hand detection
- 🚪 Automatic dustbin lid
- 📏 Waste-level monitoring
- 📊 Fill percentage calculation
- 🟢 Normal-status LED
- 🔴 Warning/full-status LED
- 🔊 Full-bin buzzer alert
- 📟 Serial Monitor status output
- ⚡ ESP32-based control
- 🧪 Wokwi simulation
- 🔧 PlatformIO project
- 📚 Complete project documentation
| Technology | Purpose |
|---|---|
| ESP32 | Main microcontroller |
| C++ | Firmware programming |
| Arduino Framework | Embedded development |
| PlatformIO | Build and project management |
| Wokwi | Circuit simulation |
| ESP32Servo | Servo motor control |
| HC-SR04 | Ultrasonic distance measurement |
- ESP32 DevKit
- 2 × HC-SR04 Ultrasonic Sensors
- Servo Motor
- Green LED
- Red LED
- Buzzer
| Component | ESP32 GPIO |
|---|---|
| Servo PWM | GPIO 18 |
| Hand Sensor TRIG | GPIO 23 |
| Hand Sensor ECHO | GPIO 22 |
| Level Sensor TRIG | GPIO 5 |
| Level Sensor ECHO | GPIO 19 |
| Green LED | GPIO 25 |
| Red LED | GPIO 26 |
| Buzzer | GPIO 27 |
The first HC-SR04 sensor detects a hand or object near the dustbin.
Configured threshold:
20 cm
When the distance is 20 cm or less:
Hand Detected
↓
Servo Opens
↓
Lid Opens
↓
Wait 3 Seconds
↓
Servo Closes
↓
Lid Closes
The second HC-SR04 sensor measures the distance between the top of the bin and the waste.
Configured bin height:
30 cm
The filled height is calculated using:
Filled Height = Bin Height - Sensor Distance
The fill percentage is calculated using:
Fill Percentage =
(Filled Height / Bin Height) × 100
| Fill Level | Green LED | Red LED | Buzzer | Status |
|---|---|---|---|---|
| 0–74% | ON | OFF | OFF | Normal |
| 75–89% | ON | ON | OFF | Warning |
| 90–100% | OFF | ON | ON | Full |
SMART DUSTBIN
|
ESP32
|
+--------------+--------------+
| |
v v
Hand Detection Waste Monitoring
HC-SR04 HC-SR04
| |
v v
Hand Distance Waste Distance
| |
v v
Hand Detected Fill Percentage
| |
v v
Servo Motor Status Decision
| |
v +--------+--------+
Automatic | | |
Lid v v v
Normal Warning Full
| | |
v v v
Green Green+Red Red+Buzzer
LED LED
START
|
v
Initialize ESP32
|
v
Read Hand Sensor
|
v
Hand <= 20 cm?
|
+---- YES ----> Open Lid
| |
| v
| Wait 3 sec
| |
| v
| Close Lid
|
v
Read Waste-Level Sensor
|
v
Calculate Fill %
|
v
Determine Bin Status
|
+---- Normal ----> Green LED
|
+---- Warning ---> Green + Red LED
|
+---- Full ------> Red LED + Buzzer
|
v
Repeat
Smart-Dustbin-Embedded-System/
│
├── circuit_diagram/
│ └── README.md
│
├── docs/
│ ├── architecture.md
│ └── testing.md
│
├── include/
│ └── config.h
│
├── reports/
│ └── project_report.md
│
├── screenshots/
│ ├── 01-complete-circuit.png
│ ├── 02-hand-detection.png
│ ├── 03-lid-open.png
│ ├── 04-normal-level.png
│ ├── 05-warning-level.png
│ ├── 06-full-bin-alert.png
│ └── 07-serial-monitor.png
│
├── src/
│ └── main.cpp
│
├── test/
│ └── test_smart_dustbin.md
│
├── diagram.json
├── platformio.ini
├── wokwi.toml
├── README.md
├── LICENSE
└── .gitignore
The system was tested in stages before complete integration.
- ESP32
- Servo motor
- Hand-detection sensor
- Waste-level sensor
- Green LED
- Red LED
- Buzzer
- Serial Monitor
| Test | Result |
|---|---|
| PlatformIO Build | ✅ PASS |
| Servo Operation | ✅ PASS |
| Hand Detection | ✅ PASS |
| Automatic Lid | ✅ PASS |
| Waste-Level Detection | ✅ PASS |
| Fill Calculation | ✅ PASS |
| Green LED | ✅ PASS |
| Red LED | ✅ PASS |
| Buzzer | ✅ PASS |
| Complete Integration | ✅ PASS |
The project was successfully tested using Wokwi.
The simulation includes:
ESP32
├── Hand Detection HC-SR04
├── Waste-Level HC-SR04
├── Servo Motor
├── Green LED
├── Red LED
└── Buzzer
The circuit configuration is stored in:
diagram.json
The Wokwi configuration is stored in:
wokwi.toml
Install:
- Visual Studio Code
- PlatformIO
- Wokwi
git clone https://github.com/VaishnavaDevi-R/Smart-Dustbin-Embedded-System.gitMove into the project:
cd Smart-Dustbin-Embedded-Systempio runA successful build should display:
=============================== [SUCCESS] ===============================
Open the project in Visual Studio Code with the Wokwi extension installed.
Build the firmware first:
pio runThen start the Wokwi simulation using the Wokwi controls in Visual Studio Code.
The main configuration values are stored in:
include/config.h
Important settings include:
Hand Detection Distance : 20 cm
Bin Height : 30 cm
Warning Threshold : 75%
Full Threshold : 90%
Servo Closed Angle : 0°
Servo Open Angle : 90°
Lid Open Time : 3 seconds
Serial Baud Rate : 115200
The system uses:
115200 baud
The Serial Monitor can be used to observe sensor and system information during testing.
Example information includes:
Hand Distance
Waste Distance
Fill Level
Lid Status
Bin Status
Detailed documentation is available in the following folders:
docs/architecture.md
Contains:
- System architecture
- GPIO mapping
- Functional modules
- System flow
- Sensor operation
- Servo operation
- Fill-level calculation
docs/testing.md
Contains:
- Test cases
- Testing procedures
- Expected results
- Actual results
- Final test summary
reports/project_report.md
Contains the complete project report including:
- Introduction
- Problem statement
- Objectives
- Hardware
- Software
- Working principle
- Results
- Advantages
- Applications
- Future enhancements
- Conclusion
circuit_diagram/README.md
Contains the complete circuit connection details.
The Smart Dustbin concept can be used for:
- Smart homes
- Schools
- Colleges
- Offices
- Hospitals
- Public places
- Smart-city projects
- Waste-management systems
Future versions can include:
- 📡 Wi-Fi connectivity
- ☁️ IoT cloud monitoring
- 📱 Mobile application
- 🌐 Web dashboard
- 🔔 Remote notifications
- 📊 Historical waste-level analytics
- 🗑️ Multiple dustbin monitoring
- 🔋 Battery-powered operation
- ☀️ Solar-powered operation
- 🚛 Smart waste collection management
- Current prototype is primarily tested using Wokwi simulation.
- Fill percentage depends on the configured bin height.
- Ultrasonic readings can vary depending on the waste surface.
- Remote monitoring is not currently implemented.
- Cloud connectivity is not currently included.
Microcontroller : ESP32
Language : C++
Framework : Arduino
Build Tool : PlatformIO
Simulation : Wokwi
Sensors : HC-SR04 × 2
Actuator : Servo Motor
Indicators : Green LED + Red LED
Alert : Buzzer
Vaishnava Devi R
B.Sc. Digital & Cyber Forensic Science
Interested in:
- Embedded Systems
- IoT
- Cyber Security
- Digital Forensics
- VLSI / FPGA
- Software Development
This project is licensed under the MIT License.
See the LICENSE file for details.
If you find this project useful or interesting, consider giving the repository a ⭐ on GitHub.






