Introduction
Rapid urbanization has increased waste generation, making traditional waste collection inefficient. An IoT Smart Dustbin is an intelligent waste management system that automatically monitors garbage levels and sends real-time data to authorities. This system helps keep cities clean, hygienic, and efficient.
The dustbin can also open automatically using sensors and alert when it is full.
Objective of the Project
- To monitor garbage level automatically
- To reduce overflow of waste
- To improve waste collection efficiency
- To support smart city initiatives
Working Principle
- Ultrasonic sensor measures the garbage level inside the bin
- Microcontroller processes sensor data
- Data is sent to cloud using Wi-Fi
- Alert is generated when bin is full
- Optional servo motor opens the lid automatically
Components Required
- ESP32 / NodeMCU (ESP8266)
- Ultrasonic Sensor (HC-SR04)
- Servo Motor
- Buzzer
- LED Indicators
- Jumper Wires
- Power Supply
- IoT Platform (ThingSpeak / Blynk / Firebase)
Block Diagram
Ultrasonic Sensor
↓
ESP32 / NodeMCU
↓
Servo Motor + Buzzer
↓
Wi-Fi Module
↓
Cloud Platform
Circuit Connections (ESP32 Example)
Ultrasonic Sensor
VCC → 5V
GND → GND
Trig → GPIO5
Echo → GPIO18
Servo Motor
Signal → GPIO19
VCC → 5V
GND → GND
Buzzer
+ → GPIO23
- → GND
IoT Arduino Code (IoT Smart Dustbin)
#include <WiFi.h>
#include <Servo.h>
#include "ThingSpeak.h"
#define trigPin 5
#define echoPin 18
#define servoPin 19
#define buzzer 23
Servo lidServo;
WiFiClient client;
const char* ssid = "Your_WiFi";
const char* password = "Your_Password";
unsigned long channelID = 123456;
const char* writeAPIKey = "YOUR_API_KEY";
long duration;
int distance;
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
lidServo.attach(servoPin);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
ThingSpeak.begin(client);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
if (distance < 15) {
lidServo.write(90);
digitalWrite(buzzer, HIGH);
} else {
lidServo.write(0);
digitalWrite(buzzer, LOW);
}
ThingSpeak.setField(1, distance);
ThingSpeak.writeFields(channelID, writeAPIKey);
delay(15000);
}
Code Explanation
- Ultrasonic sensor measures garbage level
- Servo motor opens lid automatically
- Buzzer alerts when dustbin is full
- Data is uploaded to IoT cloud
Advantages
- Prevents garbage overflow
- Reduces manual monitoring
- Improves city cleanliness
- Real-time waste tracking
Applications
- Smart cities
- Public waste management
- Hospitals and malls
- Offices and campuses
Future Enhancements
- Mobile app notifications
- AI-based waste segregation
- GPS-enabled dustbin tracking
- Solar-powered operation
Conclusion
The IoT Smart Dustbin is an efficient and smart solution for modern waste management. By integrating sensors, IoT, and automation, it reduces human effort and keeps environments clean and hygienic.
