0% found this document useful (0 votes)
59 views32 pages

Smart Dust Bin Using Ultrasonic Sensor

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
59 views32 pages

Smart Dust Bin Using Ultrasonic Sensor

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 32

A Project Report On

Smart Dust Bin Using Ultrasonic Sensor

Submitted in partial fulfillment of the requirements

For the award of the degree in

Electronics Engineering

Submitted By

--------------------

--------------------

--------------------

Department Of _______________________ Engineering College

Affiliated to ___________ University, Hyderabad.


CERTIFICATE

This is to certify that the project work entitled “Smart Dust Bin Using Ultrasonic
Sensor ” is the work done by
_______________________________________________submitted in partial
fulfillment for the award of ‘Electronics Engineering from______________ College of
Engineering affiliated to _________ University, Hyderabad .

________________ ____________

(Head of the department, ECE) (Assistant Professor)

External Examiner
ACKNOWLEDGEMENT

The satisfaction that accompany the successful completion of any task would be
incomplete without the mentioning of the people whose constant guidance and
encouragement made it possible. We take pleasure in presenting before you, our
project, which is result of studied blend of both research and knowledge.

I express my earnest gratitude to our internal guide, Assistant Professor


______________, Department of Automobile Engineering for his constant support,
encouragement and guidance. I am grateful for his cooperation and his valuable
suggestions.

Finally, I express my gratitude to all other members who are involved either
directly or indirectly for the successful completion of this project.
INDEX

Contents Page No.

 Abstract

 Introduction

 Arduino Open Source Harware Platform

 Hardware Description

 Software Description

 Schematic Diagram

 Coding

 Conclusion

 References
ABSTRACT

Design & Implementation of Smart Dust Bin Using Ultrasonic Sensor

Ultrasonic sensors can be used to measure distance from objects without


actual contact and used at several places like water level measurement, distance
measurement etc. This is an efficient way to measure small distances precisely.
In this project we are using Ultrasonic Sensor to determine the distance of an
obstacle from the sensor. Detection Range of the sensor is upto 4 meters.

Microcontroller used in project is Atmega328 which belongs to AVR


microcontroller family. We are using Arduino Uno board to interface peripherals.
HC-SR04 ultrasonic sensor is used for object distance measurement. The
distance readings are also sent to computer serial monitor for debugging
purpose. Servo motor is used to control a lid of dust bin. Regulated power supply
5V is given for all the units. We are using 12V 1A dc adapter to supply power.
We can also use a battery pack for outdoor usage condition.

Software:

 Arduino IDE

 Embedded CPP Code

 Proteus Simulator

Hardware:

1. Atmega328 Microcontroller (Arduino UNO)

2. Ultrasonic sensor Module HC-SR04


3. Servo Motor
4. LED indicator
5. Regulated Power Supply 5V
6. 12V 1A DC Adapter
BLOCK DIAGRAM :

Servo Motor
Ultrasonic
Sensor Atmega328
Module Computer (Serial
MCU (UNO)
Monitor)
HC-SR04

Regulated Power

Supply

Working Operation :

HC-SR04 ultrasonic sensor is interaced with Atmega328 microcontroller which


processes data and displays distance reading on computer serial monitor. Whenever
there is any object or a person within specific distance, controller sends signal to servo
motor which then opens a lid of a dust bin and it returns to initial position after specific
duration.
Introduction :

Dustbins (or Garbage bins, Trash Cans, whatever you call them) are small plastic (or
metal) containers that are used to store trash (or waste) on a temporary basis. They are
often used in homes, offices, streets, parks etc. to collect the waste. In some places,
littering is a serious offence and hence public waste containers are the only way to
dispose small waste. We are converting ordinary dust bins to smart dust bin with
technology. It is possible to know dust bin level in a real time if we send a data to IOT
platform. User can access same data from anywhere in the world. In this application, we
have implemented a motorized mechanism to control lid of a dust bin for user
convenience.

Arduino Platform

Arduino is an open-source electronics prototyping platform based on flexible,


