Download as pdf or txt
Download as pdf or txt
You are on page 1of 52

POLITECNICO DI MILANO

Master Of Science in Computer Science and Engineering


School of Industrial and Information Engineering

IoT-BASED SMART BIN SIMULATION


SYSTEM FOR WASTE MANAGEMENT

Supervisor: Prof. Alessandro Enrico Cesare Redondi

Author:
Wendy Katherine Garcia Cruz,
Student ID 873132

Academic Year 2017-2018


To God, the owner of my life. To my mom, my dad, my brother and my
fiancee. Without your support and patience I could not have done it.
Acknowledgements

In this special occasion I would like to thank Prof. Alessandro Redondi,


who was an enormous support for me since the beginning of this project
and with his guidance, patience and help I could develop this work. I also
want to extend my gratitude to all professors of Politecnico Di Milano for
everything they taught me, this two years have been highly formative and
have make me grow professional and personally.
I want to thank Prof. Oscar Acosta, who have been supporting me
along the development of the master and tutoring me to reinforce concepts
required to sustain my studies.
All my gratitude for my colleagues and friends in the university, they
became my family here and gave me the strength to carry on.
A very special thanks to my family, who have been supporting me from
the distance, and my fiancee, for his patience and will to let me grow in
every aspect of my life even in the distance.
Finally I want to thank God for giving me the opportunity to move out
of my confort zone and conquer new goals.
Contents

Abstract 2

Sommario 3

1 Introduction 5
1.1 Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Smart bins and waste management . . . . . . . . . . . . . . . 6
1.3 Thesis Structure . . . . . . . . . . . . . . . . . . . . . . . . . 7

2 Related Work 9

3 Technological Background 13
3.1 IEEE 802.11 standard . . . . . . . . . . . . . . . . . . . . . . 13
3.2 MQTT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.1 The publish/subscribe pattern . . . . . . . . . . . . . 15
3.2.2 Scalability . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2.3 Message filtering . . . . . . . . . . . . . . . . . . . . . 16
3.2.4 Quality of Service (QoS) . . . . . . . . . . . . . . . . . 16
3.3 Node-RED . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.4 SQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4 System Implementation 21
4.1 Bin generator . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 MQTT connection . . . . . . . . . . . . . . . . . . . . . . . . 26
4.3 SQLite database . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4 Node-RED flows . . . . . . . . . . . . . . . . . . . . . . . . . 26

5 System Analysis and evaluation 30


5.1 Analysis of bins according to its usage . . . . . . . . . . . . . 30
5.2 Simulator Performance . . . . . . . . . . . . . . . . . . . . . . 35

6 Conclusions 42

5
7 Future Work 43
List of Figures

3.1 MQTT Protocol . . . . . . . . . . . . . . . . . . . . . . . . . 15


3.2 Topics in MQTT . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.3 QoS 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4 QoS 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5 QoS 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6 Basic flow in Node-RED . . . . . . . . . . . . . . . . . . . . . 18
3.7 Configuring charts in Node-RED dashboard . . . . . . . . . . 19
3.8 Example of Node-RED dashboard [13] . . . . . . . . . . . . . 19

4.1 Normal distributions according to low and very low usage. . . 22


4.2 Normal distributions according to mid, high and very high
usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3 Percentage of waste per hour. . . . . . . . . . . . . . . . . . . 24
4.4 KD Tree algorithm. . . . . . . . . . . . . . . . . . . . . . . . . 24
4.5 Diagram algorithm for data generation. . . . . . . . . . . . . 25
4.6 Flow for displaying the main page. . . . . . . . . . . . . . . . 27
4.7 Flow for displaying the map into the main page. . . . . . . . 27
4.8 Main page dashboard. . . . . . . . . . . . . . . . . . . . . . . 28
4.9 Flow for displaying bin status. . . . . . . . . . . . . . . . . . 28
4.10 Dashboard for bin status. . . . . . . . . . . . . . . . . . . . . 29

5.1 Very high usage bin height. . . . . . . . . . . . . . . . . . . . 30


5.2 Very high usage bin weight. . . . . . . . . . . . . . . . . . . . 31
5.3 High usage bin height. . . . . . . . . . . . . . . . . . . . . . . 31
5.4 High usage bin weight. . . . . . . . . . . . . . . . . . . . . . . 32
5.5 Mid usage bin height. . . . . . . . . . . . . . . . . . . . . . . 32
5.6 Mid usage bin weight. . . . . . . . . . . . . . . . . . . . . . . 33
5.7 Low usage bin height. . . . . . . . . . . . . . . . . . . . . . . 33
5.8 Low usage bin weight. . . . . . . . . . . . . . . . . . . . . . . 34
5.9 Very low usage bin height. . . . . . . . . . . . . . . . . . . . . 34
5.10 Very low usage bin weight. . . . . . . . . . . . . . . . . . . . . 34

7
5.11 Height for all type of bins. . . . . . . . . . . . . . . . . . . . . 35
5.12 Weight for all types of bins. . . . . . . . . . . . . . . . . . . . 35
5.13 CPU performance without the simulator and with 2500 bins . 37
5.14 memory performance without the simulator and with 2500 bins 37
5.15 Disk performance without the simulator and with 2500 bins. . 38
5.16 Simulation time according to the amount of bins . . . . . . . 39
5.17 Solid state disk performance. . . . . . . . . . . . . . . . . . . 40
5.18 Solid state disk performance. . . . . . . . . . . . . . . . . . . 41
Abstract

With the new technologies emerging in development for IoT, smart bins
are becoming a need for waste management field. Be able to control the
status of containers to guarantee a cleaner environment, as well as improve
waste collection process is a must. For people working in waste recollection,
it would be very useful to know where they should go to collect it and
avoid wasting time when there is no need to pick it up. Also knowing the
weight would be useful to know if some additional person will be needed to
perform the task. Implementation of this system may improve quality of
life, but creating a lot of bins to prove the effectivity of the system, as well
as feasibility, is expensive and it is also difficult, especially for researching
groups, which cannot create them in mass. To solve this issue, in this
project, a smart bin simulator system is presented. This simulator allows
to generate data for weight and size of garbage into the bins, as well as
providing them a position in the space and verify its behavior according to
their location. Likewise, it adopts an schedule for picking up waste, and also
takes into account the times in which bins are not used, to give them a more
realistic performance. Visualization and recording of data is also displayed
by using Node-RED, which is a flow based programming tool through which
information is received from a broker and then shown in a dashboard, so
that analysis of the bins behavior can be easily done.

