13 Garbage

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 61

IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

IOT BASED GARBAGE MONITORING USING ARDUINO

By
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Chapter Name Page no

Table of contents 5
Table of figures 5
List of tables 5
Introduction 6
Hardware Requirements 8
Design and Modelling 15
Implementation 16
System Testing 23
Conclusion 25
Experiment Results 26
References 27
List of Figures Page No

1. Flow Chart of Project 7


2. Arduino Uno Board 9
3. HC-SR04 Ultrasonic Sensor 11
4. GSM Module 13
5. DHT11 pin diagram 14
6. Pin out of NodeMCU 14
7. NodeMCU 15
8. Project diagram 16
9. Circuit diagram 16
10. Circuit diagram of NodeMCU 17
11. Screenshot of output 22
12. Actual circuit of NodeMCU 22
13. Output of sensor in serial monitor 26
14. Output as a Text Message 26
List of Tables Page No
1. Specification of Arduino 9
2. Pin number And their function 10
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

1. INTRODUCTION

We are living in an age where tasks and systems are fusing together with the power of IOT to
have a more efficient system of working and to execute jobs quickly! With all the power at our
finger tips this is what we have come up with.The Internet of Things (IoT) shall be able to
incorporate transparently and seamlessly a large number of different systems, while providing
data for millions of people to use and capitalize. Building a general architecture for the IoT is
hence a very complex task, mainly because of the extremely large variety of devices, link layer
technologies, and services that may be involved in such a system. One of the main concerns with
our environment has been solid waste management which impacts the health and environment of
our society. The detection, monitoring and management of wastes is one of the primary problems
of the present era. The traditional way of manually monitoring the wastes in waste bins is a
cumbersome process and utilizes more human effort, time and cost which can easily be avoided
with our present technologies. This is our solution, a method in which waste management is
automated. This is our IoT Garbage Monitoring system, an innovative way that will help to keep
the cities clean and healthy.

1.1 The problem

Nowadays, there are tons of flats and apartments which have been built in the rapid urbanization
area. This is due to high housing demands which have been drastically risen as a result of
migration from villages to cities to find work. In order to accommodate the growing population
in the urban area, the government has also constructed more apartment complexes. There are
several issues faced by the residents of the flats. One of them is disposal of solid waste. Unlike
private houses, the residents of all the apartments use a common dustbin, which tends to fill up
very quickly. This overflowing of garbage is a sanitary issue which might cause diseases like
cholera and dengue. Moreover it is a waste of fuel to travel around a complex or an area to find
that some of the garbage are filled and some are not. Also, on rare days, problems might arise
that there is so much garbage that the truck doesn’t have enough capacity. The idea struck us
when we observed that the garbage truck use to go around the town to collect solid waste twice a
day. Although this system was thorough it was very inefficient. For example let's say street A is
a busy street and we see that the garbage fills up really fast whereas maybe street B even after
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

two days the bin isn't even half full. This example is something that actually happens thus it lead
us to the ''Eureka'' moment!

Figure 1: Flow chart of project

What our system does is it gives a real time indicator of the garbage level in a trashcan at any
given time. Using that data we can then optimize waste collection routes and ultimately reduce
fuel consumption. It allows trash collectors to plan their daily/weekly pick up schedule.
An Ultrasonic Sensor is used for detecting whether the trash can is filled with garbage or not.
Here Ultrasonic Sensor is installed at the top of Trash Can and will measure the distance of
garbage from the top of Trash can and we can set a threshold value according to the size of trash
can.
If the distance will be less than this threshold value, means that the Trash can is full of garbage
and we will print the message “Basket is Full” on the message and if the distance will be more
than this threshold value, then we will print the distance remaining for the garbage vat to be full.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

2. HARDWARE REQUIREMENTS

We will need the following hardware to accomplish our project.


1. HC-SR04 ultrasonic sensor.
2. Arduino Uno.
3. GSM module
4. Connecting wires.

2.1 ARDUINO UNO

Arduino is an open-source platform used for building electronics projects. Arduino consists of
both a physical programmable circuit board (often referred to as a microcontroller) and a piece of
software, or IDE (Integrated Development Environment) that runs on your computer, used to
write and upload computer code to the physical board.
• The Arduino platform has become quite popular with people just starting out with
electronics, and for good reason. Unlike most previous programmable circuit boards, the
Arduino does not need a separate piece of hardware (called a programmer) in order to
load new code onto the board – you can simply use a USB cable. Additionally, the
Arduino IDE uses a simplified version of C++, making it easier to learn to program.
Finally, Arduino provides a standard form factor that breaks out the functions of the
micro-controller into a more accessible package. The Arduino is a microcontroller board
based on the ATmega8. It has 14 digital -input/output pins (of which 6 can be used as
PWM outputs), 6 analog inputs, a16 MHz ceramic resonator, a USB connection, a power
jack, an ICSP header, and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it with a AC-
to-DC adapter or battery to get started .The Uno differs from all preceding boards in that
it does not use the FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2
(Atmega8U2 up to version R2) programmed as a USB-to-serial converter .Revision 2 of
the Uno board has a resistor pulling the 8U2HWB line to ground, making it easier to put
into DFU mode. Revision of the board has the following new features:
• Pin out: added SDA and SCL pins that are near to the AREF pin and two other new pins
placed near to the RESET pin, the IOREF that allow the shields to adapt to the voltage
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

provided from the board. In future, shields will be compatible with both the board that
uses the AVR, which operates with 5V and with the Arduino Due that operates with
3.3V. The second one is a not connected pin that is reserved for future purposes.
• Stronger RESET circuit.
• AT mega 16U2 replace the 8U2.
"Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno
and version 1.0 will be the reference versions of Arduino, moving forward. The Uno is the latest
in a series of USB Arduino boards, and the reference model for the Arduino platform.

Figure 2: ARDUINO UNO BOARD

Parameters For Arduino UNODescription


Microcontroller ATmega328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 14
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 32KB(ATmega328) of which 0.5KB used by
bootloader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16MHz
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Length 68.6 mm