easy-to-use hardware and software. It is a single board microcontroller, descendant of
the open-source wiring platform designed to make the process of using electronics in
multidisciplinary projects. Several plug-in application shields are also commercially
available.

Arduino Mega board is based on the Atmega2560 microcontroller. The hardware


consists of a simple open hardware design for the Arduino board with an on-board
input/output support. The software consists of a standard programming language
compiler and the boot loader that runs on the board. Arduino hardware is programmed
using a Wiring-based language (syntax and libraries), similar to C++ with some slight
simplifications and modifications, and a Processing-based integrated development
environment.

Arduino can sense the environment by receiving input from a variety of sensors
and can affect its surroundings by controlling lights, motors, and other actuators. The
microcontroller on the board is programmed using the Arduino programming language
(based on Wiring) and the Arduino development environment (based on Processing).
Arduino projects can be stand-alone or they can communicate with software running on
a computer. The hardware reference designs (CAD files) are available under an open-
source license; you are free to adapt them to your needs. The open-source Arduino
environment makes it easy to write code and upload it to the i/o board. It runs on
Windows, Mac OS X, and Linux. In addition to all the features of the previous board, the
Uno now uses an ATmega8U2 instead of the FTDI chip.

Arduino Hardware:

An Arduino board consists of an 8-bit Atmel AVR microcontroller with


complementary components to facilitate programming and incorporation into other
circuits. An important aspect of the Arduino is the standard way that connectors are
exposed, allowing the CPU board to be connected to a variety of interchangeable add-
on modules known as shields. Some shields communicate with the Arduino board
directly over various pins, but many shields are individually addressable via an I²C
serial bus, allowing many shields to be stacked and used in parallel. Official Arduino’s
have used the mega AVR series of chips, specifically the ATmega8, ATmega168,
ATmega328, ATmega1280, and ATmega2560. A handful of other processors have
been used by Arduino compatibles. Most boards include a 5 volt linear regulator and a
16 MHz crystal oscillator (or ceramic resonator in some variants), although some
designs such as the Lily Pad run at 8 MHz and dispense with the onboard voltage
regulator due to specific form-factor restrictions. An Arduino's microcontroller is also
pre-programmed with a boot loader that simplifies uploading of programs to the on-chip
flash memory, compared with other devices that typically need an external
programmer.

At a conceptual level, when using the Arduino software stack, all boards are
programmed over an RS-232 serial connection, but the way this is implemented varies
by hardware version. Serial Arduino boards contain a simple inverter circuit to convert
between RS-232-level and TTL-level signals. Current Arduino boards are programmed
via USB, implemented using USB-to-serial adapter chips such as the FTDI FT232.
Some variants, such as the Arduino Mini and the unofficial Board uno, use a
detachable USB-to-serial adapter board or cable, Bluetooth or other methods. (When
used with traditional microcontroller tools instead of the Arduino IDE, standard AVR ISP
programming is used.)

Arduino Uno is a microcontroller board based on 8-bit ATmega328P microcontroller.


Along with ATmega328P, it consists other components such as crystal oscillator, serial
communication, voltage regulator, etc. to support the microcontroller. Arduino Uno has
14 digital input/output pins (out of which 6 can be used as PWM outputs), 6 analog input
pins, a USB connection, A Power barrel jack, an ICSP header and a reset button.

The technical features of Arduino Uno ATmega328 includes the following.

 The operating voltage is 5V


 The recommended input voltage will range from 7v to 12V
 Digital input/output pins are 14
 Analog Input pins are 6
 DC Current for each input/output pin is 40 mA
 DC Current for 3.3V Pin is 50 mA
 Flash Memory is 32 KB
 SRAM is 2 KB
 EEPROM is 1 KB
 CLK Speed is 16 MHz
Atmega328 Microcontroller

The ATmega328 is one kind of single-chip microcontroller formed with Atmel within
the megaAVR family.

Power Supply