2
Sommario

Con le nuove tecnologie emergenti nello sviluppo per l’IoT, i contenitori


intelligenti stanno diventando un bisogno per il settore della gestione dei
rifiuti. Essere in grado di controllare lo stato dei contenitori per garan-
tire un ambiente più pulito, nonche migliorare il processo di raccolta dei
rifiuti eùn must. Per le persone che lavorano nel raccoglimento dei rifiuti,
sarebbe molto utile sapere dove dovrebbero andare a ritirarlo ed evitare di
perdere tempo quando non c’è bisogno di raccoglierlo. Anche conoscere il
peso sarebbe utile e sapere se sarà necessario qualche persona aggiuntiva per
eseguire l’operazione.
L’implementazione di questo sistema può migliorare la qualità della vita,
ma, creare molti contenitori per dimostrare l’efficacia del sistema, cosı̀ come
la fattibilità, è costoso ed è anche difficile, soprattutto per i gruppi di ricerca,
che non possono crearli in massa. Per risolvere questo problema, in questo
progetto, viene presentato un sistema di simulatore di contenitori intelli-
genti. Questo simulatore consente di generare dati per il peso e la dimen-
sione della spazzatura nei cassonetti, oltre a fornire loro una posizione nello
spazio e verificarne il comportamento in base alla loro posizione. Allo stesso
modo, adotta un programma per la raccolta dei rifiuti e tiene anche conto dei
tempi in cui i contenitori non vengono utilizzati, per offrire loro prestazioni
più realistiche. La visualizzazione e la registrazione dei dati vengono an-
che visualizzate utilizzando Node-RED, uno strumento di programmazione
basato sul flusso dei dati, attraverso il quale le informazioni vengono ricevute
da un broker e quindi visualizzate in un dashboard, in modo che l’analisi del
comportamento dei contenitori possa essere facilmente eseguita.

3
Chapter 1

Introduction

1.1 Context

The Internet of Things (IoT) is a novel paradigm use widely especially in


wireless telecommunications, which consist basically in taking advantage of
pervasiveness in all kind of devices, equipped with Radio-Frequency IDentifi-
cation (RFID), tags, sensors, actuators, mobile phones, among others. These
devices are able to communicate with each other and achieve a common goal,
which provides intelligent services for users by the usage of communication
modules and different network technologies with unique addressing schemes
[3].
Internet of Things (IoT) field is increasing rapidly because of the numerous
applications in many different sectors, such as industry, medicine, daily life
among others. Nowadays, one of the most common applications is the de-
velopment of different devices oriented to smart cities, which are growing to
improve quality of life for citizens, trying to understand their behaviors and
be able to supply their needs and improve their comfort. This is done by
using sensors and collecting information to monitor and manage efficiently
different types of services. The main objective of this smart cities is to make
a better use of public resources, increasing the quality of the services and
reducing operational costs [24] .
The amount of data generated by these smart cities is huge, according with
the type of application and the frequency in which data is collected. Data
obtained from sensors is increasing at exponential rate. This information
is heterogeneous, with different scale, complexity, and collection time. As
data increases, there is more complexity for managing and processing it[22]
.

5
One of the most required applications in smart cities is related with waste
management. Waste management is a process which involves collection of
garbage as well as transportation and correct disposal to the appropriate
places. With this purpose, smart bins have been created, by using common
bins and adapting sensors to them, so that weight and waste size are mea-
sured and sent by using a Wi-Fi module so that this information can be
monitored to visualize the behavior of the bins.
Keeping in mind that collecting information every hour, for example, hav-
ing thousands of bins, lots of data are generated. This data generation,
monitoring and storage, consumes large amounts of power, bandwidth and
resources. To diminish costs, it is necessary to perform an analysis of the
obtained data and verify the moments in which it is necessary to collect
information, so that the device can be in sleep mode and so, be able to save
energy and increase the device lifetime, as well as saving storage capacity
and network bandwidth. Moreover, before creating a smart bin system, it is
very important to verify that resources are enough to sustain data collection
and visualization.
Advance Network Technology Laboratory (ANTLab), which is a research
laboratory from Politecnico de Milano is currently developing bin prototypes
to be able to deploy a smart bin system for the university. Nevertheless, it
is not feasible for them to create thousands of bins to evaluate its effectivity
and feasibility. For this reason, this work is devoted for developing a data
simulator that allows to virtually create thousands of bins with different
distributions for weight and size of garbage, as well as simulate waste rec-
ollection days and working times. With this approach it will be possible to
verify if the system can be implemented successfully and if it will be useful
for adequate waste management.

1.2 Smart bins and waste management


Smart Bins are garbage collectors equipped with sensors to verify the quan-
tity in all of them to know the filling levels of the bins, as well as their
weight. These devices are aimed to improve waste collection and save costs
and time, giving information and alerts when bins need to be emptied, so
that users will find bins ready for use and waste collectors will know the
right time to empty containers, without doing extra work. Also, if a bin is
too heavy, stronger people, or collecting cars are going to be ready to pick
them.
Usually load cells and ultrasound or infrared sensors are used in smart bins.
Load cells are transducers which creates electrical signals with a magnitude

6
that is proportional to the weight they are measuring. Ultrasonic and In-
frared sensors measure distances by sending a signal to the measured surface,
and calculate the distance based on the time it takes for the signal to be
reflected by the surface and go back to the reader.
Some of these smart bins also have a GPS device which allows to know where
the bin is and be able to collect the garbage, especially where they are po-
sitioned in very big places, for example into a smart city. These devices
receive signal from GPS satellites and so, they calculate their own position.
These elements are going to be connected to a microcontroller, which is go-
ing to have the logic of the device and is going to be in charge of capture
the data. This data is going to be sent by using a WiFi module to a central
server, which will allow to obtain information of the state of the bin. After
receiving this data, it is usually displayed in different ways (schemas, notifi-
cations, graphs) to the final user and likewise, collected into a database for
future analysis.
By using this bins, it is possible to improve waste management and collec-
tion process, this is due to the fact that obtaining the state of the bins, a
prediction can be performed, so that a recollection route can be created for
picking up garbage according to the predicted amount of waste, also provid-
ing people around smart bin system a cleaner ambience and bins ready to
use all the time.