Width 53.4 mm
Weight 53gm
Table 1. Specifications of Arduino

2.2 HC-SR04 ULTRASONIC SENSOR.

HC-SR04 is an ultrasonic sensor which is used for measuring the distance between the top of the
lid to the top of the garbage.

PIN NUMBER PIN NAME DESCRIPTION

1. VCC The Vcc pin powers the sensor, typically with +5V
2. Trigger Trigger pin is an Input pin. This pin has to be kept high
for 10us to initialize measurement by sending US
wave.
3. Echo Echo pin is an Output pin. This pin goes high for a
period of time which will be equal to the time taken for
the US wave to return back to the sensor.
4. GND This pin is connected to the Ground of the system.
Table 2: Pin Number and Function of Ultrasonic sensor

2.2.2 HC-SR04 SENSOR FEATURES.

• Operating voltage: +5V


• Theoretical Measuring Distance: 2cm to 450cm
• Accuracy: 3mm
• Measuring angle covered: <15°
• Operating Current: <15ma
• Operating Frequency: 40Hz
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

2.2.3 ULTRASONIC SENSOR WORKING

The HC-SR04 Ultrasonic (US) sensor is a 4 pin module, whose pin names are Vcc, Trigger,
Echo and Ground respectively. This sensor is a very popular sensor used in many applications
where measuring distance or sensing objects are required. The module has two eyes like projects
in the front which forms the Ultrasonic transmitter and Receiver. The sensor works with the
simple high school formula that

Distance = Speed × Time

The Ultrasonic transmitter transmits an ultrasonic wave, this wave travels in air and when it gets
objected by any material it gets reflected back toward the sensor this reflected wave is observed
by the Ultrasonic receiver module.Now, to calculate the distance using the above formulae, we
should know the Speed and time. Since we are using the Ultrasonic wave we know the universal
speed of US wave at room conditions which is 330m/s. The circuitry inbuilt on the module will
calculate the time taken for the US wave to come back and turns on the echo pin high for that
same particular amount of time, this way we can also know the time taken. Now simply calculate
the distance using a microcontroller or microprocessor.

Figure 3: HCSR04 ULTRASONIC SENSOR

2.3 GSM MODULE.

GSM/GPRS module is used to establish communication between a computer and a GSM-


GPRS system. Global System for Mobile communication (GSM) is an architecture used for
mobile communication in most of the countries. Global Packet Radio Service (GPRS) is an
extension of GSM that enables higher data transmission rate. GSM/GPRS module consists of a
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

GSM/GPRS modem assembled together with power supply circuit and communication
interfaces (like RS-232, USB, etc) for computer. GSM/GPRS MODEM is a class of wireless
MODEM devices that are designed for communication of a computer with the GSM and GPRS
network. It requires a SIM (Subscriber Identity Module) card just like mobile phones to
activate communication with the network. Also they have IMEI (International Mobile
Equipment Identity) number similar to mobile phones for their identification. A GSM/GPRS
MODEM can perform the following operations:
1. Receive, send or delete SMS messages in a SIM.
2. Read, add, search phonebook entries of the SIM.
3. Make, Receive, or reject a voice call.
The MODEM needs AT commands, for interacting with processor or controller, which are

communicated through serial communication. These commands are sent by the

controller/processor. The MODEM sends back a result after it receives a command. Different AT

commands supported by the MODEM can be sent by the processor/controller/computer to

interact with the GSM and GPRS cellular network.

A GSM modem is a wireless modem that works with a GSM wireless network. A wireless
modem behaves like a dial-up modem. The main difference between them is that a dial-up
modem sends and receives data through a fixed telephone line while a wireless modem sends and
receives data through radio waves.
A GSM modem can be an external device or a PC Card / PCMCIA Card. Typically, an external
PC Card / PCMCIA Card is designed for use with a laptop computer. It should be inserted into
one of the PC Card / PCMCIA Card slots of a laptop computer. Like a GSM mobile phone, a
GSM modem requires a SIM card from a wireless carrier in order to operate.
A SIM card contains the following information:
• Subscriber telephone number (MSISDN)
• International subscriber number (IMSI, International Mobile Subscriber Identity)
• State of the SIM card
• Service code (operator)
• Authentication key
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

• PIN (Personal Identification Code)


• PUK (Personal Unlock Code)
Computers use AT commands to control modems. Both GSM modems and dial-up
modems support a common set of standard AT commands. In addition to the standard AT
commands, GSM modems support an extended set of AT commands. These extended AT
commands are defined in the GSM standards. With the extended AT commands, the
following operations can be performed:
• Reading, writing and deleting SMS messages.
• Sending SMS messages.
• Monitoring the signal strength.
• Monitoring the charging status and charge level of the battery.
• Reading, writing and searching phone book entries.

Figure 4: GSM MODULE

2.4.DHT11 sensor:

DHT11 is a Humidity and Temperature Sensor, which generates calibrated digital output.
DHT11 can be interface with any microcontroller like Arduino, Raspberry Pi, etc. and get
instantaneous results. DHT11 is a low cost humidity and temperature sensor which provides high
reliability and long term stability. The DHT11 Humidity and Temperature Sensor consists of 3
main components. A resistive type humidity sensor, an NTC (negative temperature coefficient)
thermistor (to measure the temperature) and an 8-bit microcontroller, which converts the analog
signals from both the sensors and sends out single digital signal. This digital signal can be read
by any microcontroller or microprocessor for further analysis.DHT11 Humidity Sensor consists
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

of 4 pins: VCC, Data Out, Not Connected (NC) and GND. The range of voltage for VCC pin is
3.5V to 5.5V. A 5V supply would do fine. The data from the Data Out pin is a serial digital data.
DHT11 Sensor can measure a humidity value in the range of 20 – 90% of Relative Humidity
(RH) and a temperature in the range of 0 – 500C. The sampling period of the sensor is 1 second.
All the DHT11 Sensors are accurately calibrated in the laboratory and the results are stored in the
memory. A single wire communication can be established between any microcontroller like
Arduino and the DHT11 Sensor. Also, the length of the cable can be as long as 20 meters. The
data from the sensor consists of integral and decimal parts for both Relative Humidity (RH) and
temperature.

