Arduino UNO-Based Smart Waste Segregator with Ultrasonic and Moisture Sensors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to segregate dry and wet waste using an Arduino UNO microcontroller. It utilizes various sensors to detect the type of waste and a servo motor to sort the waste accordingly. The circuit includes an ultrasonic sensor to measure distance, a moisture sensor to detect wetness, an IR sensor, an LCD display for user interface, and a water pump controlled by a transistor.
Component List
Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
16x2 I2C LCD
- Description: 16x2 character LCD display with I2C interface.
- Pins: GND, VCC, SDA, SCL
HC-SR04 Ultrasonic Sensor
- Description: Ultrasonic distance sensor.
- Pins: VCC, TRIG, ECHO, GND
Servo
- Description: Servo motor for mechanical movement.
- Pins: GND, VCC, PWM
Water Sensor
- Description: Sensor to detect water presence.
- Pins: -, +
Rain/Snow Sensor - Board
- Description: Sensor to detect rain or snow.
- Pins: 1, 2, A0 (Analog), D0 (Digital), GND, VCC (5V)
IR Sensor
- Description: Infrared sensor for object detection.
- Pins: out, gnd, vcc
TIP120 Hi-Current Darlington Transistor
- Description: NPN power transistor.
- Pins: BASE, COLLECTOR, EMITTER
5V Mini Water Pump
- Description: Small water pump powered by 5V.
- Pins: positive pin, negative pin
9V Battery
- Description: 9V battery for power supply.
- Pins: -, +
Resistor
- Description: 1000 Ohms resistor.
- Pins: pin1, pin2
Wiring Details
Arduino UNO
- GND: Connected to GND of Rain/Snow Sensor, 16x2 I2C LCD, IR Sensor, Servo, HC-SR04 Ultrasonic Sensor, and 9V Battery.
- 5V: Connected to VCC of Rain/Snow Sensor, 16x2 I2C LCD, IR Sensor, Servo, and HC-SR04 Ultrasonic Sensor.
- A0: Connected to A0 (Analog) of Rain/Snow Sensor.
- A4: Connected to SDA of 16x2 I2C LCD.
- A5: Connected to SCL of 16x2 I2C LCD.
- D12: Connected to TRIG of HC-SR04 Ultrasonic Sensor.
- D11: Connected to ECHO of HC-SR04 Ultrasonic Sensor.
- D8: Connected to PWM of Servo.
- D3: Connected to pin1 of Resistor.
- D2: Connected to out of IR Sensor.
16x2 I2C LCD
- GND: Connected to GND of Arduino UNO.
- VCC: Connected to 5V of Arduino UNO.
- SDA: Connected to A4 of Arduino UNO.
- SCL: Connected to A5 of Arduino UNO.
HC-SR04 Ultrasonic Sensor
- VCC: Connected to 5V of Arduino UNO.
- TRIG: Connected to D12 of Arduino UNO.
- ECHO: Connected to D11 of Arduino UNO.
- GND: Connected to GND of Arduino UNO.
Servo
- GND: Connected to GND of Arduino UNO.
- VCC: Connected to 5V of Arduino UNO.
- PWM: Connected to D8 of Arduino UNO.
Water Sensor
- -: Connected to pin 1 of Rain/Snow Sensor.
- +: Connected to pin 2 of Rain/Snow Sensor.
Rain/Snow Sensor - Board
- GND: Connected to GND of Arduino UNO.
- VCC (5V): Connected to 5V of Arduino UNO.
- A0 (Analog): Connected to A0 of Arduino UNO.
- 1: Connected to - of Water Sensor.
- 2: Connected to + of Water Sensor.
IR Sensor
- out: Connected to D2 of Arduino UNO.
- gnd: Connected to GND of Arduino UNO.
- vcc: Connected to 5V of Arduino UNO.
TIP120 Hi-Current Darlington Transistor
- BASE: Connected to pin2 of Resistor.
- COLLECTOR: Connected to negative pin of 5V Mini Water Pump.
- EMITTER: Connected to GND of Arduino UNO and 9V Battery.
5V Mini Water Pump
- positive pin: Connected to + of 9V Battery.
- negative pin: Connected to COLLECTOR of TIP120 Hi-Current Darlington Transistor.
9V Battery
- -: Connected to GND of Arduino UNO and EMITTER of TIP120 Hi-Current Darlington Transistor.
- +: Connected to positive pin of 5V Mini Water Pump.
Resistor
- pin1: Connected to D3 of Arduino UNO.
- pin2: Connected to BASE of TIP120 Hi-Current Darlington Transistor.
Documented Code
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Use correct I2C address and dimensions (16x2)
Servo servo1;
const int trigPin = 12;
const int echoPin = 11;
long duration;
int distance = 0;
int potPin = A0;
int soil = 0;
int fsoil;
int maxDryValue = 1; // Value for treating waste as wet object based on humidity
int Ultra_Distance = 15; // Distance in cm between Ultrasonic and moisture sensor
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
servo1.attach(8);
Serial.println("Soil Sensor Ultrasonic Servo");
lcd.print(".........");
delay(1000);
}
void loop()
{
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Dry Wet Waste");
lcd.setCursor(3, 1);
lcd.print("Segregator");
int soil = 0;
for (int i = 0; i < 2; i++)
{
digitalWrite(trigPin, LOW);
delayMicroseconds(7);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
delayMicroseconds(10);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2 + distance;
delay(10);
}
distance = distance / 2;
if (distance < Ultra_Distance && distance > 1)
{
delay(1000);
for (int i = 0; i < 3; i++)
{
soil = analogRead(potPin);
soil = constrain(soil, 485, 1023);
fsoil = (map(soil, 485, 1023, 100, 0)) + fsoil;
delay(75);
}
fsoil = fsoil / 3;
Serial.print("Humidity: ");
Serial.print(fsoil);
Serial.print("% Distance: ");
Serial.print(distance);
Serial.print(" cm");
if (fsoil > maxDryValue)
{
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Garbage Detected!");
lcd.setCursor(6, 1);
lcd.print("WET");
Serial.println(" ==> WET Waste");
servo1.write(160);
delay(3000);
}
else
{
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Garbage Detected!");
lcd.setCursor(6, 1);
lcd.print("DRY");
Serial.println(" ==> Dry Waste");
servo1.write(20);
delay(3000);
}
servo1.write(90);
}
distance = 0;
fsoil = 0