1.3 Thesis Structure


This thesis is divided into main chapters which are going to cover the de-
velopment and analysis of the simulator.
In the first chapter, introduction to smart cities and smart bins for waste
management was presented.
In the second chapter, the state of the art of this project is going to be
considered, since it is fundamental to understand the related work done by
researchers and how they can provide a strong basis in the development of
this work.
In the third chapter, main topics related with the project are exposed,
so that it gives a basis for a complete understanding of the whole process in
the development of the simulator.
In the fourth chapter, system implementation is going to be explained,
as well as the reasons which motivated the decisions taken in choosing the
algorithms and the tools to develop this work.
In the fifth chapter, results analysis are going to be shown, according
to the behavior of the data generator, as well as the performance of the

7
simulator according with the amount of bins employed.
In the sixth and seven chapter, conclusions and future work are going to
be exposed, so that the system can be improved and used widely.

8
Chapter 2

Related Work

In this chapter, some related work is going to be referenced as the state of


the art for the scope of this project. Several different projects have been
performed, trying to solve waste management problems by incorporating
various technologies, mostly based in smart bins. Nevertheless, even though
it exists some simulation systems, they are not specific for waste manage-
ment, and as it has been seen before, it is very important to simulate the
behavior of the bins and be sure that the system will work properly without
spending lots of money by physically doing smart bins without verifying its
feasibility.
In 2009, Rovetta et al. created an application for use in monitoring of
waste, implementing a network of sensorized waste containers linked to a
data management system. The main objective was to collect and evaluate
data to provide for feasibility analysis of the final device.
For collecting data, a set of sensors was mounted in a container, to monitor
the content and provide an estimation of weight, volume and type of waste.
This data was recorded and forwarded to a management center, which su-
pervised this information and optimized truck routes according to container
content. There were created two sensorized containers to verify the function-
ing and feasibility of the system, because the laboratory was not in capacity
of create an industrial quantity of containers. Information obtained by these
containers was applied to implement truck routing and scheduling to reduce
collection costs and improve waste collection efficiency. In order to generate
these routes, there were placed the two containers in different points to ac-
quire enough data to observe the routes for waste collection. Testing phase
took four months to be performed, and to verify routes, this phase was made
offline by using data already stored in the DB [16]. As containers are big,

9
a smaller number of them are needed for cover the required area, which is
not the same case for bins, so it is not feasible to perform the same kind
of measurements by replacing the existing bins for smart bins around the
whole campus, it is necessary a more practical way to evaluate the system.
More recently, in 2014, Hong et al. have developed and IoT based smart
garbage system, composed of smart bins, routers and servers, but in this
case, this type of smart bins is exclusive for food waste management, so
that people can avoid wasting food and government can control this phe-
nomena and also charge properly those who produce significative amounts
of waste [6]. This shows that smart bins are not only with purpose of waste
collection, but also waste control. In our case, this type of bin is out of the
scope of this project.
In 2015 Sharma et al. described their smart bin implementation, by using
the microcontroller PIC-16F73 and an ultrasonic sensor for measuring the
amount of waste, also assigning a level to them as full, half full and not full.
They also used a GSM module to transmit messages as SMS, later received
by the central waste office. The data received is saved in a DB and then
used for prediction, designed to obtain the time in which the container level
is going to be the maximum, so that the route for waste collection can be
optimized, saving time, money and resources. The visualization of this data
is done by using Microsoft Excel, which receives the content of the SMS in
form of text files that are connected to the excel sheets, which also works as
a dashboard. The widgets of the dashboard are distributed in a map where
bins are positioned according to its coordinates, thanks to the GPS [19]. In
this case, they use historical data to be able to predict behavior of the bins,
but the problem here is the scalability, because for understanding the whole
behavior of the system it is necessary to create all the bins, it is not enough
to use only a few to do so. [21]. A similar approach was used by [8].
As it has been seen in the previous work, these projects have been done over
the basis of prototypes which does not have the full functionality of the sys-
tem, mostly for costs, logistics and the unfeasibility of create a large amount
of bins for obtaining an overall vision of the whole system, also keeping in
mind its performance. Now, some different procedures regarding with data
simulation are going to be presented, as an alternative to evaluate costs and
general behavior of the systems.
In 2014, Catania et al. have proposed an approach based on Smart-M3
platform, for improving solid waste collection, generating agents interacting
in a smart space, which is a virtualization of the real world. Ontologies have
been used to describe relationships between the entities. The components
of a smart space are: semantic information broker (SIB) which is the entry

10
point to the RDF graph, and knowledge processors (KPs), which run on
phisical devices. KPs comunicate to the SIB their data using the Smart
Space Access Protocol (SSAP), protocol which defines a set of messages for
reading or modifying the smart-space. This system generates components
using Python and ontologies with Protg. To test this protocol, commu-
nication between bins and smart space was performed by using sensors of
proximity and weight, connected to a Raspberry PI. If the measured value
exceeds a certain threshold, the measure is updated, indicating measuring
time. To verify the system with a greater amount of nodes, Raspberry PI
generated a random number of bins, with their respective sensors and a
random position. To simulate control center and vehicles, PC was used,
evaluating proximity of the bins to the collecting cars, which have their own
state, and also recognizing the dirtier areas, assigning colors to it according
to the amount of total waste. In order to monitor the behavior of the system,
two Android applications were implemented, one for users and the other for
vehicles [4]. In this case, the approach is very interesting, but limited to
the random generation of bins, and also focused in improve waste collection
according to the location of the vehicles with respect to the bins.
In 2015, Sanjeevi et al. used ArcGIS to create an optimal routing for waste
transportation, which reduce costs and time for collecting garbage, neverthe-
less, it only took into account the distribution of the containers in the city,
more than the volume or weight of waste [17]. In the same way, Medvedev
et al. proposed a Decision Support System for efficient waste collection,
creating a cooperative network for sharing data between truck drivers and
optimizing routes, as well as treating problems such as inaccessible bins,
which happens often when for example, there are problems related with in-
accurate car parking. This system also have a surveillance system to prove
problems in waste collection or verify the cleaning status around the bins
[10]. A similar approach is used in [2]
More recently, in 2017, Likotiko et al. have used a Multi-Agent based models
to abstract real time waste management, to design an architectural model,
based on wireless sensor network (WSN) technology. This project was done
by using Netlogo, which is an open source software to model and simulate
natural and social phenomena, creating a real time waste generation and
collection system, and also showing optimal paths for collection. In this
simulation, waste level per bin is generated by simulation tick in minutes,
its level is updated continuously, users need to pay per waste unit they pro-
duce, so that it can be collected, and the truck needs to follow the optimal
path for collecting garbage. In the map, bins change of color according to
a load threshold. If load is maximum, bin color becomes red and the bin

