Shows how full the bin is on an LCD and beeps at 80%.
Built and tested by Shahan Fathima K · Industrial Robotics Institute

A smart dustbin that measures how full it is. An ultrasonic sensor under the lid measures the distance down to the rubbish; the ESP8266 turns that into a fill percentage, shows it on a 16×2 LCD and sounds a buzzer when the bin is more than 80% full, so it gets emptied on time.
| Component | Qty |
|---|---|
| ESP8266 NodeMCU | 1 |
| Ultrasonic Sensor (HC-SR04) | 1 |
| 16×2 LCD with I2C Module | 1 |
| Buzzer | 1 |
| Jumper Wires | As needed |
| Power Supply | 1 |
| From | Connect to |
|---|---|
| Ultrasonic VCC | 5V (VIN) |
| Ultrasonic GND | GND |
| Ultrasonic TRIG | D1 |
| Ultrasonic ECHO | D2 |
| LCD VCC | 5V (VIN) |
| LCD GND | GND |
| LCD SDA | D3 |
| LCD SCL | D4 |
| Buzzer + | D5 |
| Buzzer − | GND |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define trigPin D1
#define echoPin D2
#define buzzer D5
LiquidCrystal_I2C lcd(0x27, 16, 2);
long duration;
int distance;
int binHeight = 30; // inside height of the bin in cm
void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
Wire.begin(D3, D4); // SDA = D3, SCL = D4
lcd.init();
lcd.backlight();
lcd.print("Smart Dustbin");
delay(2000);
lcd.clear();
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
int fillPercent = ((binHeight - distance) * 100) / binHeight;
fillPercent = constrain(fillPercent, 0, 100);
lcd.setCursor(0, 0);
lcd.print("Fill: ");
lcd.print(fillPercent);
lcd.print("% ");
if (fillPercent > 80)
{
digitalWrite(buzzer, HIGH);
}
else
{
digitalWrite(buzzer, LOW);
}
delay(1000);
}A smart dustbin that measures how full it is. An ultrasonic sensor under the lid measures the distance down to the rubbish; the ESP8266 turns that into a fill percentage, shows it on a 16×2 LCD and sounds a buzzer when the bin is more than 80% full, so it gets emptied on time.
You need: ESP8266 NodeMCU (1), Ultrasonic Sensor (HC-SR04) (1), 16×2 LCD with I2C Module (1), Buzzer (1), Jumper Wires, Power Supply (1). Software: Arduino IDE, LiquidCrystal_I2C library.
Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP8266 NodeMCU. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-048). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.