saravana surendar
Published © GPL3+

Smart Dustbin

It is a user friendly automated dustbin which can be used as an alternative for existing Corporation Dustbins as it makes management easier.

AdvancedFull instructions provided9 hours1,069
Smart Dustbin

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×2
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Breadboard (generic)
Breadboard (generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
Rechargeable Battery, 12 V
Rechargeable Battery, 12 V
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
SMS Messaging API
Twilio SMS Messaging API

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)
Tape, Double Sided
Tape, Double Sided
foam board
Used as Lid to the bin
bucket

Story

Read more

Schematics

Connections

Required Circuit Connections for the project

Code

Server Coding

Python
Main Server Code which sends messages through VPS when needed
from boltiot import Bolt, Sms #Import Sms and Bolt class  from boltiot library 

import bolt, json, time # accesing the json and time function 

 Maxlimit= 10 # the distance between device and garbage in dustbin in cm
  

mybolt = Bolt(bolt.API, bolt.ID) #Create object to fetch data 

sms = Sms(bolt.SID, bolt.AUTH, bolt.TO, bolt.FROM) #Create object to send SMS 

response = mybolt.serialRead('13')# we are now receiving the data read at the 13th pin of arduino board 

print(response) 

  

while True: 

    response = mybolt.serialRead('13')  #Fetching the value from Arduino 13th pin 

    data = json.loads(response)#storing the value received to the bolt from arduino 

    glevel = data['value'].rstrip()#storing the integer part  

    print("Garbage level is", glevel) 

     

     if (int(glevel) <= Maxlimit or int(glevel)==357): 

         response = sms.send_sms('Hello  I am full,please clean me out, location') #sending the sms to your mobile number 

    time.sleep(2.5)#time between two consecutive readings in seconds 

Arduino

C/C++
Code Uploaded to Arduoino Mega
#include <LiquidCrystal.h>
#include <Servo.h>   //servo library
#include <Ultrasonic.h>
Servo servo;
Ultrasonic ultrasonic(12, 13);
LiquidCrystal lcd(22,24,26,28,30,32);
#define LCD_NSCRL         3
#define LCD_DOT           '.'
#define LCD_SPC           ' '
int threshold=10;// change the threshold value in accordance with the iot
int ud=0;
int l=0;
int pos=0;
int trigPin = 5;    
int echoPin = 6;   
int servoPin = 7;
long duration, dist, average;   
long aver[3];   //array for average
void setup() {  
    lcd.begin(16,2);
    LCD();
    Serial.begin(9600);
    servo.attach(servoPin);  
    pinMode(trigPin, OUTPUT);  
    pinMode(echoPin, INPUT);  
    servo.write(0);         //close cap on power on
    delay(100);
    servo.detach();
    DispTitle();
} 
void TSKMONITOR(void){
  if(ud < threshold or ud==357){
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("BIN FULL!");
       }
     else{DispParam();
     }
  }
void DispTitle(void){
  lcd.clear();
  lcd.setCursor(0, 0); 
  lcd.print("SMARTBIN");
  delay(500);
  DispParam();
}
void DispParam(void) {
  lcd.clear();
  lcd.setCursor(0,0);
  delay(50);
  lcd.print(ud);
  }

void LCD(void) {
  int i, j, adr;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Loading");
  lcd.setCursor(0,1);
  for ( j = 0; j < LCD_NSCRL; j++ ) {
    adr = 0xc0;               // 2nd row, first coloumn
    for ( i = 0; i < 16; i++ ) {
      lcd.setCursor(i,1);
      lcd.print(LCD_DOT);       
      if ( i < 8 ) delay(200+(50*i)); else delay(25);
      lcd.setCursor(i,1);     
      lcd.print(LCD_SPC);     
   }
  } 
}
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(void) { 
  ud=ultrasonic.distanceRead();
  Serial.println(ud);
  delay(2500);
  TSKMONITOR();
  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 (ud< threshold or ud==357){
  servo.attach(servoPin);
  servo.write(pos);
     delay(1);
     servo.detach();
}else{
   if ( dist<50 ) {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("welcome");
  delay(50);
//Change distance as per your need
  servo.attach(servoPin);
    delay(1);
  servo.write(0); 
    delay(3000);       
  servo.write(180);
    delay(1000);
  servo.detach();      
}
}}

Bolt Iot

Python
Has all the credentials for bolt iot to access the cloud and Twillio account via API
 API = "bolt cloud api" 

 ID  = "device" 

 # Credentials required to send SMS 

SID = 'your twillio account sid' 

AUTH = 'your twillio account auth token' 

FROM = 'your twillio number' 

TO =' your number to get alert sms, please dont forget to add your country  code in the beginning of your phone number '

# SAVE IT IN A SEPARATE FILE CALL bolt.py and then we can acces this file in the main code by importing it

Credits

saravana surendar
2 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.