11
becomes part of the optimal path for the truck. Then the truck empties the
bin and the bin become green (empty) again. Bins were placed randomly,
and citizens behavior is controlled by paying the price per unit waste. In
this project, 25 bins were simulated, so there is no certainty of the number
of bins the system can support. Also, waste is generated by tick per sim-
ulation, and according to people behavior and the amount of money they
should pay per waste unit, which is variable. They are also focusing their
efforts, trying to find the shortest path for collecting, more than simulat-
ing the real behavior of the bins. Besides that, Netlogo is a very generic
simulation system, not specific for waste management [9].

12
Chapter 3

Technological Background

In this chapter we will discuss about the main topics regarding with the
development of the smart bin simulator. In the first section, IEEE 802.11
standard is going to be revised. This standard is generally known as Wi-Fi
and it defines the main aspects that devices need to follow in order to be
Wi-Fi certified. This standard is used to communicate the data generator
with the server. In the second part MQTT protocol is going to be explained,
as well as its importance into the IoT field. Finally, some tools required to
develop this work will be presented.

3.1 IEEE 802.11 standard


IEEE 802.11 Standard defines a medium access control (MAC) sublayer,
MAC management protocols and services, and three physical layers (PHY).
The goal of this standard in to describe a WLAN (Wireless Local Area Net-
work), that deliver services that were only available in wired networks. It
also describes a WLAN that allows transparent mobility and built-in power
saving operations to the network user.
IEEE architecture has some advantages, including being tolerant of faults
in the WLAN equipment and eliminating the bottlenecks produces by a
centralized architecture. It is very flexible and supports easily both small,
transient networks and large permanent or semi-permanent networks. In
addition, deep power-saving modes are built into the architecture and pro-
tocols to prolong the battery life, without losing connectivity [15].
This standard combines the advantages of Wi-Fi and low power sensor net-
work communication technologies. It enables single-hop communication over
distances up to 1000m. Relay access points are used to extend the connec-

13
tivity to Access Points that are two-hops away. It proposes a hierarchical
network organization with a large number of associated stations (STAs), to
improve simplicity and scalability. In order to handle collisions, the 802.11
introduces a RAW-based mechanism that improves the network performance
significantly [1].
It is very difficult to control which devices are receiving the network signal.
For this reason, there must be a software link-level protection, so there are
some security solutions that will preserve the privacy of the network. The
most common solutions are:

• Access Control List: Filters out unknown users and requires a list of
authorized clients MAC addresses to be loaded in the Access Point. If
the address is not registered, it will not be able to communicate with
the Access Point. This is the simplest security measure and can be
easily defeated.

• WEP (Wired Equivalent Privacy): Was the only link-level security


option established in the 802.11 standard. Its purpose was offering a
comparable confidentiality to a traditional wired network. WEP uses
encryption to protect the data and it can use also an access control
method. In a WEP protected wireless network, a data packet that
gets into the link-level needs to be encrypted before sending it off the
air.

• WPA (Wi-Fi Protected Access): It is a solution provided by the Wi-Fi


Alliance, while a definotove security protocol is standardized. Some
security improvements were implemented, such as key hierarchy, which
avoids WPA main key to be exposed. This means that WPA doesnt
use the main key to encrypt, but this main key is used to generate
other keys.

• WPA-PSK (WPA- Pre-Shared Key): In this mode, there is no 802.11


authentication infrastructure, permitting the use of a pre-shared key.
Most of the manufacturers implement only one pre-shared key for the
whole wireless network [23].

For developing this project, an ad hoc WLAN using WPA2-Enterprise was


used, with a network band of 2.4 GHz was used to guarantee communication
between the data generator and the broker, in order to publish and subscribe
messages by using MQTT protocol.

14
3.2 MQTT

MQTT (MQ Telemetry Transport) is a lightweight messaging protocol that


allows to publish/subscribe messages, designed to be used by simple devices
and unreliable networks with low-bandwith and high-latency. Its goal is to
transmit efficiently messages without consuming a lot of resources. This
protocol is ideal for M2M (Machine to Machine) or IoT connected devices
[12].
MQTT protocol is based on TCP/IP. Both the client and the broker need
to have a TCP/IP stack and it use only port 1883.

Figure 3.1: MQTT Protocol

To better understand this protocol, the following characteristics need to


be seen in more detail:

3.2.1 The publish/subscribe pattern

In this pattern, the model decouples the publisher and the subscriber client.
They never contact each other directly, instead, the connection between
them is handled by a broker, which is in charge of filter incoming messages
from publisher and distribute them correctly to subscribers. This works
somehow as subscribing to determined newsletters and receiving via e-mail
the contents of interest. This pattern guarantees space, time and synchro-
nization decoupling. For the scope of this project, MQTT decouples pub-
lisher and subscriber spatially and to publish or receive messages, publisher
and subscriber only need to know the hostname/IP and port of the broker.

15
3.2.2 Scalability
Operations on the broker can be highly parallelize in comparison with tra-
ditional client-server approach, and messages can be processed in an event-
driven way, but if it is necessary to perform a million connections, broker
nodes need to be clustered to distribute adequately and efficiently the load.

3.2.3 Message filtering


Every message contains a topic (subject) that the broker can use to deter-
mine whether a subscriber client receives the message or not. In MQTT
topic refers to an UTF-8 string, that can consist of one or more topic levels,
separated by a forward slash (/): Each topic must contain at least 1 char-

