The Smart Waste Management System is designed to monitor the fill level of a waste bin and alert maintenance personnel when the bin is nearing full capacity. The system uses an Arduino Nano microcontroller to process signals from an HC-SR04 Ultrasonic Sensor, which measures the distance to the waste inside the bin. Depending on the fill level, different colored LEDs (green, yellow, red) indicate the bin's status, and a buzzer sounds an alarm when the bin is more than 80% full. The system also includes a SIM800L GSM Module to send SMS alerts for high fill levels. Power is supplied by a Lithium-ion Battery, which is charged by a solar panel through a Charge Controller.
#include <SoftwareSerial.h>
#define TRIG_PIN 2 // Ultrasonic sensor trigger pin
#define ECHO_PIN 3 // Ultrasonic sensor echo pin
#define GSM_TX 4 // GSM Module TX
#define GSM_RX 5 // GSM Module RX
#define BUZZER_PIN 6 // Buzzer pin
#define GREEN_LED 7 // Green LED pin
#define YELLOW_LED 8 // Yellow LED pin
#define RED_LED 9 // Red LED pin
SoftwareSerial gsm(GSM_RX, GSM_TX); // Software serial for GSM
const int binHeight = 30; // Bin height in cm (adjust according to your bin)
long duration;
int distance, fillLevel;
void setup() {
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(YELLOW_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
Serial.begin(9600);
gsm.begin(9600);
// GSM Module Initialization
sendSMS("Smart Waste Management System Initialized");
}
void loop() {
// Measure distance
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
duration = pulseIn(ECHO_PIN, HIGH);
distance = duration * 0.034 / 2;
// Calculate fill level percentage
fillLevel = map(distance, 0, binHeight, 100, 0);
// Determine bin status and set LEDs and buzzer accordingly
if (fillLevel <= 50) {
digitalWrite(GREEN_LED, HIGH);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, LOW);
digitalWrite(BUZZER_PIN, LOW);
Serial.println("Bin Status: Less than 50% full");
}
else if (fillLevel > 50 && fillLevel < 80) {
digitalWrite(GREEN_LED, LOW);
digitalWrite(YELLOW_LED, HIGH);
digitalWrite(RED_LED, LOW);
digitalWrite(BUZZER_PIN, LOW);
Serial.println("Bin Status: Between 50% and 80% full");
}
else if (fillLevel >= 80) {
digitalWrite(GREEN_LED, LOW);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, HIGH);
digitalWrite(BUZZER_PIN, HIGH);
Serial.println("Bin Status: More than 80% full");
sendSMS("Bin is 80% full. Please empty.");
}
delay(60000); // Wait for 1 minute before next reading
}
// Function to send SMS alert
void sendSMS(String message) {
gsm.print("AT+CMGF=1\r"); // Set SMS mode
delay(100);
gsm.print("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace with your phone number
delay(100);
gsm.print(message);
delay(100);
gsm.write(26); // ASCII code for Ctrl+Z (end of message)
delay(1000);
}
This code is responsible for the operation of the Smart Waste Management System. It initializes the hardware components, takes measurements from the ultrasonic sensor, calculates the fill level, updates the status LEDs, sounds the buzzer if necessary, and sends SMS alerts when the bin is 80% full.