Figure 5: DHT 11 pin out

2.3.5 Node MCU:

NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266Wi-Fi
SoC from Espressif Systems, and hardware which is based on the ESP-12 module. The term
"NodeMCU" by default refers to the firmware rather than the development kits. The firmware
uses the Lua scripting language. It is based on the eLua project, and built on the Espress-if Non-
OS SDK for ESP8266. It uses many open source projects, such as lua-cjson, and spiffs.

Figure 6: NodeMCU PINOUT


IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Node MCU provides a way to connect different sensors to their controllers wirelessly via wifi.
Since, it is an improved version of the ESP8266 it has better and easier programming, with better
voltage stability and more reliability.

Figure 7: Node MCU

3. DESIGN AND MODELLING

In this section we design structure of the system before implementation of circuit. we use
advanced microcontroller called Arduino (ATmega8). It has in built with many components like
analog to digital converter, clock of 16 MHz, shift registers.
In this project we put the ultrasonic sensor on top of the garbage bin/ dump. The output of the
ultrasonic sensor is processed by the Arduino and the output is then sent to the GSM module
which sends a text message to the concerned person. We have a threshold value of 5cm.Which
means that if the distance of the sensor from the top of the garbage is less than 5cm, the output
will come with a message that the basket is full. Also, a buzzer will ring if output is less than
5cm. The DHT11 sensor will show the temperature and the humidity.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Figure 8: project diagram

4. IMPLEMENTATION

4.1 Hardware implementation

Connections of the ultrasonic sensor with the Arduino are very simple. Connect the VCC and the
ground of the ultrasonic sensor to the 5V and the ground of the Arduino. Then connect the TRIG
and ECHO pin of ultrasonic sensor to the pin 11 and 12 of the Arduino respectively(you can use
any other pin as well).Connect the RX pin of the arduino with the TX pin of the GSM module
and the TX pin of the arduino with the RX pin of the GSM module. Connect the GND of the
arduino to the ground of the module. Also,the GSM module needs an external 12v supply.

Figure 9: circuit diagram


IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Figure 10: circuit diagram of node MCU with DHT11 and HCSR04

The ESP8266 is the name of a micro controller designed by Espressif Systems. The
ESP8266 itself is a self-contained WiFi networking solution offering as a bridge from
existing micro controller to WiFi and is also capable of running self-contained applications.
This module comes with a built in USB connector and a rich assortment of pin-outs. With a
micro USB cable, you can connect NodeMCU devkit to your laptop and flash it without any
trouble, just like Arduino. It is also immediately breadboard friendly.

Getting Started User Guide


IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

1. Specification:
 Voltage:3.3V.
 Wi-Fi Direct (P2P), soft-AP.
 Current consumption: 10uA~170mA.
 Flash memory attachable: 16MB max (512K normal).
 Integrated TCP/IP protocol stack.
 Processor: Tensilica L106 32-bit.
 Processor speed: 80~160MHz.
 RAM: 32K + 80K.
 GPIOs: 17 (multiplexed with other functions).
 Analog to Digital: 1 input with 1024 step resolution.
 +19.5dBm output power in 802.11b mode
 802.11 support: b/g/n.
 Maximum concurrent TCP connections: 5.

2. Pin Definition:
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

3. Using Arduino IDE


The most basic way to use the ESP8266 module is to use serial commands, as the chip is basically a WiFi/Serial
transceiver. However, this is not convenient. What we recommend is using the very cool Arduino ESP8266
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO
project, which is a modified version of the Arduino IDE that you need to install on your computer. This makes it
very convenient to use the ESP8266 chip as we will be using the well-known Arduino IDE. Following the below
step to install ESP8266 library to work in Arduino IDE environment.

3.1 Install the Arduino IDE 1.6.4 or greater


Download Arduino IDE from Arduino.cc (1.6.4 or greater) - don't use 1.6.2 or lower version! You can use your
existing IDE if you have already installed it.
You can also try downloading the ready-to-go package from the ESP8266-Arduino project, if the proxy is giving
you problems.

3.2 Install the ESP8266 Board Package


Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs
field in the Arduino v1.6.4+ preferences.

Click ‘File’ -> ‘Preferences’ to access this panel.


Next, use the Board manager to install the ESP8266 package.

4 www.handsontec.com
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Click ‘Tools’ -> ‘Board:’ -> ‘Board Manager…’ to access this panel.
Scroll down to ‘ esp8266 by ESP8266 Community ’ and click “Install” button to install the ESP8266 library
package. Once installation completed, close and re-open Arduino IDE for ESP8266 library to take effect.

3.3 Setup ESP8266 Support


When you've restarted Arduino IDE, select ‘Generic ESP8266 Module’ from the ‘Tools’ -> ‘Board:’ dropdown
menu.

Select 80 MHz as the CPU frequency (you can try 160 MHz overclock later)

5 www.handsontec.com
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Select ‘115200’ baud upload speed is a good place to start - later on you can try higher speeds but 115200 is a
good safe place to start.

Go to your Windows ‘Device Manager’ to find out which Com Port ‘USB-Serial CH340’ is assigned to. Select
the matching COM/serial port for your CH340 USB-Serial interface.

6 www.handsontec.com
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Find out which Com Port is assign for CH340 Select the correct Com Port as indicated on ‘Device Manager”

Note: if this is your first time using CH340 “ USB-to-Serial ” interface, please install the driver first before
proceed the above Com Port setting. The CH340 driver can be download from the below site:

https://github.com/nodemcu/nodemcu-devkit/tree/master/Drivers

3.4 Blink Test

We'll begin with the simple blink test.


