Introduction
Today we learn How to make Smart Dustbin with Arduino. A smart dustbin is a type of dustbin that uses technology such as sensors, microcontrollers, and internet connectivity to enhance its functionality. The primary aim of a smart dustbin is to make waste management more efficient, hygienic, and environmentally friendly. In this project, we will be using an Arduino microcontroller to create a smart dustbin that can detect when trash is deposited and automatically open and close the lid.
Hardware Required
Components | # | Buy From Amazon |
---|---|---|
Arduino UNO | 1 | Buy Now |
HC-SR04 Ultrasonic Sensor | 1 | Buy Now |
SG-90 Servo Motor | 1 | Buy Now |
Dustbin | 1 | Buy Now |
Battery 9v | 1 | Buy Now |
Jumper Wires | Few | Buy Now |
Breadboard | 1 | Buy Now |
What is the HC-SR04 Ultrasonic Sensor?
The HC-SR04 Ultrasonic Sensor is a popular sensor module used in electronics projects to measure distances between objects. It works by emitting high-frequency sound waves that bounce off nearby objects and return to the sensor. By measuring the time it takes for the sound waves to return, the sensor can calculate the distance to the object. The HC-SR04 Ultrasonic Sensor is small, affordable, and easy to use, making it a popular choice for hobbyists and DIY enthusiasts. It can be used in a wide range of applications, including robotics, home automation, and security systems.
Pinout of HC-SR04 Sensor
![HC-SR04-Ultrasonic-Distance-Sensor-Pinout](http://arduinocircuit.com/wp-content/uploads/2023/05/HC-SR04-Ultrasonic-Distance-Sensor-Pinout-1024x614.webp)
Pinout Configuration of HC-SR04 Sensor
Pin Name | Description |
---|---|
Vcc | The Vcc pin powers the sensor, typically with +5V |
Trigger | Trigger pin is an Input pin. This pin has to be kept high for 10us to initialize measurement by sending US wave. |
Echo | Echo pin is an Output pin. This pin goes high for a period of time which will be equal to the time taken for the US wave to return back to the sensor. |
Ground | This pin is connected to the Ground of the system. |
What is SG-90 Servo Motor?
SG90 Servo Motor is a small and economical type of servo motor that is commonly used in various robotic and automation projects. It is a type of rotary actuator that provides precise control over the angular position of a device. The SG90 is a 9g micro servo motor with a torque of 1.8 kg/cm and a rotation angle of approximately 180 degrees.
SG90 Servo Pinout
![SG90-SG-90-Servo-Motor-Pinout](http://arduinocircuit.com/wp-content/uploads/2023/03/SG90-SG-90-Servo-Motor-Pinout.webp)
Pin Name | Pin Description |
---|---|
Signal | Signal or PWM pin |
VCC | VCC, +5V Pin |
GND | Ground Pin |
Working Explanations
The smart dustbin will use an ultrasonic sensor to detect the presence of an object, in this case, trash, within a certain range. Once the sensor detects the trash, it will send a signal to the Arduino microcontroller, which will activate a servo motor to open the lid of the dustbin. After a certain period, the servo motor will close the lid of the dustbin. Additionally, the project can be enhanced by adding Wi-Fi connectivity, allowing the user to receive real-time updates on the level of trash in the bin and receive notifications when the bin needs to be emptied.
Circuit Diagram
![How-to-Make-a-Smart-Dustbin-using-Arduino-Circuit](http://arduinocircuit.com/wp-content/uploads/2023/05/How-to-Make-a-Smart-Dustbin-using-Arduino-Circuit-1024x651.webp)
Installing Arduino IDE Software
First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow
Installing Libraries
Now when you are Ready to upload the code, to the Arduino Board you will need first to add the Following Libraries in Arduino, If you Learn How to add the library in the Arduino step-by-step guide click on how to install the library Button given Blow
Code
//For more Projects: www.arduinocircuit.com
#include <Servo.h> //servo library
Servo servo;
int trigPin = 5;
int echoPin = 6;
int servoPin = 7;
int led= 10;
long duration, dist, average;
long aver[3]; //array for average
void setup() {
Serial.begin(9600);
servo.attach(servoPin);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
servo.write(0); //close cap on power on
delay(100);
servo.detach();
}
void measure() {
digitalWrite(10,HIGH);
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(15);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
dist = (duration/2) / 29.1; //obtain distance
}
void loop() {
for (int i=0;i<=2;i++) { //average distance
measure();
aver[i]=dist;
delay(10); //delay between measurements
}
dist=(aver[0]+aver[1]+aver[2])/3;
if ( dist<50 ) {
//Change distance as per your need
servo.attach(servoPin);
delay(1);
servo.write(0);
delay(3000);
servo.write(150);
delay(1000);
servo.detach();
}
Serial.print(dist);
}
Applications
- Home use: A smart dustbin can be used in households to make waste management more efficient and hygienic. The automatic lid ensures that the trash is not exposed, reducing the risk of contamination and foul odor.
- Public places: A smart dustbin can be installed in public places such as parks and shopping malls to encourage people to dispose of their waste properly.
- Hospitals: Smart dustbins can be installed in hospitals to improve hygiene and reduce the risk of infections.
- Smart Cities: Smart dustbins can be integrated into the larger smart city infrastructure to enhance waste management and improve the environment.
- Offices: Smart dustbins also using in offices to promote a cleaner and healthier work environment.
Conclusion
A smart dustbin is a simple yet effective example of how technology also uses to solve everyday problems. By automating the waste management process, we can reduce the risk of contamination and improve the hygiene of our surroundings. With the advent of the Internet of Things (IoT) and smart city initiatives, the potential applications of smart dustbins are limitless.