The Arduino Uno power supply can be given with the help of a USB cable or an
external power supply. The external power supplies mainly include AC to DC adapter
otherwise a battery. The adapter can be connected to the Arduino Uno by plugging into
the power jack of the Arduino board. Similarly, the battery leads can be connected to
the Vin pin and the GND pin of the POWER connector. The suggested voltage range
will be 7 volts to 12 volts.

Input & Output

The 14 digital pins on the Arduino Uno can be used as input & output with the help of
the functions like pinMode(), digitalWrite(), & Digital Read().
Pin1 (TX) & Pin0 (RX) (Serial):

This pin is used to transmit & receive TTL serial data, and these are connected to the
ATmega8U2 USB to TTL Serial chip equivalent pins.

Pin 2 & Pin 3 (External Interrupts):

External pins can be connected to activate an interrupt over a low value, change in
value.

Pins 3, 5, 6, 9, 10, & 11 (PWM):

This pin gives 8-bit PWM o/p by the function of analogWrite()

SPI Pins (Pin-10 (SS), Pin-11 (MOSI), Pin-12 (MISO), Pin-13 (SCK):

These pins maintain SPI-communication, even though offered by the fundamental


hardware, is not presently included within the Arduino language.

Pin-13(LED):

The inbuilt LED can be connected to pin-13 (digital pin). As the HIGH-value pin, the
light emitting diode is activated, whenever the pin is LOW.

Pin-4 (SDA) & Pin-5 (SCL) (I2C):

It supports TWI-communication with the help of the Wire library.

AREF (Reference Voltage):

The reference voltage is for the analog i/ps with analogReference()

Reset Pin:

This pin is used for reset (RST) the microcontroller.

Memory

The memory of this Atmega328 Arduino microcontroller includes flash memory-32 KB


for storing code, SRAM-2 KB EEPROM-1 KB.

Communication
The Arduino Uno ATmega328 offers UART TTL-serial communication, and it is
accessible on digital pins like TX (1) and RX (0). The software of an Arduino has a serial
monitor that permits easy data. There are two LEDs on the board like RX & TX which
will blink whenever data is being broadcasted through the USB.

A SoftwareSerial library permits for serial communication on Arduino Uno digital pins
and the ATmega328P supports TWI (I2C) as well as SPI-communication. The Arduino
software contains a wired library for simplifying the utilization of the I2C bus.

Using Arduino Uno Board

Arduino Uno can detect the surroundings from the input. Here the input is a
variety of sensors and these can affect its surroundings through controlling motors,
lights, other actuators, etc. The ATmega328 microcontroller on the Arduino board can
be programmed with the help of an Arduino programming language and the IDE
(Integrated Development Environment).

The 14 digital input/output pins can be used as input or output pins by using
pinMode(), digitalRead() and digitalWrite() functions in arduino programming. Each pin
operate at 5V and can provide or receive a maximum of 40mA current. Out of these 14
pins, some pins have specific functions as listed below:

 Serial Pins 0 (Rx) and 1 (Tx): Rx and Tx pins are used to receive and transmit TTL
serial data. They are connected with the corresponding ATmega328P USB to TTL serial
chip.
 External Interrupt Pins 2 and 3: These pins can be configured to trigger an interrupt
on a low value, a rising or falling edge, or a change in value.
 PWM Pins 3, 5, 6, 9 and 11: These pins provide an 8-bit PWM output by using
analogWrite() function.
 SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK): These pins are used for SPI
communication.
 In-built LED Pin 13: This pin is connected with an built-in LED, when pin 13 is HIGH –
LED is on and when pin 13 is LOW, its off.

Along with 14 Digital pins, there are 6 analog input pins, each of which provide 10 bits of
resolution, i.e. 1024 different values. They measure from 0 to 5 volts but this limit can be
increased by using AREF pin with analog Reference() function.

 Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire
library.

Arduino Uno has a couple of other pins as explained below:

 AREF: Used to provide reference voltage for analog inputs with analogReference()
function.
 Reset Pin: Making this pin LOW, resets the microcontroller.

Arduino Communication

Arduino can be used to communicate with a computer, another Arduino board or