Enter this into the sketch window (and save since you'll have to). Connect a LED as shown in Figure3-1.

void setup() {
pinMode(5, OUTPUT); // GPIO05, Digital Pin D1
}

void loop() {
digitalWrite(5, HIGH);
delay(900);
digitalWrite(5, LOW);
delay(500);
}

Now you'll need to put the board into bootload mode. You'll have to do this before each upload. There is no
timeout for bootload mode, so you don't have to rush!

 Hold down the ‘Flash’ button.


 While holding down ‘ Flash’, press the ‘RST’ button.
 Release ‘RST’, then release ‘Flash’

7 www.handsontec.com
 When you release the ‘RST’ button, the blue indication will blink once, this means its ready to bootload.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Once the ESP board is in bootload mode, upload the sketch via the IDE, Figure 3-2.

Figure3-1: Connection diagram for the blinking test

8 www.handsontec.com
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Figure 3.2: Uploading the sketch to ESP8266 NodeMCU module.


The sketch will start immediately - you'll see the LED blinking. Hooray!

3.5 Connecting via WiFi

OK once you've got the LED blinking, let’s go straight to the fun part, connecting to a webserver. Create a new
sketch with this code:
Don’t forget to update:
const char* ssid = "yourssid";
const char* password = "yourpassword";
to your WiFi access point and password, then upload the same way: get into bootload mode, then upload code
via IDE.

/*
* Simple HTTP get webclient test
*/

#include <ESP8266WiFi.h>
const char* ssid = "handson"; // key in your own SSID
const char* password = "abc1234"; // key in your own WiFi access point
password

9 www.handsontec.com
const char* host = "www.handsontec.com";

void setup() { IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO


Serial.begin(115200);
delay(100);

// We start by connecting to a WiFi network

Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

int value = 0;

void loop() {
delay(5000);
++value;

Serial.print("connecting to ");
Serial.println(host);

// Use WiFiClient class to create TCP connections


WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}

// We now create a URI for the request


String url = "/projects/index.html";
Serial.print("Requesting URL: ");
Serial.println(url);

// This will send the request to the server


client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(500);

// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}

Serial.println();
Serial.println("closing connection");
}

10 www.handsontec.com
Open up the IDE serial console at 115200 baud to see the connection and webpage printout!
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

That's it, pretty easy right ! This section is just to get you started and test out your module.

11 www.handsontec.com
4. Flashing NodeMCU Firmware on the ESP8266 using Windows
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Why flashing your ESP8266 module with NodeMCU?


NodeMCU is a firmware that allows you to program the ESP8266 modules with LUA script. And you’ll
find it very similar to the way you program your Arduino. With just a few lines of code you can establish a
WiFi connection, control the ESP8266 GPIOs, turning your ESP8266 into a web server and a lot more.
In this tutorial we are going to use another ESP8266 module with pin header adapter board which is breadboard
friendly.

ESP8266 Module Breadboard Friendly with Header Connector

4.1 Parts Required:

 ESP8266 Module Breadboard Friendly


 PL2303HX USB-UART Converter Cable
 Some Male-to-Female Jumper Wires

4.2 Pin Assignment:

12 www.handsontec.com
4.3 Wiring:
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

ESP8266 Pin Description


CH_PD Pull high, connect to Vcc +3.3V
Vcc Power Supply +3.3V
TXD Connect to RXD (white) of PL2303HX USB-Serial converter cable
RXD Connect to TXD (Green) of PL2303HX USB-Serial converter cable
GPIO0 Pull low, connect to GND pin
GND Power Supply ground

4.4 Downloading NodeMCU Flasher for Windows

After wiring your circuit, you have to download the NodeMCU flasher. This is a .exe file that you can download
using one of the following links:
 Win32 Windows Flasher
 Win64 Windows Flasher

You can find all the information about NodeMCU flasher here.

4.5 Flashing your ESP8266 using Windows

Open the flasher that you just downloaded and a window should appear (as shown in the following figure).

13 www.handsontec.com
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Press the button “Flash” and it should start the flashing process immediately, showing the Module MAC address
if successful connected.

After finishing this flashing process, it should appear a green circle with a check icon at lower left corner.

Your ESP8266 module is now loaded with NodeMCU firmware.

14 www.handsontec.com
5. Getting Started with the ESPlorer IDE
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

ESPlorer is an IDE (Integrated Development Environment) for ESP8266 devices. It‟s a multi platform IDE, can
be used in any OS environment, this simply means that it runs on Windows, Mac OS X or Linux.
Supported platforms:
 Windows(x86, x86-64)
 Linux(x86, x86-64, ARM soft & hard float)
 Solaris(x86, x86-64)
 Mac OS X(x86, x86-64, PPC, PPC64)

This software allows you to establish a serial communications with your ESP8266 module, send commands, and
upload code and much more.

Requirements:
 You need to have JAVA installed in your computer. If you don’t have, go to this website:
http://java.com/download, download and install the latest version. It requires JAVA (SE version 7 and above)
installed.
 In order to complete the sample project presented in this Guide you need to flash your ESP8266 with
NodeMCU firmware. Refer to chapter-4 in this guide on how to flash the NodeMCU firmware.
Main Resources:
 ESPlorer Homepage: http://esp8266.ru/esplorer/
 GitHub Repository: https://github.com/4refr0nt/ESPlorer

5.1 Installing ESPlorer

Now let’s download the ESPlorer IDE, visit the following URL: http://esp8266.ru/esplorer/#download
Grab the folder that you just downloaded. It should be named “ESPlorer.zip” and unzip it. Inside that folder you
should see the following files:

Execute the “ESPlorer.jar” file and the ESPlorer IDE should open after a few seconds (the “ESPlorer.jar” file
is what you need to open every time you want to work with the ESPlorer IDE).

15 www.handsontec.com
Note: If you’re on Mac OS X or Linux you simply use this command line in your terminal to run the
ESPlorer: sudo java –jar ESPlorer.jar. IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO
When the ESPlorer first opens, that’s what you should see:

Here‟s a rundown of the features the ESPlorer IDE includes:


 Syntax highlighting LUA and Python code.
 Code editor color themes: default, dark, Eclipse, IDEA, Visual Studio.
 Undo/Redo editors features.
 Code Autocomplete (Ctrl+Space).
 Smart send data to ESP8266 (without dumb send with fixed line delay), check correct answer from ESP8266
after every lines.
 Code snippets.
 Detailed logging.
 And a lot more…

The ESPlorer IDE has a couple of main sections, let‟s break it down each one.
In the top left corner you can see all the regular options that you find in any software. Create a New file, Open a
new file, Save file, Save file as, Undo, Redo, etc.

16 www.handsontec.com
In the top right corner you have all the options you need to establish a serial communication (you‟re going to
learn how to use them later in this Guide). IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

This next screenshot shows your Code Window, that‟s where you write your scripts (your scripts are highlighted
with your code syntax).

Below the Code Window, you have 12 buttons that offer you all the functions you could possible need to interact
with your ESP8266. Here‟s the ones you‟ll use most: “Save to ESP” and “Send to ESP”.

This screenshot shows the Output Window which tells you exactly what‟s going on in your ESP8266. You can
see errors and use prints in your code to debug your projects.

17 www.handsontec.com
5.2 Schematics
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

To upload code to your ESP8266, you should connect your ESP8266 to your PL2303HX USB-UART
Programming Cable like the figure below:

5.3 Writing Your Lua Script

Below is your script to blink an LED.


lighton=0
pin=4
gpio.mode(pin,gpio.OUTPUT)
tmr.alarm(1,2000,1,function()
if lighton==0 then
lighton=1
gpio.write(pin,gpio.HIGH)
else
lighton=0
gpio.write(pin,gpio.LOW)
end
end)

Right now you don‟t need to worry how this code works, but how you can upload it to your ESP8266.

18 www.handsontec.com
Having your ESP8266+PL2303HX Programmer connected to your computer, go to the ESPlorer IDE:
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Look at the top right corner of your ESPlorer IDE and follow these instructions:
1. Press the Refresh button.
2. Select the COM port for your FTDI programmer.
3. Select your baudrate.
4. Click Open.

Then in the top left corner of your ESPlorer IDE, follow these instructions:
1. Select NodeMCU
2. Select Scripts
3. Create a new filled called “init.lua”

19 www.handsontec.com
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Copy your Lua script to the code window (as you can see in the Figure below):

The next step is to save your code to your ESP8266!


At the left bottom corner click the button “Save to ESP”.
In your output window, it should start showing exactly which commands are being sent to your ESP8266 and it
should look similar to the Figure below.

20 www.handsontec.com
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Note: If you want to delete your “init.lua” file, you can do that easily. Simply type file.remove(“init.lua”) and
press the button “Send” (see Figure above). Or you can type the command file.format() to remove all the files
saved in your ESP8266. You can type any commands and send them to your ESP8266 through that window.
After uploading your code to your ESP8266, unplug your ESP8266 from your computer and power up the
ESP8288 module.

Congratulations, you‟ve made it! The blue LED at the upper right corner should be blinking every 2 seconds!

21 www.handsontec.com
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO
6. NodeMCU GPIO for Lua

The GPIO(General Purpose Input/Output) allows us to access to pins of ESP8266 , all the pins of
ESP8266 accessed using the command GPIO, all the access is based on the I/O index number on
the NoddMCU dev kits, not the internal GPIO pin, for example, the pin „D7‟ on the NodeMCU
dev kit is mapped to the internal GPIO pin 13, if you want to turn „High‟ or „Low‟ that particular
pin you need to called the pin number „7‟, not the internal GPIO of the pin. When you are
programming with generic ESP8266 this confusion will arise which pin needs to be called during
programming, if you are using NodeMCU devkit, it has come prepared for working with Lua
interpreter which can easily program by looking the pin names associated on the Lua board. If
you are using generic ESP8266 device or any other vendor boards please refer to the table below
to know which IO index is associated to the internal GPIO of ESP8266.

Nodemcu ESP8266 Pin Nodemcu dev ESP8266 Pin


dev kit kit
D0 GPIO16 D7 GPIO13
D1 GPIO5 D8 GPIO15
D2 GPIO4 D9 GPIO3
D3 GPIO0 D10 GPIO1
D4 GPIO2 D11 GPIO9
D5 GPIO14 D12 GPIO10
D6 GPIO12

D0 or GPIO16 can be used only as a read and write pin, no other options like PWM/I2C
are supported by this pin.

In our example in chapter 5 on blinking the blue LED, the blue LED in connected to GPIO2, it
is defined as Pin4 (D4) in Lua script.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

4.2 Software implementation.


The software required for it is the Arduino IDE.

4.2.1 ARDUINO IDE


The open-source Arduino Software (IDE) makes it easy to write code and upload it to the
board. It runs on Windows, Mac OS X, and Linux. The environment is written in Java and
based on Processing and other open-source software. This software can be used with any
Arduino board. The Arduino development environment contains a text editor for writing
code, a message area, a text console, a toolbar with buttons for common functions, and a
series of menus. It connects to the Arduino hardware to upload programs and communicate
with them.Software written using Arduino are called sketches. These sketches are written in
thetext editor. Sketches are saved with the file extension .ino. It has features for
cutting/pastingand for searching/replacing text. The message area gives feedback while
saving and exportingand also displays errors. The console displays text output by the
Arduino environmentincluding complete error messages and other information. The bottom
right-hand corner ofthe window displays the current board and serial port. The toolbar
buttons allow you to verifyand upload programs, create, open, and save sketches, and open
the serial monitor.

6.1 Introduction to Arduino IDE

Arduino is a prototype platform (open-source) based on an easy-to-use hardware and


software. It consists of a circuit board, which can be programmed (referred to as a microcontroller)
and a ready-made software called Arduino IDE (Integrated Development Environment), which is
used to write and upload the computer code to the physical board.

The key features are:

 Arduino boards are able to read analog or digital input signals from different sensors and
turn it into an output such as activating a motor, turning LED on/off, connect to the cloud
and many other actions.

 You can control your board functions by sending a set of instructions to the
microcontroller on the board via Arduino IDE (referred to as uploading software).
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

 Unlike most previous programmable circuit boards, Arduino does not need an extra
piece of hardware (called a programmer) in order to load a new code onto the board. You
can simply use a USB cable.

 Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn
to program.

 Finally, Arduino provides a standard form factor that breaks the functions of the micro-
controller into a more accessible package.

After learning about the main parts of the Arduino UNO board, we are ready to learn howto set up
the Arduino IDE. Once we learn this, we will be ready to upload our program onthe Arduino board.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

6.1.1 Arduino data types:

Data types in C refers to an extensive system used for declaring variables or functions of
different types. The type of a variable determines how much space it occupies in the storage and how
the bit pattern stored is interpreted.

The following table provides all the data types that you will use during Arduinoprogramming.

Void:

The void keyword is used only in function declarations. It indicates that the function is
expected to return no information to the function from which it was called.

Example:

Void Loop ( )

// rest of the code

Boolean:

A Boolean holds one of two values, true or false. Each Boolean variable occupies one byte of
memory.

Example:

Boolean state= false ; // declaration of variable with type boolean and initialize it with
false.
IOT BASED
Boolean state = true ; // declaration of GARBAGE MONITORING
variable with SYSTEM
type boolean and USING ARDUINO
initialize it with
false.

Char:A data type that takes up one byte of memory that stores a character value. Character literals
are written in single quotes like this: 'A' and for multiple characters, strings use double quotes:
"ABC".

However, characters are stored as numbers. You can see the specific encoding in the ASCII
chart. This means that it is possible to do arithmetic operations on characters, in whichthe ASCII
value of the character is used. For example, 'A' + 1 has the value 66, since theASCII value of the
capital letter A is 65.

Example:

Char chr_a = ‘a’ ;//declaration of variable with type char and initialize it with character a. Char

chr_c = 97 ;//declaration of variable with type char and initialize it with character 97

Unsigned char:

Unsigned char is an unsigned data type that occupies one byte of memory. The unsigned
char data type encodes numbers from 0 to 255.

Example:

Unsigned Char chr_y = 121 ; // declaration of variable with type Unsigned char and initialize
it with character y

Byte:

A byte stores an 8-bit unsigned number, from 0 to 255.

Example:

byte m = 25 ;//declaration of variable with type byte and initialize it with 25


int: IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Integers are the primary data-type for number storage. int stores a 16-bit (2-byte) value. This
yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1).

