Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views10 pages

Lecture Notes 3.9 (Smart Dustbin)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 10

University Institute of Computing

Master of Computer Applications


Internet of Things (IoT)
Sub Code: 23CAH-702

Designed By :
Dr. Kavita Jindal
Assistant Professor 1
Syllabus
1. Embedded
IOT UNIT
System
2.Embedded 1
& Raspberry
Programming
Pi
3. Arduino
1.
Programming
1. Interfacing of Devices
UNITand
2. Basic Laws 2
Interface Digital and Analog I/O Devices
Components
3. Various Sensor and
2. Devices

1. Embedded System
UNIT
Application 3 using
Application of Embedded systems
Arduino
3.
Syllabus
Application of Embedded Systems and IoT
Unit-3 Contact Hours: 15
Introduction to Node MCU, Pin diagram, Programming of Node MCU, Introduction
Chapter 3.1 ofcloud(BLYNK/Thingspeak/Cayenne), Connecting NodeMCU to WIFI network and cloud,
Collect and analyze data of sensors over the cloud. Interfacing of LEDs with NodeMCU.

Chapter 3.2 Design smart home systems, Smart parking systems, Smart dustbins for a clean environment,
Water level controller systems, and other various applications.
Smart Dustbin
Project Overview:
A Smart Dustbin aims to reduce human interaction with waste bins by automatically detecting when
waste is approaching and opening the lid accordingly. This can help in maintaining hygiene, reducing
the spread of germs, and making waste disposal more convenient. The project will use an Arduino
Uno, an ultrasonic sensor to detect the presence of a hand or waste, and a servo motor to open and
close the dustbin lid.

Components Required:
Arduino Uno: The microcontroller that controls the entire operation.
Ultrasonic Sensor (HC-SR04): To measure the distance of an object (like a hand) from the sensor.
Servo Motor (SG90): To actuate the lid of the dustbin.
Dustbin: A small dustbin or a container to act as the body.
Jumper Wires: For connecting the components.
Breadboard: For prototyping the circuit.
Power Supply: USB cable or batteries for the Arduino.
Smart Dustbin
Circuit Diagram:
Here's a brief description of the connections:

Ultrasonic Sensor HC-SR04:


VCC to 5V on Arduino
GND to GND on Arduino
Trig to Digital Pin 9 on Arduino
Echo to Digital Pin 8 on Arduino
Servo Motor SG90:
VCC (Red wire) to 5V on Arduino
GND (Black wire) to GND on Arduino
Signal (Yellow/White wire) to Digital Pin 3 on Arduino
Arduino Code:
The code below controls the ultrasonic sensor to measure the distance and actuates the servo motor to open
and close the lid based on the detected distance.
Smart Dustbin
#include <Servo.h>
// Define pins for the ultrasonic sensor
const int trigPin = 9;
const int echoPin = 8;

// Define pin for the servo motor


const int servoPin = 3;
Servo myServo; // Create servo object to control the servo
void setup() {
// Initialize the serial communication
Serial.begin(9600);
// Set the ultrasonic sensor pins as input and output
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
// Attach the servo motor to the servo pin
myServo.attach(servoPin);
myServo.write(0); // Ensure the servo starts in a closed position
Smart Dustbin
}
void loop() {
// Send a 10us pulse to trigger the ultrasonic sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the echo pin and calculate the distance
long duration = pulseIn(echoPin, HIGH);
int distance = duration * 0.034 / 2; // Convert to centimeters
// Print the distance to the serial monitor (for debugging)
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Check if an object is within 15 cm
if (distance < 15) {
myServo.write(90); // Open the lid (90 degrees)
delay(2000); // Keep the lid open for 2 seconds
Smart Dustbin
} else {
myServo.write(0); // Close the lid
}
delay(500); // Small delay before next loop iteration
}

Theory and Explanation:


Ultrasonic Sensor (HC-SR04):
The HC-SR04 ultrasonic sensor is used to measure the distance between the sensor and an object. It
works by emitting a high-frequency sound wave and measuring the time it takes for the wave to bounce
back after hitting an object. The sensor consists of two parts: the transmitter and the receiver.
Trig Pin: Sends out a pulse (sound wave).
Echo Pin: Receives the reflected pulse.
The distance to the object is calculated based on the time difference between sending and receiving the
sound wave, using the formula:
Distance=(Time×Speed of Sound2)\text{Distance} = \left(\frac{\text{Time} \times \text{Speed of Sound}}
{2}\right)Distance=(2Time×Speed of Sound​)
Smart Dustbin
where the speed of sound is approximately 343 meters per second in air.
Servo Motor (SG90):
A servo motor is used to control the position of the dustbin lid. It can rotate to a
specific angle based on the input pulse width. In this project, the servo is set to
rotate between 0° (closed) and 90° (open).
Arduino Uno:
The Arduino Uno acts as the brain of the smart dustbin, controlling the operation
based on the inputs from the ultrasonic sensor and sending signals to the servo
motor to actuate the lid.
This smart dustbin project can serve as a fundamental building block for more
complex automated waste management systems and can be expanded with
additional features and capabilities.
THANK YOU

Dr. Kavita Jindal

You might also like