Skip to main content

garbage monitoring using arduino code with gsm

#include <SoftwareSerial.h>

#include <LiquidCrystal.h>

//LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

SoftwareSerial mySerial(0,1);

#define trigPin 2
#define echoPin 3

#define PIR_sensor 4
#define m11 5
#define m12 6

void setup()
{
   lcd.begin(16, 2);
   lcd.print("    Garbage    ");
   Serial.println("garbage ");
  lcd.setCursor(0,1);
  lcd.print("   Open Close    ");
  Serial.println(" open close");
  delay(3000);
  lcd.clear();
  //lcd.print(" ");
  delay(2000);
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
 pinMode(m11, OUTPUT);
  pinMode(m12, OUTPUT);
 

}
void loop()
{
 readPIR();
 pingDist();
 SendMessage();
}


void pingDist ()
  {
   
long duration, distance;
int max = 80; // Let consider as Height of the Garbage Bin is = 80 cm.
float diff, perc;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
diff = max - distance; // 'diff' variable tells u that, how much the Garbage Bin is Left to fill.
perc = (diff/max)*100; // 'perc' variable tells u that, how much percentage the Garbage Bin is filled.

if (perc>=10)
{
 
Serial.println("Garbage Bin is FULL."); // When the Garbage Bin is filled more than 90%, then this Error Message will Displayed.
lcd.print("Garb Bin full.");
lcd.setCursor(2,1);
// Call the Function of Send SMS.
SendMessage(); // Send Message Function Call.
}

else
{
Serial.print("Garbage Bin is Filled ");
lcd.setCursor(0,1);
//lcd.print("Garb Bin filled");
Serial.print(perc);
Serial.print("     %."); // These 3 Lines are print, that how much the Garbage
lcd.setCursor(0,0);
lcd.print("perc:");
lcd.print("    %.");
lcd.setCursor(5, 0);
//Bin is Filled...Ex. "Garbage Bin is Filled 70%.".
}


if (distance >= 200 || distance <= 2)
{
Serial.println("Out of range");
lcd.print("Out of range");
lcd.setCursor(0,1);
}
else
{
Serial.print(distance);
Serial.println(" cm");
//lcd.print("  ");
//lcd.print(" cm");
lcd.setCursor(9,1);
}

delay(500);
}
void SendMessage()
{
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
//lcd.print("AT+CMGF=1");
//lcd.setCursor(0,1);

delay(1000); // Delay of 1000 milli seconds or 1 second

mySerial.println("AT+CMGS=\"+919003413525\"\r"); // Replace x with mobile number

//lcd.print("AT+CMGS=\"+919003413525\"\r");

lcd.setCursor(0,1);

//delay(1000);

mySerial.println("Garbage Bin is Full."); // The SMS text you want to send
//lcd.print("Garb.BinisFull");

//delay(1000);

mySerial.println((char)26); // ASCII code of CTRL+Z

//delay(1000);

}

void readPIR()
{

 if(digitalRead(PIR_sensor))
  {
    lcd.setCursor(0,0);
    lcd.print("Movement Detected");
    Serial.println("Movement Detected");
    lcd.setCursor(0, 1);
    lcd.print("    Gate Opened    ");
    Serial.println("Gate Opened ");
    digitalWrite(m11, HIGH);         // gate opening
    digitalWrite(m12, LOW);
    delay(1000);
    digitalWrite(m11, LOW);          // gate stop for a while
    digitalWrite(m12, LOW);
    delay(1000);
    lcd.clear();
    lcd.print("   Gate Closed    ");
    digitalWrite(m11, LOW);           // gate closing
    digitalWrite(m12, HIGH);
    delay(1000);
    digitalWrite(m11, LOW);            // gate closed
    digitalWrite(m12, LOW);
    delay(1000);
  }
}

Comments

Popular posts from this blog

PUNCHING MACHINE

ACCIDENT AVOIDING SYSTEM FOR PUNCHING MACHINE SYNOPSIS The aim of our project is to take a system-wide approach to preventing the machine accident. The system includes not just the machine and the operator; but rather, it includes everything from the initial design of the machine to the training of everyone that is responsible for any aspect of it, to the documentation of all changes, to regular safety audits and a finally a corporate culture of safety-first. Design is the part of a machine's life where the greatest impact can be made in relation to avoiding accidents. The designer should ensure that the machine is safe to set up and operate, safe to install, safe to maintain, safe to repair, and safe to decommission. Although safe operation is usually at the forefront of a designer's mind, safe maintenance and repair should also be a high priority. Around 50% of fatal accidents involving industrial equipment are associated with maintenance activities, and design...