This circuit is designed to control a waste collection system that includes the following phases: Collection, Lifting, Dumping, and Resetting. It utilizes an HC-SR04 Ultrasonic Sensor to monitor the fill level of a bin, a GSM SIM900 module for sending updates, a DC Motor for movement, and a 1-Channel Relay to control the motor based on the bin's fill level. An Arduino Uno R3 serves as the central microcontroller, interfacing with an LCD I2C Display for user feedback. The circuit is powered by a 12V 5A Power Supply, with a LM2956 Buck Converter regulating the voltage for the Arduino and other 5V components.
/*
* This Arduino sketch controls a waste collection system with the following phases:
* Collection, Lifting, Dumping, and Resetting. It uses an ultrasonic sensor to
* monitor the bin's fill level and a GSM module to send updates. The motor is
* turned off when the bin is full to prevent overfilling.
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
// Pin definitions
const int trigPin = 9;
const int echoPin = 10;
const int motorPin1 = 2;
const int motorPin2 = 3;
const int relayPin = 7;
const int binFullLevel = 20; // Example threshold in cm
// LCD and GSM setup
LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial gsm(0, 1); // RX, TX
void setup() {
// Initialize serial communication
Serial.begin(9600);
gsm.begin(9600);
// Initialize LCD
lcd.begin();
lcd.backlight();
// Initialize pins
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(relayPin, OUTPUT);
// Initial state
digitalWrite(relayPin, LOW);
lcd.print("System Ready");
}
void loop() {
// Measure distance
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration / 2) / 29.1;
// Display distance on LCD
lcd.setCursor(0, 1);
lcd.print("Distance: ");
lcd.print(distance);
lcd.print(" cm");
// Check if bin is full
if (distance < binFullLevel) {
digitalWrite(relayPin, LOW); // Turn off motor
lcd.setCursor(0, 0);
lcd.print("Bin Full");
gsm.println("Bin is full");
} else {
// Collection Phase
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
delay(5000); // Adjust delay as needed
// Lifting Phase
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
delay(5000); // Adjust delay as needed
// Dumping Phase
digitalWrite(relayPin, HIGH);
delay(2000); // Adjust delay as needed
digitalWrite(relayPin, LOW);
// Resetting Phase
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
delay(5000); // Adjust delay as needed
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
}
delay(1000); // Adjust delay as needed
}
This code is responsible for the operation of the waste collection system. It initializes the components, measures the distance to the waste using the ultrasonic sensor, displays the distance on the LCD, and controls the motor and relay based on the bin's fill level. The GSM module is used to send a message when the bin is full.