Embedded SystemsBeginnerPRJ-048

Intelligent Dustbin with Fill-Level Display Using ESP8266

Shows how full the bin is on an LCD and beeps at 80%.

Built and tested by Shahan Fathima K · Industrial Robotics Institute

Circuit diagram of the Intelligent Dustbin with Fill-Level Display using ESP8266 NodeMCU
Circuit diagram · ESP8266 NodeMCU
LevelBeginner
Build time1–2 hours
BoardESP8266 NodeMCU
Parts6 components

What is the Intelligent Dustbin with Fill-Level Display?

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.

How it works

  1. The ultrasonic sensor under the lid measures the distance to the rubbish.
  2. As rubbish builds up, that distance gets shorter.
  3. The ESP8266 converts it to a fill percentage using the bin height (30 cm).
  4. The LCD shows "Fill: NN%".
  5. Above 80% full, the buzzer sounds.

Parts list

ComponentQty
ESP8266 NodeMCU1
Ultrasonic Sensor (HC-SR04)1
16×2 LCD with I2C Module1
Buzzer1
Jumper WiresAs needed
Power Supply1

Software

  • Arduino IDE
  • LiquidCrystal_I2C library

Wiring and connections

FromConnect to
Ultrasonic VCC5V (VIN)
Ultrasonic GNDGND
Ultrasonic TRIGD1
Ultrasonic ECHOD2
LCD VCC5V (VIN)
LCD GNDGND
LCD SDAD3
LCD SCLD4
Buzzer +D5
Buzzer −GND

How to build the Intelligent Dustbin with Fill-Level Display

  1. Fix the ultrasonic sensor under the bin lid, facing down.
  2. Wire the sensor to D1 (TRIG) and D2 (ECHO).
  3. Wire the I2C LCD to D3 (SDA) and D4 (SCL), and the buzzer to D5.
  4. Measure your bin’s inside height and set binHeight in the code.
  5. Install the LiquidCrystal_I2C library and upload the code.
  6. Fill the bin and watch the percentage rise.

Intelligent Dustbin with Fill-Level Display code

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);
}

Real-world uses

  • Schools and offices
  • Smart city waste bins
  • Housing societies
  • Waste management demos

Frequently asked questions

What is a Intelligent Dustbin with Fill-Level Display?

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.

What components are needed for the Intelligent Dustbin with Fill-Level Display?

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.

Is the Intelligent Dustbin with Fill-Level Display project good for beginners?

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.

Where can I get the code for the Intelligent Dustbin with Fill-Level Display?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the Intelligent Dustbin with Fill-Level Display?

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.

Industrial Robotics Institute
Logo