Smart Dustbin: Automated Open-Close and Garbage Level Measurement System

by Vasudev-2001 in Circuits > Arduino

471 Views, 2 Favorites, 0 Comments

Smart Dustbin: Automated Open-Close and Garbage Level Measurement System

#technology #startup #tech #electronics#hobby Smart dustbin prototype Multiple functions with one se
Air-Ground Robotic Collaboration Mentors Amit Kumar, Jaison Jose, Arun P Madhu, Smit Kesaria Interns Vasudev Kesharwani, Ashish Kumar Sahu (4).png

In a world where technology is constantly pushing boundaries, even the most ordinary objects can be transformed into extraordinary innovations. Enter the realm of the "Smart Dustbin" – a brilliant amalgamation of simplicity and ingenuity that redefines waste management.

Introducing the "Singular Sensor Smart Dustbin" – a revolutionary leap in waste management. This innovation accomplishes both automatic lid control and garbage level measurement using just one sensor, simplifying complexity and enhancing efficiency.

Story and Motivation:

As a tech enthusiast, I've come across quite a few smart dustbins. And you know what? It's not all just bells and whistles. There's a real challenge in there. One of the trickiest parts is making these bins super energy-efficient. Imagine, they need to work smoothly even in places where plugging into a power source isn't an option. That's a puzzle that keeps the tech minds buzzing.

I've noticed a common thread in smart dustbins: automatic lid control and garbage level measurement, but what got me thinking was if there's a way to tackle both tasks using just a single sensor. Imagine the efficiency boost if we crack that code!

So, with my trusty pen in hand, I decided to merge the geometry I learned back in 10th grade with my current electronic skills. After some tinkering, I'm thrilled to present the solution I've detailed in this instructable.

Supplies

I built a frame from cardboard, but you can use any type of material you prefer, such as cardboard. All the electronic components used are listed below:

  1. Arduino UNO X 1
  2. HC-SR04 Ultrasonic sensor X 1
  3. Servo Motor 9 gram X 1
  4. Led X 2
  5. Iron strips for the mechanism (similar to Mechanix components)

Mechanisum and Construction

1.jpeg
2.jpeg
beam.png

The mechanism is straightforward yet innovative, as depicted in the first image:

A: A movable joint that links the bin's lid to the AB strip (where the sensor is attached).

B: A movable joint that connects the AB strip to the BC strip.

C: A movable joint that attaches the BC strip to the CD strip.

D: A movable joint that is directly linked to a 180-degree rotation servo motor.

E: A movable upper joint that facilitates the rotation of the entire lid of the dustbin.

Mechanical Configurations:

Closed: The sensor is oriented forward (outside), enabling the automatic opening feature of the dustbin.

Open: The sensor is oriented downward (inside), facilitating the garbage level measurement feature of the dustbin.

Construction:

The second image illustrates the state of the construction in perfect working condition. This is due to the ultrasonic sensor having a 15-degree beam angle on each side, resulting in a 30-degree total beam angle. For the project to function effectively, the inequality described in the image needs to hold.

W/H >= 0.53

W: width of the bottom of the dustbin

H: height from the bottom of the dustbin without lid

Circuit Diagram

smart-dustbin.png

Downloads

Algorithm and Code

The algorithm initiates when the dustbin is in a closed condition, continuously monitoring the distance until it becomes less than 50.0 cm. Once the distance reaches this threshold, the event() function is triggered. This function manages the entire process of automating the lid-opening mechanism and measuring the level of garbage within the bin.

Below is the whole Arduino IDE code with suitable explanations:

#include "NewPing.h"
#include <Servo.h>
#define TRIGGER_PIN 11
#define ECHO_PIN 10
#define MAX_DISTANCE 400
#define led_red 13
#define led_yellow 12
#define led_green 8
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards


int pos = 180; // variable to store the servo position
int reward = 0, reward_Y = 0,reward_R = 0;
void setup() {
Serial.begin(9600);
pinMode(led_red, OUTPUT);
pinMode(led_green, OUTPUT);
pinMode(led_yellow, OUTPUT);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.write(20);
}


float Distance() {
float duration = sonar.ping_median(10);
float distance = (duration / 2) * 0.0343;
delay(5);// very nacessry to perform all the calculations
if (distance >= 400 ) {
distance = 400;
}
else if (distance <= 2) {
distance = 2;
}
return distance;
}
int grbgLevel(float d) {
if (d <= 17.27 && d >= 12.00) return 0; //"green" ;
else if ( d < 12.00 && d >= 7.00) return 1; //"yellow";
else if ( d < 7.00 && d >= 2.00) return 2; //"red";
}
void event(int Delay) {
for (pos = 20; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(3); // waits 15 ms for the servo to reach the position
}
Serial.print("gate opened ! pos :");
Serial.println(pos);
float D = Distance();
int val = grbgLevel(D);
digitalWrite(led_red, LOW);
digitalWrite(led_yellow, LOW);
digitalWrite(led_green, LOW);
Serial.print("garbage level : ");
if (val == 0) {
Serial.println("GREEN");
digitalWrite(led_green, HIGH);
}
else if (val == 2) {
Serial.println("RED");
digitalWrite(led_red, HIGH);
reward_R = 1;
}
else if (val == 1) {
Serial.println("YELLOW");
digitalWrite(led_yellow, HIGH);
reward_Y = 1;
}


Serial.println("Dustbin is ready to use !!");
delay(Delay);// to fill the garbage

D = Distance();
Serial.print("d parameter : ");
Serial.println(D);


val = grbgLevel(D);
digitalWrite(led_red, LOW);
digitalWrite(led_yellow, LOW);
digitalWrite(led_green, LOW);
Serial.print("garbage level : ");
if (val == 0) {
Serial.println("GREEN");
digitalWrite(led_green, HIGH);
}
else if (val == 2) {
Serial.println("RED");
digitalWrite(led_red, HIGH);
if (reward_Y )reward++; // yellow to red
else if(reward_R == 1)reward = 0;
else reward += 2;
}


else if (val == 1) {
Serial.println("YELLOW");
digitalWrite(led_yellow, HIGH);
reward_Y = 1;
reward++;
}
delay(1000);
for (pos = 180; pos >= 20; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(3); // waits 15 ms for the servo to reach the position
}
Serial.print("gate closed ! pos :");
Serial.println(pos);
delay(1000);// for mechanical system
}


void loop() {
delay(2000); // to set the mechanical system to it's mean position
while (true) {
float d = Distance();
Serial.print("Distance : ");
Serial.println(d);
if (d <= 50.00)break;
}
event(10000);
if (reward) {
// Reward Mode is activated
// keypad input stored in unique_id
// get the prevoius reward
// add the reward in previous reward to optain the total value
// Total reward in firebase node which is denoted by unoque_id

// ----- IOT development platform/firebase code
}
Serial.print("Distance just after event get happened : ");
Serial.println(Distance());
//reset
reward = 0;
reward_Y = 0;
reward_R = 0;
}