other microcontrollers. The ATmega328P microcontroller provides UART TTL (5V)
serial communication which can be done using digital pin 0 (Rx) and digital pin 1 (Tx).
An ATmega16U2 on the board channels this serial communication over USB and
appears as a virtual com port to software on the computer. The ATmega16U2 firmware
uses the standard USB COM drivers, and no external driver is needed. However, on
Windows, a .inf file is required. The Arduino software includes a serial monitor which
allows simple textual data to be sent to and from the Arduino board. There are two RX
and TX LEDs on the arduino board which will flash when data is being transmitted via
the USB-to-serial chip and USB connection to the computer (not for serial
communication on pins 0 and 1). A SoftwareSerial library allows for serial
communication on any of the Uno's digital pins. The ATmega328P also supports I2C
(TWI) and SPI communication. The Arduino software includes a Wire library to simplify
use of the I2C bus.
Arduino Programming

Once arduino IDE is installed on the computer, connect the board with computer using
USB cable. Now open the arduino IDE and choose the correct board by selecting
Tools>Boards>Arduino/Genuino Uno, and choose the correct Port by selecting
Tools>Port. Arduino Uno is programmed using Arduino programming language based
on Wiring. To get it started with Arduino Uno board and blink the built-in LED, load the
example code by selecting Files>Examples>Basics>Blink. Once the example code (also
shown below) is loaded into your IDE, click on the ‘upload’ button given on the top bar.
Once the upload is finished, you should see the Arduino’s built-in LED blinking.

Below is the example code for led blinking:

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever


void loop()
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Applications

 Prototyping of Electronics Products and Systems


 Multiple DIY Projects.
 Easy to use for beginner level DIYers and makers.
 Projects requiring Multiple I/O interfaces and communications.
 Advantages of Arduino Over other Microcontrollers
There are many other microcontrollers and microcontroller platforms available for
physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's
Handyboard, and many others offer similar functionality. All of these tools take the
messy details of microcontroller programming and wrap it up in an easy-to-use
package. Arduino also simplifies the process of working with microcontrollers, but it
offers some advantage for teachers, students, engineers and interested amateurs over
other systems:

1) Inexpensive - Arduino boards are relatively inexpensive compared to other


microcontroller platforms. The least expensive version of the Arduino module can
be assembled by hand, and even the pre-assembled Arduino modules cost less
than INR 1000;
2) Cross-platform - The Arduino software runs on Windows, Macintosh OSX, and
Linux operating systems. Most microcontroller systems are limited to Windows;
3) Simple, clear programming environment - The Arduino programming
environment is easy-to-use for beginners, yet flexible enough for advanced users
to take advantage of as well. For teachers, it's conveniently based on the
Processing programming environment, so students learning to program in that
environment will be familiar with the look and feel of Arduino.
4) Open source and extensible software- The Arduino software is published as
open source tools, available for extension by experienced programmers. The
language can be expanded through C++ libraries, and people wanting to
understand the technical details can make the leap from Arduino to the AVR C
programming language on which it's based. Similarly, you can add AVR-C code
directly into your Arduino programs if you want to.
5) Open source and extensible hardware - The Arduino is based on Atmel's
ATMEGA8 and ATMEGA168 microcontrollers. The plans for the modules are
published under a Creative Commons license, so experienced circuit designers
can make their own version of the module, extending it and improving it. Even
relatively inexperienced users can build the breadboard version of the module in
order to understand how it works and save money.
Hardware Peripherals Description :

12V, 5V Voltage Regulator Board

We are using 12V, 5V Voltage Regulator board to provide supply for all the
peripherals. We are using 12V 1A/2A DC Adapter as input to the voltage regulator
board.

Almost all basic household electronic circuits need an unregulated AC supply to


be converted to constant DC, in order to operate the electronic device. All devices will
have a certain power supply limit and the electronic circuits inside these devices must
be able to supply a constant DC voltage within this limit. This DC supply is regulated
and limited in terms of voltage and current. But the supply provided from mains may be
fluctuating and could easily break down the electronic equipment, if not properly limited.
This work of converting an unregulated alternating current (AC) or voltage to a limited
Direct current (DC) or voltage to make the output constant regardless of the fluctuations
in input, is done by a regulated power supply circuit.

