IoT based Smart Dustbin Management System using NodeMCU

Published  February 28, 2022   0
D Divansh Sahni
Author
IoT based Smart Dustbin using NodeMCU and Ultrasonic sensor

The idea struck us when we observed that the garbage truck use to go around the town to collect solid waste twice a day. Although this system was thorough it was very inefficient. For example, let's say street A is a busy street and we see that the garbage fills up really fast whereas maybe street B even after two days the bin is even half full. 

We previously built smart dustbin using NodeMCU and ultrasonic sensor.

What Smart Dustbin does?

It gives a real time indicator of the garbage level in a trashcan at any given time. Using that data, we can then optimize waste collection routes and ultimately reduce fuel consumption. It allows trash collectors to plan their daily/weekly pick up schedule. The level of dustbin filled or not is done by using an Ultrasonic sensor or IR sensor. Through an internet app or web page, every truck driver knew the real time data easily.

Smart Dustbin Management System

Component Requirement for IoT based Dustbin

Project Used Hardware

  • NodeMCU ESP8266 Controllers,
  • Ultrasonic Sensor *2,
  • Servo motor,
  • Battery,
  • Wire

Project Used Software

  • Arduino IDE,

Project Hardware Software Selection

NODEMCU ESP8266: The ESP8266 is a low cost MCU with built in Wi-Fi. It can be used as a standalone MCU, as it includes a 32-bit 80Mhz processor, 16 GPIO pins (4 PWM enabled), and a built-in analog to digital converter, SPI, I2C interfaces, and more. The MCU has an operating voltage of 2.5V - 3.6V and an average operating current of 80mA.

Ultrasonic Sensor: An ultrasonic sensor is an instrument that measures the distance to an object using ultrasonic sound waves. An ultrasonic sensor uses a transducer to send and receive ultrasonic pulses that relay back information about an object’s proximity. High-frequency sound waves reflect from boundaries to produce distinct echo patterns.

Servo Motor: The TowerPro SG90 9g Mini Servo is a 180° rotation servo. It is a Digital Servo Motor that receives and processes PWM signal faster and better. It equips sophisticated internal circuitry that provides good torque, holding power, and faster updates in response to external forces.

Arduino IDE: Arduino IDE is an open-source software, designed by Arduino.cc and mainly used for writing, compiling & admin/uploading code to almost all Arduino Modules. It is an official Arduino software, making code compilation too easy that even a common person with no prior technical knowledge can get their feet wet with the learning process.

Circuit Diagram

Smart Dustbin using NodeMCU and Ultrasonic sensor Circuit Diagram

In this project, we have used 2 ultrasonic sensors. In which one of the sensors we used to display the level of the trash filled in the dustbin which will be shown in our mobile phones. And the second sensor we used with the help of a servo motor to open the lid of the dustbin automatically.

Applications

  • Waste Level detection inside the dustbin
  • Transmit the information wirelessly to concerned
  • The data can be accessed anytime and from anywhere
  • The real-time data transmission and access
  • Avoids the overflows of Dustbins.
Code
#include
#define BLYNK_PRINT Serial
#include
#include
#define trigPin1 D6                                
#define echoPin1 D7                                 
#define LED D5                      
#define trigPin2 D2
#define echoPin2 D3
int servoPin = D4;
Servo Servo1;
char auth[] = "e3cba71f269345f98e85eba906703e13";
char ssid[] = "Smart_Cleaner";
char pass[] = "10666897";
WidgetLCD lcd(V1);
long duration, distance, UltraSensor1, UltraSensor2;
char data;
String SerialData="";
void setup(){
Serial.begin(9600);                             
pinMode(trigPin1, OUTPUT);                      
pinMode(echoPin1, INPUT);                        
pinMode(LED, OUTPUT);                
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
pinMode(servoPin, OUTPUT);
 Servo1.attach(servoPin);
 Blynk.begin(auth, ssid, pass);
 lcd.clear();
}
void loop() {
lcd.clear();
SonarSensor(trigPin1, echoPin1);            
UltraSensor1 = distance; 
Blynk.run();
delay(2000);
SonarSensor(trigPin2,echoPin2);              
UltraSensor2 = distance;                     
if(UltraSensor1 >=23)
{
  Serial.print("Dustbin is 0% fill");
 lcd.print(0, 0, "Dustbin is 0% fill");
 delay(100);
}
if(UltraSensor1 <20)
{
   Serial.print("Dustbin is 25% full");
 lcd.print(0, 0, "Dustbin is 25% full");
  delay(100);
}
if(UltraSensor1 <17)
{
  Serial.print("Dustbin is 50% full");
  lcd.print(0, 0, "Dustbin is 50% full");
  delay(100);
}
if(UltraSensor1 <13)
{
 Serial.print("Dustbin is 75% full");
 lcd.print(0, 0, "Dustbin is 75% full");
  delay(100);
}
if(UltraSensor1 <9)
{
 Serial.print("Dustbin is 100% full");
 lcd.print(0, 0, "Dustbin is 100% full");
  delay(100);
}
if(UltraSensor2 <=15)
{
Serial.print(distance);
Serial.println("distance");
Servo1.write(0);
delay(10000);
Servo1.write(60);
delay(10000);
}
else
{
Serial.print(distance);
Serial.println("distance");
}
}
void SonarSensor(int trigPinSensor,int echoPinSensor)
{
digitalWrite(trigPinSensor, LOW);
delayMicroseconds(2);
digitalWrite(trigPinSensor, HIGH);
delayMicroseconds(10); //
digitalWrite(trigPinSensor, LOW);
duration = pulseIn(echoPinSensor, HIGH);
distance= (duration/2) / 29.1;
}
Have any question realated to this Article?

Ask Our Community Members