The int size varies from board to board. On the Arduino Due, for example, an int stores a 32-
bit (4-byte) value. This yields a range of -2,147,483,648 to 2,147,483,647 (minimum value of
-2^31 and a maximum value of (2^31) - 1).

Example:

int counter = 32 ;// declaration of variable with type int and initialize it with 32.

Unsigned int:

Unsigned ints (unsigned integers) are the same as int in the way that they store a 2 byte value.
Instead of storing negative numbers, however, they only store positive values, yielding a useful range
of 0 to 65,535 (2^16) - 1). The Due stores a 4 byte (32-bit) value, ranging from 0 to 4,294,967,295
(2^32 - 1).

Example:

Unsigned int counter= 60 ; // declaration of variable with type unsigned int and initialize it
with 60.

Word:

On the Uno and other ATMEGA based boards, a word stores a 16-bit unsigned number.
On the Due and Zero, it stores a 32-bit unsigned number.

Example

word w = 1000 ;//declaration of variable with type word and initialize it with 1000.
Long: IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Long variables are extended size variables for number storage, and store 32 bits (4 bytes),
from 2,147,483,648 to 2,147,483,647.

Example:

Long velocity= 102346 ;//declaration of variable with type Long and initialize it with 102346

Unsigned long:Unsigned long variables are extended size variables for number storage and store 32
bits (4 bytes). Unlike standard longs, unsigned longs will not store negative numbers, making their
range from 0 to 4,294,967,295 (2^32 - 1).