Figure 3.2: Topics in MQTT

acter and they are case sensitive. It is possible to use also wildcards, for
subscribing to messages in single level (+), which replaces one topic level, or
multi level (), which covers many topic levels. It has sort of a tree structure.

3.2.4 Quality of Service (QoS)


Is an agreement between the sender of a message and the receiver that defines
the guarantee of delivery for a specific message. This is defined both for
communication between publisher with broker and broker with subscriber.
There are three levels of QoS in MQTT:

• QoS 0- At most once: This is the minimal QoS level, so theres no


guarantee of deliver, since the receiver does not acknowledge receipt
of the message. It is also called fire and forget.

16
Figure 3.3: QoS 0

• QoS 1- At least once: This level guarantees that a message is delivered


at least one time to the receiver. The sender stores the message until
it receives from the receiver a puback, which acknowledges receipt of
the message.

Figure 3.4: QoS 1

• QoS 2- Exactly once: It is the highest level of service. It guarantees


that the message is received only once. It is safe, but also slower
than the other levels. When publish packet arrives to the receiver,
it replies to the sender with a PUBREC packet, that acknowledges
the publish packet. If the PUBREC is not received by the sender, it
will keep sending the message until receive the acknowledge. Once the
sender receives it, it can discard the publish packet and responds with
a PUBREL packet, so that the receiver can discard the stored states
and finally send a PUBCOM packet, which means that the deliver of
the message was completed [5].

17
Figure 3.5: QoS 2

3.3 Node-RED
Node-RED is a flow-based programming tool, which allows to wire together
different components and it allows to use JavaScript functions. It provides
a visual editor that allows to drag and drop boxes with predetermined and
configurable functions. It is built on Node.js, taking advantage of its event
driven model. This tool is very flexible and allows the user to fully under-

Figure 3.6: Basic flow in Node-RED

stand the data flow, and so, making easier the programming process. Users
dont need to worry about the interfacing code for MQTT, HTTP among
others. It is also equipped with very useful nodes such as MQTT receiver,
which is going to be highly used along the development of this work [14].
Node-red allows to install extra nodes, available to expand its functional-
ity. One of the most used package of nodes is the node-red dashboard.
With these nodes, it is possible to visualize data in a dashboard by means
of graphs, texts, gauges, and also configure elements to trigger events, for
example buttons, sliders, switches, text inputs and so on. Creating the dash-
board is very simple and intuitive as it allows to configure all the elements.
In figure 3.7, there are some options for configuring a graph and in the
right side, there is a hierarchy of elements in the dashboard and the tabs to
which they belong. After configuring the flow, a complete dashboard can be
visualized as in Figure 3.8.

18
Figure 3.7: Configuring charts in Node-RED dashboard

Figure 3.8: Example of Node-RED dashboard [13]

19
3.4 SQLite
SQLite is a self-contained, high-reliability, embedded, full-featured, public-
domain SQL database engine. It manages atomic, consistent, isolated and
durable transactions, even after system crashes. It provides also a simple
and ready to use API, which gives it the flexibility to work with IoT, since
it has a small code footprint, makes efficient use of memory, disk space and
disk bandwidth. It is reliable and does not require maintenance from a
Database Administrator, which allows it to work in devices which needs to
operate without expert support.
SQLite has a different objective than a client/server SQL database, because
the aim of this databases is to implement a shared repository of enterprise
data, while SQLite is mainly focused to provide local data storage for indi-
vidual applications and devices [20]. In this project, an SQLite database is
created locally for populating tables and saving the status of bins per hour,
which allows to have control over the data and verify the behavior of the
system.

20
Chapter 4

System Implementation

In the previous chapters, the importance of waste management, as well as


technologies for supporting it have been analyzed, as well as the technolog-
ical background necessary to develop this project. In this chapter, project
development and implementation are going to be exposed in the following
sections.

4.1 Bin generator


Initially, at the beginning of the search for the most adequate tool for de-
veloping the simulator, Simpy, a framework for creating containers and de-
scribing its behavior was used. The main idea was to create N bins and
put garbage with different sizes, weights and at random instants of time.
Nevertheless, system was consuming a lot of resources and did not allow
to work with a large number of bins. This happened due to the fact that
the process was fine-grained, taking into account the information for each
piece of garbage, so it was necessary to modify the initial idea. Then, the
approach taken was to define a number of bins, that its possible to modify,
and each of the bins were characterized by a determined level of usability,
so, five levels were taken (very-low, low, mid, high and very high usage). To
each level it was assigned a percentage of the total number of bins, which is
also modifiable, but in this case, the relation was generated as follows:
Then, it was also assigned a position to each bin randomly, but delimited
by x and y coordinates, which coincides with the geographic position of the
main campus of the university. This values are constant in all the simula-
tion, because bins does not change position frequently and also because the
usability of the bins generally is determined for its position.

21
Usability Percentage of bins
Very low 10 %
Low 20 %
Mid 40 %
High 20 %
Very high 10 %

Table 4.1: Percentage of bins according to usage.

According to [7] it is assumed that weight and size of each containers


content after a certain time will follow a normal distribution, based on the
central limit theorem, which states that the sum of many stochastic variables
of arbitrary probability distributions, approaches a normal distribution; so,
five different normal distributions have been used for size and weight, ac-
cording to its usage as it can be seen in Figures 4.1 and 4.2.

Figure 4.1: Normal distributions according to low and very low usage.

The values obtained by the daily distribution change every day, as the
amount of garbage is not the same from time to time. As the size of waste is
measured according to the filling percentage of the bin, the maximum filling
value is going to be 100.
Then, after having the values for every bin in a day, it is important to keep
in mind the schedule, since there are hours in which less or no garbage

22
Figure 4.2: Normal distributions according to mid, high and very high usage.

is produced, so bin behavior is defined by a percentage of the total value