The best method used in making a dc power supply is to use combination of a


transformer or 12V dc adapter, bridge rectifier, filter capacitor,voltage regulator Ics 7812
and 7805 as per requirement , power indicator led.
Regulated Power Supply Schematic Diagram :

Schematic Explanation :

We need to give 12V AC/DC power supply input to the regulator board. There is
bridge rectifier using four diodes or we can use bridge rectifier package which converts
AC/DC into fluctuating dc Supply. It is then filtered using filter capacitor. 7812 voltage
regulator IC gives constant +12V output whereas 7805 regulator IC gives +5V output.
Power LED indicator shows power status of the circuit.s
HC-SR04 Ultrasonic Sensor

HC-SR04 is an ultrasonic sensor which can be used for remote measurement of


physical quantities via ultrasonic waves. Human ear don’t have ability to detect
ultrasonic waves. This module has an ability to detect distance from 2 to 400 cm
correctly and can be easily connected with the microcontroller. HC-SR04 has low power
consumption which makes it suitable choice for robotic and automatic control systems.

An ultrasonic transmitter sends a radio frequency of 40 KHz in the air at the


speed of approximately 340 meter per second and the receiver receives the reflected
signal from the object. Distance between the transmitter and the object can be
calculated by simple calculation by considering the time (t) taken by the ultrasonic wave
to travel from transmitter and received back (reflected) by the receiver. As speed of
ultrasonic wave in air is fixed and known so distance (d) can be calculated by using the
following equation.

d = 340 *0.5 t

Ultrasonic sensor HC-SR04 has got four pins as shown in picture.

HC-SR04 Ultrasonic Distance Sensor Module


Technical Specifications:

Working voltage 5V DC

Working current max 15 ma

Working frequency 40KHZ

Temperature 0º to 60º Ambient room temperature

Output signal 0-5V (Output high when obstacle in range)

Sentry Angle max 15 degree

Sentry Distance 2 cm - 500 cm

High-accuracy 0.3cm

Input trigger signal 10us TTL impulse

Echo signal output TTL PWL signal

Size 45*20*15 mm

Weight 25gm
SERVO MOTOR

A Servo Motor is a small device that has an output shaft. This shaft can
be positioned to specific angular positions by sending the servo a coded
signal. As long as the coded signal exists on the input line, the servo will
maintain the angular position of the shaft. If the coded signal changes, the
angular position of the shaft changes. The control wire is used to specify the
angle. The angle is determined by the duration of a pulse that is applied to
the control wire. This is called Pulse Coded Modulation.

Servo motors work on servo mechanism that uses position feedback to


control the speed and final position of the motor. Internally, servo motor has
a motor, feedback circuit, controller and other electronic circuit. It provides
position feedback. This feedback signal is compared with input control signal
( for desired position of the motor ) and produces the error signal (if there
exists any difference between them).
Servo Motor Working Block Diagram :

Software Description :

Arduino IDE Software

 IDE stands for Integrated Development Environment. It is a text editor that lets you to
write, compile and upload code on to arduino. Every program file is called a sketch
and contains all the code that you write for your projects. Every file has an extension
of .ino. The code is written in basic c++ format and is human readable. So if the code
is written in the readable form, how does the machine understand it? Well, that is
precisely what the IDE is responsible for. The internal process of compilation
translates the code that you write to a format that the machine (microcontroller)
understands. It generates a Hex File.

We can install Arduino IDE software from arduino.cc website. It is open source
and you can install it for windows / linux operating system. We need to check our
computer configuration to select proper working software.
Arduino IDE environment is mainly distributed into three sections

 1. Menu Bar
 2. Text Editor
 3. Output Window