Example:

Unsigned Long velocity = 101006 ;// declaration of variable with type Unsigned Long and
initialize it with 101006.

Short:

A short is a 16-bit data-type. On all Arduinos (ATMega and ARM based), a short stores a 16-
bit (2-byte) value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum
value of (2^15) - 1).

Example:

short val= 13 ;//declaration of variable with type short and initialize it with 13

Float:

Data type for floating-point number is a number that has a decimal point. Floating-point
numbers are often used to approximate the analog and continuous values because they have greater
resolution than integers.
IOTasBASED
Floating-point numbers can be GARBAGE
large as MONITORING
3.4028235E+38 and asSYSTEM USING ARDUINO
low as 3.4028235E+38.
They are stored as 32 bits (4 bytes) of information.

Example:

float num = 1.352;//declaration of variable with type float and initialize it with 1.352.

Double:

On the Uno and other ATMEGA based boards, Double precision floating-point number
occupies four bytes. That is, the double implementation is exactly the same as the float, with no gain
in precision. On the Arduino Due, doubles have 8-byte (64 bit) precision.

Example:

double num = 45.352 ;// declaration of variable with type double and initialize it with 45.352.

In this section, we will learn in easy steps, how to set up the Arduino IDE on our
computerand prepare the board to receive the program via USB cable.

Step 1: First you must have your Arduino board (you can choose your favorite board) anda USB
cable. In case you use Arduino UNO, Arduino Duemilanove, Nano, Arduino Mega 2560, or Diecimila,
you will need a standard USB cable (A plug to B plug), the kind youwould connect to a USB printer
as shown in the following image.

Figure 5.12: USB Cable


IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO
Step 2: Download Arduino IDE Software.

You can get different versions of Arduino IDE from the Download page on the Arduino
Official website. You must select your software, which is compatible with your operating system
(Windows, IOS, or Linux). After your file download is complete, unzip the file.

Step 3: Power up your board.

The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power from
either, the USB connection to the computer or an external power supply. If you are using an Arduino
Diecimila, you have to make sure that the board is configured to draw power from the USB
connection. The power source is selected with a jumper, a small piece of plastic that fits onto two of
the three pins between the USB and power jacks. Check that it is on the two pins closest to the USB
port. Connect the Arduino board to your computer using the USB cable. The green power LED
(labeled PWR) should glow.

Step 4: Launch Arduino IDE.