distributed per hour as shown in Figure 4.3.
This behavior (B) is the percentage of garbage per hour. Before 7 and
after 22 there is no waste production because this is the time in which
the university is closed. This configuration does not apply to weekends, in
which bin behavior is 0 every hour. This waste is added for each cycle in the
simulation time, so that at the end of the day, the total quantity of garbage
(T ) is the sum of the multiplication of these values by the size (S) or waste
(W ) of each bin (T = S ∗ B) and (T = W ∗ B).
There is also another feature to keep in consideration, which is the fact
that when a bin is full, it is necessary to put the corresponding waste in the
closest bin with enough capacity to receive it. To do so, position of bins and
size of waste are used to redistribute the garbage accordingly and using the
nearest neighbor algorithm to find it.
The applied nearest neighbor algorithm is based in the idea that the kd-tree

23
Figure 4.3: Percentage of waste per hour.

is a binary tree, with nodes that represents an axis- aligned hyperrectangle.


Each node specifies an axis and splits the set of points based in whether the
coordinate along the axis is greater than or less than a particular value. The
tree can be queried for the k closest neighbors of any given point [18]. This
algorithm is illustrated in Figure 4.4.

Figure 4.4: KD Tree algorithm.

In this case kd-tree algorithm was used instead of brute-force, since its
performance is much better in terms of computational complexity. While
brute-Force complexity is O[D(N )2 ], kd-tree complexity is Olog(N ), where
D is the number of dimensions and N is the number of samples. As the
objective of this project is to create bins in a scalable way, it is necessary
to choose an algorithm that is going to perform computations in a faster
way, and bruteforcing requires for each sample to examine the others, cal-

24
culating their distances, sort them and find the smallest one, while kd-tree
as mentioned above, can split space, so that there is no need to go one by
one.

Finally, it is important to consider also the times in which garbage is


recollected, so in this case two days in the week were defined to pick up
waste (Tuesday and Thursday), and an hour to do so (22). Nevertheless,
these parameters can be modified too. When waste is collected, size and
weight of bins are set to 0. In figure 4.5, diagram of the used algorithm for
data generation is shown.

Figure 4.5: Diagram algorithm for data generation.

25
4.2 MQTT connection
Inside the python script containing the algorithms for defining the data
generator, the connection to the broker was also defined. Initially, the client
is defined as well as the broker address and then, connection is established
to the broker. As it has been seen before, the broker is the coordinator
for delivering message from publisher to subscriber. In this case, Mosquitto
broker was used. Eclipse Mosquitto is an open source message broker that
implements MQTT protocol. It is lightweight and is suitable for work in any
device, so its implementation works especially for IoT messaging. Mosquitto
is highly portable and available for a wide range of platforms [11]. After
generating the connection with the broker, messages are published with the
required information so that it can be used and displayed by Node-RED,
which acts as the subscriber to these messages.

4.3 SQLite database


Initially, a database is created in the local storage hard disk and a table to
save the records obtained by the simulator is created. After creating the
table, records are inserted into it. This table has the following data:

• Week (Int): Contains the number of the current week

• Day (Text): Contains the day of the week

• Hour (Int): Contains the sharp hour

• Bin (Text): Contains the name of the bin

• Height (Real): Contains the current height of waste

• Weight (Real): Contains the current weight of waste

4.4 Node-RED flows


To develop a dashboard able to show the obtained results from the data
generator, different flows need to be used. For configuring the main page,
there is some data that must be retrieved by using MQTT node to subscribe
to the established topics.
As shown in Figure 4.6, MQTT nodes (purple) are subscribed to topics
already established by the publisher and connected to a text module which
allows to visualize this data as text in the dashboard. It also has a button

26
Figure 4.6: Flow for displaying the main page.

(blue) which triggers a function that query the database so that it can
retrieve all data saved during the simulation. Also, in the main page, a
map is shown with the position of the bins. Each bin has a different color
according to the amount of waste it has. It works like an alert, so that when
the bin is red, it indicates that the container is full. For doing this, MQTT
node subscribes to all bins with the wildcard, obtaining their names and
position, which then are modified and joined to be a JSON element that
can be sent to the world map node, so that the elements can be placed into
the map. Also, fill percentage per bin is obtained, and so, a color is assigned
according to its status. Finally, this map is shown. This schema can be seen
in Figure 4.7

Figure 4.7: Flow for displaying the map into the main page.

Resulting dashboard obtained for the main page is shown in the Figure 4.8
For the bin page, the used schema is shown in figure 4.9.

27
Figure 4.8: Main page dashboard.

Figure 4.9: Flow for displaying bin status.

28
The idea is to obtain the name of the bin so that its information can
be retrieved. It shows the information in the database regarding with the
current element, as well as the fill percentage and weight, brought using
again MQTT nodes. Information is shown by means of a Gauge and a
chart, which is updated in real simulation time. It allows to have a clear
visualization of each status of the bin. Figure 4.10 shows how the dashboard
is configured.

Figure 4.10: Dashboard for bin status.

29
Chapter 5

System Analysis and


evaluation

For evaluating the obtained results with the simulator, this chapter will be
divided in two parts. The first part will show the behavior of one of the bins
for each distribution according to the usage in a period of two weeks, so that
it can be seen more clearly how this algorithm behaves. In the second part,
the evaluation will be focused in the performance of the simulator, according
with the number of bins required.

5.1 Analysis of bins according to its usage


To start, a small simulation was started to obtain the data and compare
the behavior of each type of container. The first bin that is going to be
analyzed is the very high usage one. The graphic of this behavior in height
and weight is shown below:

Figure 5.1: Very high usage bin height.

30
Figure 5.2: Very high usage bin weight.

In this case, it is possible to see that values between width and height
are correlated, so its behavior is very similar, since when there is a higher
amount of garbage, its weight also increases. In this case, bin is almost full
at the end of the first day (Monday)and it keeps growing until it is full.
Then, bin is emptied and the process start all over again more or less with
the same pattern. After Friday, values are constant during weekends because
this is the period of time in which university is closed. The graph shows
a rapid increase in the amount of waste in the bins, especially at mid day.
The next bin has a high usage, so its behavior is sort of like the previous
one as shown in figures 5.3 and 5.4

Figure 5.3: High usage bin height.

31
Figure 5.4: High usage bin weight.