As you download and open the IDE software, it will appear like an image below.
As you go to the preference section and check the compilation section, the Output Pane
will show the code compilation as you click the upload button.

 Edit – Used for copying and pasting the code with further modification for font
 Sketch – For compiling and programming
 Tools – Mainly used for testing projects. The Programmer section in this panel is
used for burning a bootloader to the new microcontroller.
 Help – In case you are feeling skeptical about software, complete help is available
from getting started to troubleshooting.
Variable declaration rules:

1. A variable name cannot have a space or special characters, except for underscore(_).
2. A variable name can be alphanumeric in nature
3. A variable name cannot start with a number. It would have to start with an alphabet
character or ‘_’
4. A variable name can contain uppercase and lowercase characters
5. You cannot use a keyword (example ‘int’,’void’ and so on) as a variable name

Working With Arduino IDE


//Arduino sketch

void setup()
{
//runs once
}
void loop()
{
//repeats
}

Basically Arduino sketch consists of two main functions namely

1. void setup()

2. void loop()

1. void setup(): setup () is called when a sketch starts. It is used to initialize


variables, pin modes, start using libraries etc. The setup () will only run once, after
each power up or reset of the Arduino board.

Syntax:

void setup ()

Statements;

2. void loop():
After creating a setup () function which initializes and sets the initial values, the loop ()
function does precisely what its name suggests, and loops consecutively, allowing your
program to change and respond. It is used to actively control the Arduino board.

Syntax:

void loop ()

Statements;

Steps to write,compile,upload program.


1. Start the Arduino editor and from the File menu select Preferences to display the
screen shown below. Find and select the option to 'Show verbose output during;'
and tick the 'compilation' check box. With this option selected, the Editor will
show a trace of each step of the compilation process.

2. Create a new file and write your arduino code

3. Verify/Compile Arduino Code


4. Check proper board that you are using.

5. Check board port connection (it will be active when board is detected by computer
automatically)
6. Upload Code if it is compiled successfully

Schematic Diagram :
Schematic Description :
Trigger Pin of HC-SR04 is connected to Pin 2 and Echo Pin is connected to Pin 3.
Servo motor’s data pin is connected to Pin number 9 of the arduino. LED indicator is
connected to Pin 13 of microcontroller. Regulated 5V supply is given to all the
peripherals. 12V 1A dc adapter is used to provide power supply for all the units.

Coding :
#include <NewPing.h>
#include <Servo.h> //header file
Servo myservo; // create servo object to control a servo
int i;

#define TRIGGER_PIN 2
#define ECHO_PIN 3
#define MAX_DISTANCE 400

int LED=13;

// NewPing setup of pins and maximum distance


NewPing sonar(TRIGGER_PIN,ECHO_PIN,MAX_DISTANCE);
void setup()
{
pinMode(LED,OUTPUT);
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
delay(50);
unsigned int distance = sonar.ping_cm();
Serial.print("Distance:");
Serial.print(distance);
Serial.println("cm");
delay(100);
if(distance>0 && distance<=20)
{
digitalWrite(LED,HIGH);
for(i=0;i<=180;i++)
{
myservo.write(i); // sets the servo position to specific angle value
delay(15);
}
delay(5000); //ms

for(i=180;i>=0;i--)
{
myservo.write(i); // sets the servo positionto specific value
delay(15);
}
digitalWrite(LED,LOW);
}

} Conclusion & Future Scope

The proposed prototype model is designed and tested with all it’s features.
Ultrasonic Sensor used gives maximum detection range upto 4 meters (13 feet). It can
be thus useful in real time for any object distance purpose.

We can also use waterproof ultrasonic sensor for robust use in real time
application. We can provide internet access to the project application so that data can
be sent to IOT server. GPS can provide location information so that we can also locate
dust bin in google map. For dust bin requiring high power for lifting, we can use dc
motor based electric linear actuators.

The prototype is inexpensive, easy to install in vehicle. It has very few electronic
components.
WEBSITES REFERENCE
1. Arduino.cc
2. Circuitdigest.com
3. Engineersgarage.com
4. Researchgate.net
5. Slideshare.net

You might also like