IOT BASED
After your Arduino IDE software GARBAGE MONITORING
is downloaded, you need to SYSTEM USING
unzip the ARDUINO
folder. Inside the
folder, you can find the application icon with an infinity label (application.exe). Doubleclick the icon
to start the IDE.

Step 5: Open your first project.

Once the software starts, you have two options:


 Create a new project.
 Open an existing project example.

To create a new project, select File --> New.To open


IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

To open an existing project example, select File -> Example -> Basics -> Blink.
IOTofBASED
Here, we are selecting just one GARBAGE
the examples withMONITORING SYSTEM
the name Blink. USING
It turns the ARDUINO
LED on and
off with some time delay. You can select any other example from the list.

Step 6: Select your Arduino board.

To avoid any error while uploading your program to the board, you must select the
correct Arduino board name, which matches with the board connected to your computer.

Go to Tools -> Board and select your board

Here, we have selected Arduino Uno board according to our tutorial, but you must select the
name matching the board that you are using

Step 7: Select your serial port.


Select the serial device of theIOT BASEDboard.
Arduino GARBAGE
Go toMONITORING SYSTEM
Tools ->Serial Port USING
menu. ARDUINO
This is likely
to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find
out, you can disconnect your Arduino board and re-open the menu, the entry that disappears should
be of the Arduino board. Reconnect the board and select that serial port.

Step 8: Upload the program to your board.


IOTupload
Before explaining how we can BASEDour
GARBAGE
programMONITORING
to the board, SYSTEM
we must USING ARDUINO
demonstrate the
function of each symbol appearing in the Arduino IDE toolbar.

A- Used to check if there is any compilation error.

B- Used to upload a program to the Arduino board.

C- Shortcut used to create a new sketch.

D- Used to directly open one of the example sketch.

E- Used to save your sketch.

F- Serial monitor used to receive serial data from the board and send the serial data to the
board.

Now, simply click the "Upload" button in the environment. Wait a few seconds; you will see the
RX and TX LEDs on the board, flashing. If the upload is successful, the message "Done uploading"
will appear in the status bar.

Note: If you have an Arduino Mini, NG, or other board, you need to press the reset button
physically on the board, immediately before clicking the upload button on the Arduino Software.

Arduinoprogramming stracture
In this chapter, we will studyIOT BASEDthe
in depth, GARBAGE
ArduinoMONITORING SYSTEM
program structure andUSING ARDUINO
we will learn more
new terminologies used in the Arduino world. The Arduino software is open-source. The source code
for the Java environment is released under the GPL and the C/C++ microcontroller libraries are under
the LGPL.

Sketch: The first new terminology is the Arduino program called “sketch”.

Structure

Arduino programs can be divided in three main parts: Structure, Values (variables and
constants), and Functions. In this tutorial, we will learn about the Arduino software program, step by
step, and how we can write the program without any syntax or compilation error.

Let us start with the Structure. Software structure consist of two main functions:
 Setup( ) function
 Loop( ) function
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Void setup ( )

PURPOSE:

The setup() function is called when a sketch starts. Use it to initialize the variables, pin
modes, start using libraries, etc. The setup function will only run once, after each power up or reset
of the Arduino board.

INPUT
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO
OUTPUT

RETURN

Void Loop ( )

PURPOSE:

After creating a setup() function, which initializes and sets the initial values, the loop() function
does precisely what its name suggests, and loops secutively, allowing your program to change and
respond. Use it to activelycontrol the Arduino board.

INPUT

OUTPUT

RETURN
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

4.2.2 Source Code

#include <SoftwareSerial.h>
#include <DHT.h>
#define DHTPIN 2

#define DHTTYPE DHT11


constint buzzer = 6; //buzzer to arduino pin 6
DHT dht(DHTPIN, DHTTYPE);

SoftwareSerialmySerial(9, 10);
inttrigPin = 12;
constintechoPin = 11;
intchk;
float hum; //Stores humidity value

float temp;
// defines variables
long duration;
int distance;
void setup() {
pinMode(buzzer, OUTPUT);
mySerial.begin(9600); // Setting the baud rate of GSM Module
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
dht.begin();

delay(100);
}
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
if (distance==5)
{
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(1000); // ...for 1 sec
noTone(buzzer); // Stop sound...
delay(1000);
Serial.print("Distance: ");
Serial.println(distance);
Serial.print(" cm");

hum = dht.readHumidity();
temp= dht.readTemperature();

//Print temp and humidity values to serial monitor


Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

Serial.println(" Celsius");
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+917059759945\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("Distance: ");// The SMS text you want to send
mySerial.print(distance);
mySerial.print(" cm ");// The SMS text you want to send
mySerial.println("Humidity: ");// The SMS text you want to send
mySerial.print(hum);
mySerial.print(" %, Temp: ");// The SMS text you want to send
mySerial.print(temp);
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(5000);

delay(2000);
}
}

4.2.3 Blynk app

Blynk is a Platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes
over the Internet.It's a digital dashboard where you can build a graphic interface for your
project by simply dragging and dropping widgets.Blynk is not tied to some specific board or
shield. Instead, it's supporting hardware of your choice. Whether your Arduino or Raspberry Pi
is linked to the Internet over Wi-Fi, Ethernet or this new ESP8266 chip, Blynk will get you
online and ready for the Internet Of Your Things. Blynk was designed for the Internet of Things.
It can control hardware remotely, it can display sensor data, it can store data, visualize it and do
many other cool things.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

There are three major components in the platform:


• Blynk App - allows to you create amazing interfaces for your projects using various
widgets we provide.
• Blynk Server - responsible for all the communications between the smart phone and
hardware. You can use our Blynk Cloud or run your private Blynk server locally. It’s
open-source, could easily handle thousands of devices and can even be launched on a
Raspberry Pi.
• Blynk Libraries - for all the popular hardware platforms - enable communication with
the server and process all the incoming and out coming commands.

Source code for dht11 and NodeMCU shown via Blynk:

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "DHT.h" // including the library of DHT11 temperature and humidity sensor
#include <SimpleTimer.h> //including the library of SimpleTimer
#define DHTTYPE DHT11 // DHT 11