In this case the mean value is around 70% of the bin capacity. Here it
is also possible to visualize that not all the time values of height and width
are both equivalently large, this happens when the size of waste is large
and weight is not so high and viceversa, for instance, throwing an empty
box, this is the reason for employing different distributions along the day,
giving to the system the possibility to find the largest amount of possible
combinations between weight and height in a determined range. The next
analyzed bin is the mid usage one. Its behavior can be seen in Figures 5.7
and 5.8

Figure 5.5: Mid usage bin height.

In this case, weight is lower than in the previous cases, this is because
the mid value at the end of the day is around 50% of the bin capacity,
so it requires more or less two days to complete the whole capacity. At
the beginning, height value was not so high, so in this case it is important
to keep in consideration that a normal distribution may give also a value
outside the values around the mean, even when it is more probable to be
close to it. On the other hand, It is important to keep in mind that there

32
Figure 5.6: Mid usage bin weight.

exist schedules for picking up waste, which are Tuesday and Thursday at 22,
that is why there is a drop of the values in this period of time for all cases
in both height and weight. The following bin shows a low usage behavior,
with even lower quantities for width and height:

Figure 5.7: Low usage bin height.

For this elements there is another phenomena that is more visible than
in the previous ones. At some point its value increases rapidly, similarly
to the high usage bins, this is because when other containers are full, this
bins which have a lower usage behavior start receiving waste that should
have gone to the higher usage ones. This is visible and comparable in the
peaks before collecting time, in which the previous behavior doesnt seem as
constant as in the previously analyzed bins. Finally, analysis of very low
usage as well as its corresponding graphs is shown in Figures 5.9 and 5.10
In this case, the previously analyzed behavior due to lack of space in
other containers is also visible and even in more detail. Waste deposited is
not so much, until there is no space in the high usage ones, but it is also
important to take into consideration that this behavior not only depends
on the amount of garbage in other bins, but also its position with respect

33
Figure 5.8: Low usage bin weight.

Figure 5.9: Very low usage bin height.

to the others, because normally people will look for the closest container to
deposit waste.
All these phenomena can be seen in figures 5.11 and 5.12, where it is clear
that when bins are full, they continue full until waste is collected, but also
the other bins start increasing its amount of waste during the time the highly
used ones does not have space to collect garbage. With weight is not as clear
than with height, but it is also verifiable. This happens, because weight does
not have a limit in its amount. One can put garbage with any weight if the
space in the bin is enough to do so.

Figure 5.10: Very low usage bin weight.

34
Figure 5.11: Height for all type of bins.

Figure 5.12: Weight for all types of bins.

5.2 Simulator Performance


In this part, the analysis will be concerning about performance of the simu-
lator and the amount of utilized resources to run. For this analysis, different
number of bins are going to be considered.
For knowing the amount of time that the simulation takes to perform its
task, one simulated day performance is going to be evaluated. For checking
performance in the system, a laptop with an Intel Core i5-6200U CPU at
2.30 - 2.40GHz, a RAM 0f 8GB and a jhard disk drive (HDD) with 1TB
was used for evaluate performance. Consumed resources and time are going
to be shown in the table 5.1
Comparison was performed with non functioning system and resources
consumed for it, as well as the running system. There is not a significa-
tive change in Memory and CPU, but in disk, consumption is really high.
Nevertheless, this usage remains constant along the different number of bins.

35
Number of Bins CPU Memory Disk Time
No Running 6% 4.0 GB in use 0-10% of usage 0:00:00
10 10% of usage 4.2 GB in use 95-100% of usage 0:01:13
50 10% of usage 4.2 GB in use 95-100% of usage 0:04:57
100 10% of usage 4.2 GB in use 95-100% of usage 0:09:55
500 10% of usage 4.2 GB in use 95-100% of usage 0:49:20
1000 10% of usage 4.2 GB in use 95-100% of usage 1:39:03
1500 18% of usage 4.2 GB in use 95-100% of usage 2:19:38
2500 40% of usage 5.1 GB in use 95-100% of usage 4:20:00

Table 5.1: Time and resources according to the number of bins

As it has been seen before, there are changes in the system according
to the amount of bins. The disk, which is has the highest usage is more
or less constant for all the cases, but the memory performance changes in
each case. For running this simulator using more than 2500 bins, the system
takes a longer time, but there is a limit in the amount of elements allowed
in the map for the dashboard, which does not allow to draw the bins in the
system
In the following graphs it can be seen the difference between resources
consumption in the system without running the simulator and with 2500
bins. As performance is more or less the same for the evaluated options, it
is not pertinent to show results for every case. This shows that simulator
can run without need of a lot of resources to do so.

36
Figure 5.13: CPU performance without the simulator and with 2500 bins

Figure 5.14: memory performance without the simulator and with 2500 bins

37
Figure 5.15: Disk performance without the simulator and with 2500 bins.

38
Figure 5.16: Simulation time according to the amount of bins

Performance of the system is indeed slow for cases in which the amount
of bins is high, so even though it is feasible to adapt it anywhere, it is
necessary to keep in mind the amount of time required per simulation. The
previous graph shows the relation between time and number of bins.
Nevertheless, seeing that the disk had a very high usage in comparison
with other resources, has created the hypothesis that it could be the bottle-
neck. For this reason, another laptop was used to run it. This laptop was
an Intel Core i5-5257U at 2.70 GHz, with a RAM of 8 Gb and a a solid state
drive (SSD) disk with a capacity of Gb.
In this case, there was a significant change in performance and disk
consumption was not as high as before, as it can be seen in table 5.2.

Number of Bins Time (min)


10 0.127
50 0.5476
100 1.081
500 6.22
1000 14.51
1500 17
2500 29.03

Table 5.2: Time according to the number of bins

39
When performance was visualized, it was noticed that the amount of
disk usage was low in comparison with the case of the HDD as seeing in
figure 5.17

Figure 5.17: Solid state disk performance.

Likewise, in figure 5.18 it can be seen how many time it takes to run the
simulation for different amount of bins. This difference happens because
speed of writing/reading for each disk is different, while speed in HDD is
413 KB/s, in SSD, speed is 2,5 Mb/s. This makes a huge contrast when it
is necessary to write in the disk, as when a row is added to the database.
Speed in each disk depends on the way in which data is written, there are
no moving parts to an SSD, since SSD uses microchips to store information,
while a HDD uses a mechanical arm which has a read/write head. This
makes its speed much slower.

