VISHAL SIVARAMAN
Published © GPL3+

Smart Dustbin (IoT) Using Bolt IoT and Arduino Mega2560(1.0)

It is a user friendly automated dustbin which makes the work for the people cleaning it easier also management becomes better.

AdvancedProtip7 hours3,119
Smart Dustbin (IoT) Using Bolt IoT and Arduino Mega2560(1.0)

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Breadboard (generic)
Breadboard (generic)
×1
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×2
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
bread board small
×2
potentiometer 10k
×1
jumper wires
×1
Rechargeable Battery, 12 V
Rechargeable Battery, 12 V
×1

Software apps and online services

Arduino IDE
Arduino IDE
SMS Messaging API
Twilio SMS Messaging API

Hand tools and fabrication machines

glue gun
soldering iron kit
foam board/sun board
Tape, Double Sided
Tape, Double Sided
bucket

Story

Read more

Schematics

circuit connections

this pdf consists of the circuit connections for the entire project

Code

SERVER CODING

Python
this is the main server code which when run through vps will send messages 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 IDE

C/C++
this is the main code to be uploaded to the arduino 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

Python
this is a python file which has all the credentials for bolt to access the cloud as well as access your twilio 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

VISHAL SIVARAMAN

VISHAL SIVARAMAN

3 projects • 1 follower

Comments