#define dht_dpin 14
DHT dht(dht_dpin, DHTTYPE);
SimpleTimer timer;
charauth[] = "Your Auth. Key"; // You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).

charssid[] = "Your Wifi Network name"; // Your WiFi credentials.


char pass[] = "Password of your network"; // Set password to "" for open networks.
float t; // Declare the variables
float h;

void setup()
{
Serial.begin(9600);// Debug console
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(2000, sendUptime);
}
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

voidsendUptime()
{

float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.println("Humidity and temperature\n\n");
Serial.print("Current humidity = ");
Serial.print(h);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(t);
Blynk.virtualWrite(V0, t);
Blynk.virtualWrite(V1, h);

void loop()
{
Blynk.run();
timer.run();
}

Figure 11: screenshot of output in Blynk Figure 12: circuit of hcsr04 with NodeMCU
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

5. SYSTEM TESTING
5.1 Test approach
We will test the project in two stages: software and hardware. The software part is to be tested
via the Arduino IDE, whereas the hardware part has to be tested physically. It is necessary to
check whether the system is working properly or not. To check whether the readings are
accurate, we will check the distance pointed out by the sensor by a meter tape.

5.2 Features to be tested


After building the whole circuit we test it, testing procedure is given in 5.1. This project should
satisfy some features. Features to be tested as follows:
• The ultrasonic sensor should give proper output. To check whether the output is accurate
or not, the output of the sensor will be checked against a meter tape.
• The arduino board should show the distance in the serial monitor. So should the
NodeMCU.
• The GSM module should send messages after the specified delay. If the text messages are
reaching the phone, that means the GSM module is working. It should make a small
ringing sound, when it sends messages.
• The DHT11 sensor should work properly and show its output in the serial monitor.
• The blynk app should be checked.

5.2.2 Testing tools and environment


For testing of the project we require some tools, like to test Arduino program we require a
software called Arduino IDE. Using this we can check the program that program is working
properly or not. For hardware checking we require power supply and proper range of
measurements and a meter tape. The garbage dump should have only solid waste.
The NodeMCU should connect to the Blynk app and the app should show the output. For this
,theNodeMCU must connect first to the wifi hotspot.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

5.3 Test cases.


In this section we discuss about the inputs, expected output, testing procedure.
5.3.1 Inputs
This project requires three inputs:
1. Power supply:Power supply is the basic need of any electronic circuit. Here we use
5v dc battery to give power Arduino and sometimes we can give power directly from
the computer. We also need a 12V power supply for the GSM module.
2. We can also power these circuits via two 9v batteries using a circuit divider.Distance,
The distance will be the input of the Arduino circuit and will be gotten from the
ultrasonic sensor.
3. The temperature and humidity from the DHT11 sensor.

5.3.2 Expected output


The expected output of this project should be a text message showing the distance to full. Also,
it will also send the humidity and the temperature of the area. The output should also be seen on
the serial monitor of the Arduino IDE. Also, the output should also be seen on the serial monitor
and also on the Blynk app.

5.3.3 Testing procedure:


For testing first connect the circuit to the power supply is given to the Arduino using computer
and it can be done by using battery. In this way the whole testing circuit is built. Now we give
input to the HC-SR04 by changing the level of solid garbage.. Change in garbage levels should
be messaged using GSM Module.
Summary of testing procedure:-
1 ) Connect the circuit according to the diagram
2) Give power to the system.
3) Vary garbage level for the ultrasonic sensor to give output.
4) Get the output from the DHT11 sensor.
5) Send message via the GSM module.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

6. CONCLUSION.
We built an efficient garbage monitoring system which can be used to monitor the level of
garbage in the dump. This data can be further used to plan garbage collection trips more
efficiently, ultimately reducing overflowing bins and helping have better public sanitation.

Advantages:
• Very simple circuit.
• The HCSR04 sensor is very rugged.
• Helps monitor garbage levels.
• Uses very small amount of electricity.
• Ultimately helps in better planning of garbage pickups.
• Can help in reducing overflowing bins.
• Reduces trips to areas where the bins still have a lot of capacity.

Disadvantages:
• Cannot detect liquid waste.
• Only detects the top of the garbage level. It wouldn’t realize if there is space left.
• GSM module needs a 12v source.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

7. Experiment Results

Figure 13: Output as a text message on phone.


Figure 14: Output of sensor in serial monitor

The output of this project should have been the values of the distance, temperature and humidity,
which we were supposed to get via a text message. For, the GSM Module to send data, the
sensors must be working perfectly which can be seen in figure 13. This brings us to figure 14 in
which we see the text messages sent from the GSM Module. Also, the output in Blynk app is
shown in figure 11, which shows the real time data on the app, via WIFI.
IOT BASED GARBAGE MONITORING SYSTEM USING ARDUINO

REFERENCES

• Navghane S S, Killedar M S and Rohokale D V 2016 IoT Based Smart Garbage and
waste collection, International Journal of Advanced Research in Electronics And
Communication.
• Monika K A, Rao N, Prapulla S B and Shobha G 2016 Smart Dustbin-An
EfficientGarbage Monitoring System International Journal of Engineering Science
andComputing 6 7113-16.
• Medvedev A, Fedchenkov P, Zaslavsky A, Anagnostopoulos T and Khoruzhnikov
S,2015 Waste management as an IoT-enabled service in smart cities In Conference on
Smart Spaces Springer International Publishing 104-15.
• www.buildofy.in/smart_home_designs
• https://create.arduino.cc/projecthub/Technovation/smart-garbage-monitoring-system-
using-arduino-101-3b813c
• https://github.com/sourabhdeshmukh/Smart-Dustbin
• http://invent.module143.com/temperature-and-humidity-using-nodemcu-blynk/
• http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/what-is-
virtual-pins
• http://help.blynk.cc/getting-started-library-auth-token-code-examples/blynk-basics/how-to-
display-any-sensor-data-in-blynk-app
• http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/esp8266/nodemcu

You might also like