40
Figure 5.18: Solid state disk performance.

41
Chapter 6

Conclusions

In this project, a Smart Bin simulation system was developed to analyze


and verify the feasibility of a real smart system, to manage properly waste
collection and help people to work collecting it to do their job optimizing
time and efforts. It is also meant to keep a cleaner ambience.
Along this work, some different features of smart bins were considering, such
as sensors used for measuring weight and size, so for each bin, this measures
were assigned and reported every hour, according to various distributions,
keeping in mind the usage of these containers. There is also an assigned
quantity for each type of bins that can be modified.
This system allows to define a working schedule, so that it will not show any
change in the values when there is no people around, which will make the
system closer to the real behavior. Also, to improve this realism, position of
bins were determined so that when a bin is full, the closest one can be used
to put waste assign to the previous one if its capacity is enough to handle
it.
All of these features could be shown in a dashboard which allows to monitor
performance of each bin, as well as visualizing it in a map, with colors
according to its waste level, so that it can be used as an alert for knowing
that it is necessary to empty them, and a database to collect information of
status for all the containers.
A good performance was achieved, nevertheless, for being able to simulate
a very large number of bins, it requires a significant amount of time, since
both variables are correlated.

42
Chapter 7

Future Work

This thesis was performed to simulate the status of different types of bins
in a dettermined space. It was meant to be used for creating a real smart
bin system at Politecnico De Milano, but it can be used in other spaces.
Nevertheless, it would be very useful to add a module in which the geometry
of the area in which bins are placed can have different shapes and be adapted
to anywhere.
There is also another feature that would improve waste collection and
that was heavily mentioned in the state of the art, which is to find the more
efficient path for collecting waste, and so, optimize time and resources. By
creating routes for waste collection, the job is going to be easier and more
organized.
Another thing that could be done is to generate an interactive interface
in which user can modify the parameters according to their needs and be
able to adapt the system to any conditions. For example, a rule can be
triggered by the user if when a bin is full, waste is collected immediately.
As in the scope of this project it was only considered the fixed times for
collection, this condition was not used.

43
Bibliography

[1] N Ahmed, H Rahman, and Md I Hussain. A comparison of 802.11 ah


and 802.15. 4 for iot. ICT Express, 2(3):100–102, 2016.

[2] Theodoros Anagnostopoulos, Arkady Zaslavsky, and Alexey Medvedev.


Robust waste collection exploiting cost efficiency of iot potentiality in
smart cities. In Recent Advances in Internet of Things (RIoT), 2015
International Conference on, pages 1–6. IEEE, 2015.

[3] Luigi Atzori, Antonio Iera, and Giacomo Morabito. The internet of
things: A survey. Computer networks, 54(15):2787–2805, 2010.

[4] Vincenzo Catania and Daniela Ventura. An approch for monitoring


and smart planning of urban solid waste management using smart-m3
platform. In Open Innovations Association FRUCT, Proceedings of
15th Conference of, pages 24–31. IEEE, 2014.

[5] HiveMQ. https://www.hivemq.com/blog/mqtt-essentials-part-1-


introducing-mqtt.

[6] Insung Hong, Sunghoi Park, Beomseok Lee, Jaekeun Lee, Daebeom
Jeong, and Sehyun Park. Iot-based smart garbage system for efficient
food waste management. The Scientific World Journal, 2014, 2014.

[7] Ola M Johansson. The effect of dynamic scheduling and routing in a


solid waste management system. Waste management, 26(8):875–885,
2006.

[8] Eunice Likotiko, Dmitry Petrov, Joseph Mwangoka, and Ulrich Hiller-
ingmann. Real time solid waste monitoring using cloud and sensors
technologies. The Online Journal of Science and Technology-January,
8(1), 2018.

[9] Eunice David Likotiko, Devotha Nyambo, and Joseph Mwangoka.


Multi-agent based iot smart waste monitoring and collection architec-
ture. arXiv preprint arXiv:1711.03966, 2017.

44
BIBLIOGRAPHY 45

[10] Alexey Medvedev, Petr Fedchenkov, Arkady Zaslavsky, Theodoros


Anagnostopoulos, and Sergey Khoruzhnikov. Waste management as
an iot-enabled service in smart cities. In Conference on smart spaces,
pages 104–115. Springer, 2015.

[11] Eclipse Mosquitto. https://mosquitto.org/.

[12] MQTT. http://mqtt.org/faq.

[13] Node-RED. https://flows.nodered.org/node/node-red-dashboard.

[14] Node-RED. https://nodered.org.

[15] Bob O’hara and Al Petrick. IEEE 802.11 handbook: a designer’s com-
panion. IEEE Standards Association, 2005.

[16] Alberto Rovetta, Fan Xiumin, Federico Vicentini, Zhu Minghua,


Alessandro Giusti, and He Qichang. Early detection and evaluation
of waste through sensorized containers for a collection monitoring ap-
plication. Waste Management, 29(12):2939–2949, 2009.

[17] V Sanjeevi and P Shahabudeen. Optimal routing for efficient municipal


solid waste transportation by using arcgis application in chennai, india.
Waste Management & Research, 34(1):11–21, 2016.

[18] Scipy. https://docs.scipy.org/doc/scipy-


0.14.0/reference/generated/scipy.spatial.kdtree.html.

[19] Narayan Sharma, Nirman Singha, and Tanmoy Dutta. Smart bin im-
plementation for smart cities. International Journal of Scientific &
Engineering Research, 6(9):787–791, 2015.

[20] SQLite.

[21] Sapna Suryawanshi, Rohini Bhuse, Megha Gite, and Dhanashri Hande.
Waste management system based on iot. Waste Management, 5(03),
2018.

[22] Sapna Tyagi, Ashraf Darwish, and Mohammad Y Khan. Managing


computing infrastructure for iot data. 2014.

[23] Wong. An overview of 802.11 wireless network security standards mech-


anisms. 2014.

[24] Andrea Zanella, Nicola Bui, Angelo Castellani, Lorenzo Vangelista, and
Michele Zorzi. Internet of things for smart cities. IEEE Internet of
Things journal, 1(1):22–32, 2014.

You might also like