• Nenhum resultado encontrado

Aquarium disclosure and monitoring system

N/A
N/A
Protected

Academic year: 2021

Share "Aquarium disclosure and monitoring system"

Copied!
106
0
0

Texto

(1)

Universidade de Aveiro Departamento deElectr´onica, Telecomunica¸c˜oes e Inform´atica, 2017

Ana Madalena de

Almeida Gomes

Barbosa

Sistema de divulga¸

ao e monitoriza¸

ao para

aqu´

arios

(2)
(3)

Universidade de Aveiro Departamento deElectr´onica, Telecomunica¸c˜oes e Inform´atica, 2017

Ana Madalena de

Almeida Gomes

Barbosa

Sistema de divulga¸

ao e monitoriza¸

ao para

aqu´

arios

Aquarium disclosure and monitoring system

Disserta¸c˜ao apresentada `a Universidade de Aveiro para cumprimento dos requisitos necess´arios `a obten¸c˜ao do grau de Mestre em Engenharia de Com-putadores e Telem´atica, realizada sob a orienta¸c˜ao cient´ıfica do Professor Doutor Joaquim Manuel Henriques de Sousa Pinto, Professor Associado do Departamento de Eletr´onica, Telecomunica¸c˜oes e Inform´atica da Universi-dade de Aveiro

(4)
(5)

o j´uri / the jury

presidente / president Professor Doutor Jos´e Luis Guimar˜aes Oliveira

Professor Associado da Universidade de Aveiro

vogais / examiners committee Professor Doutor Fernando Joaquim Lopes Moreira

Professor Associado da Universidade Portucalense

Professor Doutor Joaquim Manuel Henriques de Sousa Pinto

(6)
(7)

agradecimentos A minha fam´ılia e amigos, uma agradecimento especial.`

Um obrigada ao meu orientador, professor Joaquim Sousa Pinto. Ainda aos professores Cl´audio Teixeira do DETI e Rui Rocha do DBio.

(8)
(9)

palavras-chave Internet das Coisas, Ambientes Inteligentes, Monitoriza¸c˜ao de Aqu´ario, Sen-sores

resumo Com a constante evolu¸c˜ao do desenvolvimento tecnol´ogico surge a necessi-dade de criar meios que nos permitam automatizar alguns dos mecanismos aliados `as tarefas do dia-a-dia. ´E cada vez mais frequente depararmo-nos com cen´arios monitorizados e controlados remotamente, aumentando a co-modidade e a intera¸c˜ao entre humanos e objetos. O Laborat´orio para a Inova¸c˜ao e Sustentabilidade dos Recursos Biol´ogicos Marinhos, Ecomare, cont´em aqu´arios com diversas esp´ecies que v˜ao ser alvo de estudo. Um desses aqu´arios foi o cen´ario para o desenvolvimento desta disserta¸c˜ao, sendo o objetivo principal a sua divulga¸c˜ao, monitoriza¸c˜ao e controlo. O sis-tema desenvolvido ´e composto por duas componentes, uma plataforma web e uma aplica¸c˜ao m´ovel. Ambas as plataformas permitem ter acesso aos val-ores lidos, relativamente ao aqu´ario, recolhidos pelos sensores dispon´ıveis. S˜ao emitidos alarmes quando os valores n˜ao correspondem aos esperados, de modo a que seja poss´ıvel uma r´apida atua¸c˜ao sobre o aqu´ario. O sistema foi desenvolvido para permitir aos tratadores do aqu´ario terem um acom-panhamento permanente sobre o mesmo sem terem de se preocupar com uma presen¸ca f´ısica no local.

(10)
(11)

keywords Internet of Things, Smart Environments, Aquarium Monitoring, Sensors

abstract With the constant evolution of technological solutions arises the exigency to create approaches that allow us to automate some of the processes associ-ated to our daily lives. Nowadays, it is more frequent to find many remotely monitored and controlled scenarios, increasing the convenience and inter-action between humans and “things”. The Laboratory for Innovation and Sustainability of Marine Biological Resources, Ecomare, has multiple aquari-ums with several species under study. One of those aquariaquari-ums is the scenario to this dissertation’s development, which main goal is the disclosure, mon-itoring and control of that aquarium. The solution has two components, a web’s platform and a mobile application. Both platforms allow access to the read values, related to the aquarium, collected by the available sensors. When values are not within a pre-defined threshold, alarms are triggered in order to enable a quick response over the aquarium. The solution’s aim is to allow the handlers a permanent monitoring over the aquarium, without the need of a physical presence in the facilities.

(12)
(13)

Contents

1 Introduction 1

1.1 Motivation . . . 1

1.2 Objectives . . . 2

1.3 Software Development Methodology . . . 2

1.4 Document Organisation . . . 3

2 State-of-the-Art 5 2.1 Water Quality Monitoring . . . 5

2.1.1 Potential of Hydrogen . . . 5

2.1.2 Temperature . . . 6

2.1.3 Conductivity . . . 7

2.1.4 Dissolved Oxygen (DO) . . . 8

2.2 Internet of Things . . . 9

2.2.1 Definition . . . 9

2.2.2 IoT Communication Protocols . . . 10

LoRa . . . 10 Sigfox . . . 11 Bluetooth . . . 11 Wi-Fi . . . 11 Zigbee . . . 11 Wi-Fi vs Zigbee . . . 12 Radio Frequency . . . 12

2.2.3 IoT Data Protocols . . . 13

Message Queuing Telemetry Transport (MQTT) . . . 13

Constrained Application Protocol (CoAP) . . . 16

Advanced Message Queuing Protocol (AMQP) . . . 17

Extensible Messaging and Presence Protocol (XMPP) . . . 18

2.2.4 Node-RED . . . 19 2.3 Database . . . 21 2.3.1 Database analysis . . . 21 MySQL . . . 21 MongoDB . . . 21 PostgreSQL . . . 22 2.4 Web Frameworks . . . 24

2.4.1 Web Framework Analysis . . . 24 i

(14)

ii Contents Flask . . . 24 Model-View-Controller Architecture . . . 24 ASP.NET . . . 25 Django . . . 25 2.5 Mobile Frameworks . . . 27

2.5.1 Mobile Frameworks Analysis . . . 28

Ionic . . . 28

PhoneGap . . . 28

2.6 Hardware . . . 31

2.6.1 Raspberry Pi . . . 31

Camera Module v2 . . . 32

Camera Module NoIR v2 . . . 32

2.6.2 Arduino . . . 33

2.6.3 Radio Frequency Module . . . 33

2.6.4 Sensors . . . 34

Temperature and Humidity . . . 34

Brightness . . . 35

2.7 Web services . . . 36

2.8 Web servers . . . 36

2.9 WSGI servers . . . 37

3 Requirements and System Design 39 3.1 Functional Design . . . 39

3.1.1 Functional Requirements . . . 39

3.1.2 Non-Functional Requirements . . . 42

3.1.3 Use Cases Diagram . . . 42

3.2 Adopted Technologies . . . 46 3.3 Techinal Design . . . 48 3.3.1 Architecture Definition . . . 48 3.3.2 Database Diagram . . . 49 4 Implementation 51 4.1 Overview . . . 51 4.2 Aquarium Disclosure . . . 51 4.3 Web Application . . . 54 4.3.1 Sensors Communication . . . 54

4.3.2 Application Programming Interface (API) . . . 55

4.3.3 Interface . . . 57

4.3.4 Deployment . . . 66

4.4 Mobile Application . . . 69

4.4.1 Interface . . . 69

5 Conclusions and Future Work 73

(15)

List of Figures

2.1 Aquatic pH levels . . . 6

2.2 Water temperature influence . . . 6

2.3 Water temperature’s influence in metabolic rate . . . 7

2.4 Salinity tolerance in species . . . 8

2.5 IoT applications . . . 9

2.6 Characteristics Zibgee vs Wi-Fi vs Bluetooth . . . 13

2.7 Message Queuing Telemetry Transport (MQTT) communication . . . 14

2.8 MQTT Publisher-Subscriber Model . . . 15

2.9 Constrained Application Protocol (CoAP) mechanism . . . 17

2.10 Advanced Message Queuing Protocol (AMQP) publish-subscribe mechanism . 17 2.11 Node-RED nodes . . . 20 2.12 Node-RED dashboard . . . 20 2.13 PostgreSQL features . . . 22 2.14 Model-Template-View Architecture . . . 26 2.15 Raspberry Pi 3 Model B . . . 31 2.16 Camera Module v2 . . . 32

2.17 Camera Module Noir v2 . . . 32

2.18 Arduino Nano . . . 33

2.19 Radio Frequency Module HC-12 . . . 34

2.20 RHT03 Temperature and Humidity Sensor . . . 34

2.21 Mini Photocell Sensor . . . 35

2.22 Proxy server . . . 38

2.23 Reverse proxy server . . . 38

2.24 Green Unicorn (Gunicorn) used along with Nginx . . . 38

3.1 Web Platform Use Cases Diagram . . . 43

3.2 Mobile Platform Use Cases Diagram . . . 44

3.3 Architecture Diagram . . . 48

3.4 Database’s Diagram . . . 50

4.1 Application Programming Interface (API) example for GET requests . . . 55

4.2 API - Values read from sensors . . . 55

4.3 API - Existing sensors . . . 56

4.4 API - Detected alarms . . . 56

4.5 API - Values read from temperature sensor . . . 57

4.6 Dashboard page - Last alarms . . . 57 iii

(16)

iv List of Figures

4.7 Dashboard page - Last sensor values . . . 58

4.8 Dashboard page - Last sensor values . . . 58

4.9 Statistics page - Temperature . . . 59

4.10 Statistics page - pH . . . 59

4.11 Statistics page - Temperature graphic with zoom . . . 60

4.12 Statistics page - Daily Temperature . . . 60

4.13 Statistics page - Monthly Average Temperature . . . 60

4.14 Alarms page - Alarms list . . . 61

4.15 Alarms page - Alarms list . . . 61

4.16 Alarms page - Alarms list filter and Export report . . . 62

4.17 Alarms page - Alarms list with filter . . . 62

4.18 Gallery page - Live stream video . . . 63

4.19 Settings page - Sensors list . . . 63

4.20 Settings page - Add sensor . . . 64

4.21 Settings page - Values range for each sensor . . . 64

4.22 Settings page - Edit range of values for a sensor . . . 65

4.23 Django admin page - Database, Users and Groups . . . 65

4.24 Django admin page - Users management . . . 66

4.25 Application Main Page . . . 69

4.26 Last Values Page with Last Alarms . . . 70

4.27 Last Values Page with Last Values collected . . . 70

4.28 Potential of Hydrogen (pH) statistics . . . 71

4.29 pH statistics (with zoom) . . . 71

4.30 Temperature statistics . . . 71

4.31 Alarms Page - List of alarms . . . 71

4.32 Gallery Page . . . 72

4.33 About Page . . . 72

A.1 Database Trigger . . . 81

(17)

List of Tables

2.1 Internet of Things (IoT) protocols comparison (adapted from [1] [2]) . . . 19 2.2 Mobile cross-platforms comparison [3] . . . 29

(18)
(19)

Acronyms

AJAX Asynchronous Javascript and XML

AMQP Advanced Message Queuing Protocol API Application Programming Interface

BLE Bluetooth Low Energy

BLOB Binary Large Object

BSON Binary JSON

CoAP Constrained Application Protocol CPU Central Processing Unit

CSI Camera Serial Interface CSS Cascading Style Sheets

DO Dissolved Oxygen

DSI Display Serial Interface

GPIO General-Purpose Input/Output GPS Global Positioning System Gunicorn Green Unicorn

HDMI High-Definition Multimedia Interface HTML HyperText Markup Language

HTTP Hypertext Transfer Protocol IoT Internet of Things

IP Internet Protocol

JS JavaScript

JSON JavaScript Object Notation vii

(20)

viii Acronyms

LoRa Low-Range Technology

LoRaWAN Low-Range Wide Area Network LPWAN Low-Power Wide Area Network

MQTT Message Queuing Telemetry Transport

MTV Model-Template-View

MVC Model-View-Controller

M2M Machine To Machine

NLOS Non-Line-Of-Sight

NoSQL Not Only SQL

ORDBMS Object Relational Database Management System ORP Oxidation Reduction Potential

pH Potential of Hydrogen QoS Quality of Service

RAM Random Access Memory

REST Representational State Transfer

RF Radio Frequency

RFID Radio Frequency Identification

RPi Raspberry Pi

RTMP Real-Time Messaging Protocol

SASL Simple Authentication and Security Layer

SD Secure Digital Card

SOAP Simple Object Access Protocol SQL Structured Query Language TCP Transmission Control Protocol TLS Transport Layer Security UDP User Datagram Protocol URI Uniform Resource Identifier URL Uniform Resource Locator USB Universal Serial Bus

(21)

ix

WAN Wide Area Network

WLAN Wireless Local Area Network WSGI Web Server Gateway Interface WSN Wireless Sensor Network XML Extensible Markup Language

(22)
(23)

1

Introduction

The IoT presented an exponential growth over the last years. In our daily routine it is more common to find connection between all types of objects and “things”. This is the reality we live in and it has a trend to increase as our future will depend on it.

The need to connect a large number of objects of our days brought the ability to react remotely over those devices. This capacity to control the devices in such an easy way is an asset in cases of extreme urgent actuation or in a simple ordinary situation.

1.1

Motivation

Ecomare, which was recently inaugurated, is the Laboratory for Innovation and Sustain-ability of Marine Biological Resources of Aveiro’s University. This laboratory combines the Centro de Extens˜ao e de Pesquisa Ambiental e Marinha (CEPAM) and Centro de Pesquisa e Reabilita¸c˜ao de Animais Marinhos (CPRAM).

This center works as a veterinary unit to treat animals at risk and has a component of investigation and technology transference related to the sea under scientific orientation of the University of Aveiro and Sociedade Portuguesa de Vida Selvagem.

This center is equipped with a few aquariums so that some species and environment condi-tions could be studied. One of these aquariums works as a tester to the work developed. The aquarium will be equipped with sensors to measure some chemical and physical parameters related to the water control system.

The parameters and their range of values can change according to the different species. Variations on these values can lead to dramatic consequences for the animals and this is the biggest motivation for this project.

(24)

2 Chapter 1. Introduction

1.2

Objectives

The work presented in this dissertation took into account the involvement and importance of IoT and consisted on the development of a functional platform to control a set of sensors related to an aquarium.

There are many parameters to consider concerning aquarium species. In this specific case, the aquarium not only has several fish species, but also corals and echinoderms and has capacity to uphold around 1500L of water. The values in each sensor need to be checked in short periods of time to ensure there are no problems with the different species.

Despite the sensors’ monitoring purpose, this platform plays an important role when considering sensors’ control. For each sensor it is necessary to establish a range of values that are considered normal and, when one of those values is outside the pre-defined range, an alarm must be triggered and an action should be performed to control the anomalous situation.

Another objective of this work was the aquarium’s promotion to the general public by making live video streaming available on Youtube.

In specific, the web’s platform should allow the access to the values read from the aquar-ium’s sensors, and the readings outside the established range should be displayed with greater emphasis, so the handler can pay attention over these values.

Furthermore, the platform should allow access to statistical data achieved through values registered over the time. This information should be shown with the help of line graphics.

A list of alarms must be displayed considering all the values that were recognized as unusual, allowing the user to check them as seen, so that they are not shown again.

The web’s platform should have a section to watch the live video streaming. A page of settings should be available so that the authorised users can access and change the internal information of the system, such as sensors and alarms.

A mobile application should be developed in order to show not only the last alarms and last values read but also some statistics, considering the existent sensors and its readings along the current day.

1.3

Software Development Methodology

The methodology adopted in the beginning of this dissertation was based in AGILE, which implements an alternative approach to the traditional methods of software development.

This type of method has a few rules instigating the developer to achieve the final objective and guarantee the possibility of improvement along the several steps. For that, AGILE implements a set of principles for software development under some requirements that lead to successful products [4].

The main essence according to this method pursues the following steps: Conception, Initiation, Analysis, Design, Construction, Testing and Deployment.

The first step taken was the product’s conception, where the idea of the product needs to be clearly defined to be able to carry onto the next steps successfully. Initiation and Analysis are two processes that can occur simultaneously. In these stages, we can consider the requirements’ analysis, use cases and apply the ideas set in the conception phase. When both phases were surpassed, the following two were Design and Construction, which can also have a parallel execution. The mock-up of the application needs to be slightly defined before the construction starts, however some details may change during the development

(25)

1.4. Document Organisation 3

process. Finally, the Tests and Deployment were gathered. In fact, for the final process to be completed, all tests must be running successfully and only then is the product finished and ready for production.

1.4

Document Organisation

This document presents all the research, implementation and conclusions related to the work developed and is divided in five different chapters:

• The first and current chapter presents the motivation, objectives and main idea behind this dissertation.

• The second chapter, State-of-the-Art, presents the results of the research, the frame-works and technologies used, as well as all the related themes.

• The third chapter, Requirements and System Design, reveals the architecture under-lying the building system and the requirements around it.

• The fourth chapter, Implementation, describes the several steps to achieve the final solution referring the challenges and all the decisions that were taken.

• The fifth chapter, Conclusions and Future Work, presents the final considerations about all the work developed and provides suggestions for the future.

(26)
(27)

2

State-of-the-Art

This chapter has a summary of important measured water parameters and it also presents the written result of the research on web and mobile frameworks and Internet of Things fundamentals applied in this dissertation.

2.1

Water Quality Monitoring

Aquarium monitoring implies the control of several parameters that are significant to the living species [5]. According to this, the next sections will explain and present some considerations about the important parameters to be measured.

2.1.1 Potential of Hydrogen

The pH is a scale used to measure the acidity/basicity of a solution. The scale used has a range from zero (0) to fourteen (14) and the number seven (7) represents a neutral solution. Considering the previous scale, values below seven represent acid solutions and values above seven, basic solutions.

Figure 2.1 shows a graphical representation of the pH scale and its influence in a few species.

Most fish species live in environments with a pH between 6.5 and 9.0, which is considered their ideal pH. However, this number varies according to several conditions in and outside the aquatic environment and some species do not cope well with aggressive variations, as these species are sensitive to pH’s fluctuations. Moreover, the values can increase stress in species and reduce the chances of reproduction and ultimately, may compromise their survival [6].

A pH below 5.0 affects fishes’ reproduction and one below 4.0 is even life threatening. As in with low levels of pH fishes are more susceptible to get diseases considering they are more sensitive. Also, low values of pH can lead to solubility of heavy metals which increase the concentration of metals in the water and also its toxicity. These metals are absorbed by fishes during their respiration and that can cause physical damages [6].

On the other hand, high levels of pH cause skin and gills problems and levels above 10 culminate in death [6].

(28)

6 Chapter 2. State-of-the-Art

Figure 2.1: Aquatic pH levels [6]

2.1.2 Temperature

The water temperature is one of the most important parameters to quantify considering its influence on the other ones.

Figure 2.2: Water temperature’s influence [7]

The temperature, as shown in Figure 2.2, affects parameters related to water conditions such as pH, conductivity and salinity, Dissolved Oxygen (DO), toxicity and Oxidation Re-duction Potential (ORP) [7].

The variation of temperature can lead to metabolic rate increase of animals, unfortunately some of them can not handle this forceful change [7].

It has been proven that each 10° C increase in water temperature raises the metabolic rate to double, as seen in Figure 2.3.

Temperature is implied in solubility gases and they decrease with higher temperatures. Cold environments have more dissolved gases, including oxygen, rather than hot ones. If the water is too hot, there is not enough oxygen for species to survive [7].

(29)

2.1. Water Quality Monitoring 7

Hotter water is usually more dangerous than colder water. The unusual levels are associ-ated with problems in growth, reproduction and survival of the species. Cold water can affect biological and metabolic processes, while hot water is responsible for excessive respirations, increasing the species’ stress [7].

Figure 2.3: Water temperature influence in metabolic rate [7]

2.1.3 Conductivity

Conductivity is related to water’s capability to conduct an electric flow. This is associated with the concentration of ions found in the water. These ions come from dissolved salts and inorganic materials and these values are indicators of water changes. Therefore, the more existence of ions, the more conductive is the water. Otherwise, the less ions, the lower is the conductivity [8].

Salinity is the total concentration of dissolved salts in water. According to this definition, salinity contributes to conductivity. Salinity can be measured through chemical methods, although in this case it is not viable. This point is where conductivity gets to help find salinity values. The derivation of salinity from the conductivity values is called practical salinity [8].

The salinity affects the dissolved oxygen levels directly, which implies a higher salinity level and a lower dissolved oxygen concentration [8].

The species’ capacity to respond to salinity is related to osmotic processes and varies according to the several species [8].

Figure 2.4 shows the different salinity levels according to three species of fishes.

The alteration of conductivity in a certain environment can produce negative effects in the organisms’ metabolism. These alterations can be caused by different temperatures or salinity levels [8].

Most fishes are adapted to a fixed salinity value and several changes can result in death due to alterations in dissolved gases and osmotic regulation [8].

(30)

8 Chapter 2. State-of-the-Art

Figure 2.4: Salinity tolerance in species [8]

2.1.4 Dissolved Oxygen (DO)

DO is the free oxygen present in water. Free oxygen (O2) is the oxygen that is not connected to other elements, i.e., the free molecules of oxygen. This enters the water through the air or the plants’ process of photosynthesis [9].

DO is essential to species’ survival considering its use in respiration. The changes in this parameter is noticed through the loss of species and diseases. A low level of DO leads to death and its high level develops gas bubble disease and consequently results in death [9].

(31)

2.2. Internet of Things 9

2.2

Internet of Things

Throughout the times our connection to the Internet and its relations has been increasing and becoming stronger so that we can no longer live without the resources it provides.

The need to be connected every time and everywhere is clearly a signal that things are going to evolve and our daily lives will be entirely surrounded by technological solutions, which help us take our decisions and make our life easier. The IoT is one of those solutions, which is growing faster as it promises to connect all things around us.

2.2.1 Definition

“The term “Internet of Things” was popularized by the work of Auto-ID Center at the Massachusetts Institute of Technology (MIT), which in 1999 started to design and propagate a cross-company Radio Frequency Identification (RFID) infrastructure.” [10] Although the term started at Auto-ID Center, it quickly expanded and by 2005 it was already spread worldwide.

The concept of IoT appeared combined with the ubiquitous computing concept that emerged from Weiser in the early 90’s. This vision revealed the interconnection of small devices that used sensors to monitor fixed parameters and actuators to remotely control the same parameters. [11]

“The IoT aims at enabling the interconnection and integration of the physical world and the cyber space.”[12]

Figure 2.5: IoT applications

The frequent connection of physical things to a network brought the manipulation of several type of data. This communication makes us reflect upon a few aspects, such as data collecting, data storage and analysis.

Despite the points previously mentioned there is also the need to provide “services for information transfer, applications and communications” [13].

(32)

10 Chapter 2. State-of-the-Art

The demand for several sensors operating for different measures and their low capacity, made us consider elements as memory, processor, power, among others, which led to the implementation of wireless communication to obtain a better performance.

The set of sensors operating together to monitor a region is called Wireless Sensor Network (WSN) [14]. These sensors have the capacity to communicate between them using their wireless interfaces forming a network and this introduces the concept of WSN in IoT.

A WSN can have two possible layouts according to its infrastructure: structured and unstructured.

A structured network considers a pre-designed arrangement form for displaying the sensors (all or some of them). This type of structure assists in management and maintenance costs since the nodes are presented in specific places to cover the predicted area.

An unstructured network has a different layout and the sensors are displayed in ad-hoc mode, meaning that each sensor is installed at a random position. This kind of network includes a higher number of sensors, guiding to a greater expense and a harder network management [14].

A WSN has several useful “applications in scenarios such as military target tracking and surveillance, natural disaster relief, biomedical health monitoring and hazardous environment exploration and seismic sensing” [14].

IoT has grown since its appearance and it is estimated that within a few years the major devices, known as “things” in this context, are connected to the Internet and with each other making global communication possible.

A lot of applications with this concept are already visible around us (as seen in Figure 2.5) like smart fridges, which display their contents and alert for the lack of some essentials products; smart houses with windows, doors, garages and lights remotely controlled; smart farms with controlled dosage of watering or organic fertilizer. The list of scenarios continues and in a near future it will definitely increase.

The IoT application in the context of this dissertation brings the possibility to have a frequent control over the physical and chemical water parameters to prevent and avoid anomalous situations with the aquarium and its species.

2.2.2 IoT Communication Protocols

There are several types of communication protocols related to IoT. The defined standard for IoT communication is not clear about the best protocol to use is. Wi-Fi, Zigbee, Bluetooth, Radio Frequency, are among some of the most used protocols.

The communication used in WSN has some constraints considering the low consumption, short communication range, limited storage and processing and low bandwidth [14]. Accord-ing to previous conditions, this type of network needs specific attributes to operate properly.

The characteristics of the protocols used in this type of networks are presented below.

LoRa

Low-Range Technology (LoRa) is a low-power and long-range wireless communication technology thought to Wide Area Network (WAN). This technology’s modulation is chirp spread spectrum based which preserves the low-power characteristics, increasing the commu-nication range. The chirp spread spectrum is an approach that uses chirp pulses to encode

(33)

2.2. Internet of Things 11

information. A chirp is a signal that increases or decreases over the time, according to the frequency [15] [16] [17].

Low-Range Wide Area Network (LoRaWAN) is the LoRa applied to a WAN. While LoRa physical layer enables the long-range communication, LoRaWAN “defines the communication protocol and system’s architecture for the network, and behaves as a media access control layer protocol for managing communication between Low-Power Wide Area Network (LPWAN) gateways and end-node devices” [15].

“The network capacity, the quality of service, battery lifetime of a node, the security and the variety of applications served by the network” are the main focus of the LPWAN’s protocol and architecture [15].

Sigfox

Sigfox is a technology with a modulation based on ultra-narrow band with a limited uplink connection. This type of modulation allows achieving at a maximum data rate of 100 bps by transmitting messages with 12 bytes of maximum payload length [18] [19].

This technology implements a lightweight protocol to adopt a battery saving mechanism. This is achieved considering that less data to send implies less energy consumption. Sigfox has a star network architecture where a device can connect to any base station within a range of 3 base stations. This technology was designed to return a “long device battery life-cycle, low device cost, low connectivity fee, high network capacity and long range” [18].

Bluetooth

Bluetooth for IoT is also known as Bluetooth Low Energy (BLE) or Smart Bluetooth and it is based on IEEE 802.15.1 standard. In comparison to the original Bluetooth, this one has a reduced cost and power consumption with a very similar communication range.

This type of communication operates in 2.4 GHz frequency and supports data transmission rates up to 1Mbps and a distance range around 100 meters. [20]

Wi-Fi

Wi-Fi is based on IEEE 802.11 standard and is a wireless network technology. Some of the characteristics of this type of network are bandwidth of 2.4 or 5 GHz; it has a maximum bit rate of 54 Mbps in physical layer and 24.7 Mbps as the limit for data transfer; it allows star and ad-hoc typology; it admits encryption and authentication mechanisms [21].

Besides the previously listed Wi-Fi features, it also has “high rate and bandwidth and large-scale data collection” [22].

Zigbee

Zigbee is based on IEEE 802.15.4 specification used for many scenarios placed in WSN. It is defined by low power consumption, low data rate (250 kbps) and short range.

Addressing and routing for tree and mesh topologies are supported for Zigbee. This is used essentially in applications for home automation and smart energy solutions [23].

This technology is different from Bluetooth and Wi-Fi because it is simpler and less expensive, considering its capability to start sleep mode according to traffic presence [20]. It is mainly used for low data rate applications working as a secure network. Despite all the

(34)

12 Chapter 2. State-of-the-Art

pros, this technology transmits only to limited distances and the capacity to cross barriers is compromising [22].

Wi-Fi vs Zigbee

In addition to the attributes mentioned before around Wi-Fi and Zigbee, and considering the relevance of both communication protocols, some advantages specifying the preference of Wi-Fi over Zigbee are presented [22]:

• High Bandwidth - while data transfer with latest Wi-Fi technology (802.11n) can reach 300Mbps, Zigbee can only get a maximum rate of 250 Kbps. This leads to a better performance with a reduced delay.

• Non-Line-Of-Sight (NLOS) Transmission - Wi-Fi has the capability to communicate through obstacles.

• Large Coverage Area - Zigbee can cover a range from 10 to 75 meters while Wi-Fi can cover to an extent of 300 meters outdoor and 100 meters indoor.

• Cost-effective - a wireless sensor network built over the existing Wi-Fi network can reduce the costs.

• Easy Expansion - Wi-Fi sensor nodes can support up until 100 wireless connections which is considered more indicated for further scalability.

• Strong Robustness - the tree topology used in Wi-Fi makes the network more reliable in case of failures.

Radio Frequency

Radio Frequency (RF) represents the oscillation rate of electromagnetic radiation spec-trum that can have a range starting in 9 KHz and achieving frequencies of 300 GHz.

This type of communication uses antennas and transmitters to be able to send and receive the communication signals.

The RF module is used to send and receive radio signals between two devices. This sort of communication is known for travel large distances which is convenient for longer range applications. RF signals can navigate with obstacles in the line of sight between transmitter and receiver.

(35)

2.2. Internet of Things 13

Technologies comparison

Figure 2.6: Characteristics Zibgee vs Wi-Fi vs Bluetooth [24]

2.2.3 IoT Data Protocols

Regarding IoT data protocols, we should focus our attention first on the main commu-nication protocols used on the Internet, which act as an interaction mean between com-puter networks. Therefore, we suggest a brief introduction of the two leading base protocols: Transmission Control Protocol (TCP) and User Datagram Protocol (UDP).

“The TCP is a protocol for packet-switched computer communication networks and in-terconnected system of such networks, designed to be reliable” [25]. This protocol provides reliability, packets ordering and error-checked packets delivery.

Otherwise, UDP uses messages to communicate between hosts known as datagrams. They use a connectionless transmission model and it provides checksums to guarantee data integrity. On the other hand, there are no handshake dialogues which lead to a lack of reliability of this protocol. There are no delivery confirmation, packet ordering or duplication protection [26]. Message Queuing Telemetry Transport (MQTT)

MQTT was invented by Andy Stanford-Clark of IBM and Arlen Nipper of Arcom (now Eurotech), in 1999 [27]. This is a messaging protocol based on publish-subscribe pattern designed to be used in devices with high-latency and low-bandwidth and run over TCP/IP protocol. The principles used in MQTT make it an ideal protocol to use in IoT and Machine To Machine (M2M)1 applications considering the category of devices used.

1

(36)

14 Chapter 2. State-of-the-Art

This messaging protocol uses clients as publishers and subscribers to produce the message exchange. This communication also needs a broker to process the messages.

When a client intends to send a message, it establishes the connection with the broker and then sends the information.

The first message exchanged between client (publisher or subscriber) and broker is a “CONNECT” message that contains some parameters. One of them is the Client ID, so the broker knows which client is connected to. Despite the recognition’s purpose, this ID is also used to guarantee the Quality of Service (QoS) level when a potential network failure occurs. When the connection between the two entities takes place, the information sent by the client (publisher) is always added to a specific topic it defined. On the other hand, a subscriber is a client who requires receiving messages from a specific publisher, or in this case, from a particular topic. To do that, the client needs to subscribe the topic from which it wants to receive information from. This is the basic process of publish-subscribe pattern considering the entity which sends and the one that receives the information from as it can be seen in figure 2.7.

Figure 2.7: MQTT communication [28]

All messages are followed by an acknowledge to guarantee the delivery’s success.

The middle agent in all this procedure is the broker. It has the function of connecting the publishers and subscribers to the topics in question and has to ensure this connection through a ““keep-alive” timer which defines the maximum time interval that may elapse between two messages received from that client” [29]. If during this time there are no messages transmitted, the client sends a PING to the broker and this can detect an eventual failure on the communication process. The PING messages are split in PINGREQ and PINGRESP, respectively meaning, ping request and ping response [28].

MQTT has three levels of QoS according to the reliability of messages delivered [29]. The lower level is zero and considers a service delivery with no guarantee that the messages reach their destination, i.e., without acknowledgement or retransmission. This QoS type can deliver a message only once or even not at all.

Level one is more reliable considering the retransmission of the information until an ac-knowledge message is received from the destination. This level has an adjacent problem that is the risk of several repeated messages being delivered due to the retransmission.

(37)

2.2. Internet of Things 15

The highest level is the QoS level two that ensures the reception of the messages only once by the destination.

According to Hunkeler, Truong and Stanford-Clark’s article [29], “a temperature

monitoring application could decide to use QoS level zero for the publication of normal and regular measurement reports, but QoS level one for transferring alarm messages when the temperature exceeds a certain threshold”. All things considered, the QoS level must be chosen according to the used application in order to obtain the best outcome for the aimed effect.

MQTT Brokers

As mentioned before, a broker is required to handle the communication between publishers and subscribers. “MQTT broker acts like a filter allowing only the requested data thereby saving the flow of ambiguous data” [30].

Figure 2.8 shows how a broker works as middle mediator between publishers and sub-scribers.

Then, two broker options that can be used along with MQTT will be presented.

Figure 2.8: MQTT Publisher-Subscriber Model (adapted from [31])

Mosquitto

Mosquitto is an iot.eclipse.org project and it is an open source MQTT broker. This technology implements the MQTT protocol using version 3.1. [32].

Mosquitto broker supplies a lighter implementation of MQTT that can be applied to low or high power devices.

HiveMQ

HiveMQ is a MQTT broker belonging to HiveMQ company and was thought to enterprise scenarios. It integrates MQTT 3.1 and MQTT 3.1.1 to be compatible with MQTT [31]. Some of its features are [31]:

• Great performance - allowing real-time communication between applications and de-vices.

(38)

16 Chapter 2. State-of-the-Art

• Enterprise grade security - existent mechanisms of authorization, authentication and Transport Layer Security (TLS) encryption.

• Extensions - HiveMQ allows the creation of extensions or using its owns. • 100% MQTT compliant - supports all the MQTT versions.

All the characteristics described before are relevant in a broker. Despite that, this one is thought for enterprise context and so,it is not a free tool.

MQTT Clients

A MQTT client is responsible for collecting information from a device, connecting to the broker, that acts as an intermediary between both edges entities (publisher and subscriber), and also for using a topic to publish the information obtained from the device mentioned. This time, another client, a subscriber can get the published information [33].

The topics below describe two types of MQTT clients. Paho-MQTT

Paho-MQTT is a Python library which implements versions 3.1 and 3.1.1 of MQTT proto-col. This library provides a class client to allow applications to be published to and subscribed from topics, respectively [34].

HiveMQ Websocket Client

HiveMQ Websocket Client is a tool created by HiveMQ to work as a MQTT client and “supports all common protocol features except persistent session” [31].

It has an interface that allows publishing or subscribing by following some clicks through the default’s options. It allows connection with local brokers using an Internet Protocol (IP) address or hostname.

Constrained Application Protocol (CoAP)

CoAP is an application layer protocol developed to be used by devices with constrained resources to communicate. It is based on Representational State Transfer (REST) technology and considering its execution over Hypertext Transfer Protocol (HTTP), it allows a request-response model.

CoAP supports a publish-subscribe pattern but in contrast with MQTT (2.2.3), the pub-lication of the information is not in topics but based on an Uniform Resource Identifier (URI). An URI is a string of characters to identify a resource, allowing interaction over network using specific protocols, in this case, the CoAP. This works as follows: when a publisher wants to publish information, it publishes to the URI X; on the other hand, the subscriber subscribes a particular resource, in this case, the URI X; from here, the subscriber, connects to the URI under discussion, it receives a notification of new data published and can access it [36].

(39)

2.2. Internet of Things 17

Figure 2.9 represents the main idea about CoAP operation.

Figure 2.9: CoAP mechanism [35]

Advanced Message Queuing Protocol (AMQP)

The initial concept of AMQP came out in London in 2003 by John O’Hara. This protocol is identified by message orientation, queuing, routing, security and reliability [37].

This is an application layer protocol for message-oriented middleware and assumes TCP as the base transport layer protocol.

Figure 2.10: AMQP publish/subscribe mechanism [35]

To guarantee the interoperability between systems, AMQP defines two sides: networking protocol and server-side services. The points referred to before are ensured by the following characteristics [38]:

• “a set of defined messaging capabilities called Advanced Message Queuing Protocol Model (AMQ model)”. This model combines a set of components responsible for mes-sage routing and storage and also rules to wire these components.

• “a network wire-level protocol, AMQP” that allows communication between clients and server and provide an interaction with AMQ model.

(40)

18 Chapter 2. State-of-the-Art

The AMQ model has three main components: “exchange”, “message queue” and “bind-ing” (figure 2.10). “Exchange” has as the role of receiving messages from publishers and route them to “message queues” according to some criteria like messages content and prop-erties. “Message queues” supports the storage of all the messages received by “exchange”, until they are available to be processed. “Binding” is responsible for criteria creation used by “exchange” to send messages to “message queue” [38].

Extensible Messaging and Presence Protocol (XMPP)

Originally named Jabed, Extensible Messaging and Presence Protocol (XMPP) was de-veloped by Jabed open-source community in 1999 to obtain near real-time Instant Messaging (IM) between several network entities [39]. This was created to contribute as alternative to the services existent in those times.

Although developed for instant messaging, XMPP was used also for presence information and contact lists.

One of the advantages of this protocol consists on its decentralized architecture. This leads anyone to have the power to run their own XMPP server, assuming the total control over the communications.

Confine the XMPP server from the public network and use Simple Authentication and Security Layer (SASL) 2 and TLS3 is the security’s purpose. Also, it is been developed a end-to-end encryption in order to increase the security around this protocol [39].

Among the previous mentioned attributes, XMPP is open-source and it is a standard protocol. It is been proven to have a good performance and it is used by several companies with success. Also, is an extensible protocol by the use of Extensible Markup Language (XML)

4, allowing to build functionalities over the core protocols [39].

Finally, the flexibility allowed by XMPP is recognised and that is seen in its application on “network management, content syndication, collaboration tools, file sharing, gaming, remote systems monitoring, web services, lightweight middleware and cloud computing” [39].

Although not developed to be used in IoT, XMPP extensibility and flexibility, that can lead to its application in different scenarios, can drive this protocol to be appropriate for the IoT, in the future.

2SASL - framework for authentication and data security in Internet protocols. 3

TLS - cryptographic protocol that provide communications security over a computer network.

4XML - markup language that defines a set of rules for encoding information in a specific format. XML is

(41)

2.2. Internet of Things 19

Protocols comparison

Table 2.1 shows a comparison between the IoT protocols described before.

MQTT CoAP AMQP XMPP

Publish/Subscribe Yes Yes Yes Yes

Request/Response No Yes No Yes

Transport TCP UDP TCP TCP

Security Medium/ Medium/ High/ High/

Optional Optional Mandatory Mandatory

QoS Yes Yes Yes No

Dynamic Discovery No Yes No Yes

Encoding Binary Binary Binary Plaintext

Real time No No No Near Real Time

Table 2.1: IoT protocols comparison (adapted from [1] [2])

2.2.4 Node-RED

Node-RED is a tool for building IoT applications by wiring all the blocks together. This way they can be related to an intelligent system and hide some of the complexity attached to them.

There are code blocks called ’nodes’ that can be connected. This way, the tool allows the developer to create a connect input, output and processing nodes by just configuring a few parameters that are required, enabling a full connectivity between the endpoints in the system [40].

The approach of Node-RED is based on a more visual vision over the interconnection between the several nodes, taking advantage of the code abstraction and only some essential configurations were required to make the connection happen. When all this nodes get together, they are called flows.

This product was created by IBM in 2013 for their own benefit, but it quickly proved to be a very useful tool for general users and was extended to a larger range of applications, other than IoT [40].

This tool was created to be powerful and flexible and for that, two main factors were considered essential [40]:

• Flow-based programming model - describes the application’s behaviour as a network of nodes, where their real complexity is not obvious. Some data arrives at each node and after performing its function, the data follows the flow’s direction.

• Set of built-in nodes - allows the use of nodes with ability to do complex tasks yet the developer does not need to concern about the complexity of those tasks.

(42)

20 Chapter 2. State-of-the-Art

“Node-RED consists of a Node.js-based runtime that can be pointed to a web browser to access the flow editor [40]”. After having the access, the nodes are available to create flows. They are shown, dragged and dropped to a central workspace, where we start to build our system flow. In addition to the existing nodes, others can be added by installing some packages on the Node-RED running space.

After all the nodes were wired together, the application is compiled and deployed. The results can be seen at runtime. A dashboard can be also accessed to see some graphics with the processed data [40].

In figure 2.11 and 2.12 we can see an example of nodes’s flow and dashboard results.

(43)

2.3. Database 21

2.3

Database

One of the requirements to support all the incoming data from sensors is a database. The data is collected and saved on a relational database.

There are two main database types: relational and non-relational, also known as Not Only SQL (NoSQL). MySQL and PostgreSQL are two examples from relational database. On the other hand, MongoDB is a non-relational database.

The essential difference between both types is the use of tables and rows in relational database versus documents with JavaScript Object Notation (JSON)5 format in

non-relational database.

It is also important to emphasize that data manipulation in relational databases is made through Structured Query Language (SQL) queries while in non-relational databases, object-oriented APIs6 are used .

2.3.1 Database analysis

The current and next sub-section analysis intends to show the differences between some of the existing databases.

The analysed relational databases were MySQL and PostgreSQL and the non-relational was MongoDB.

MySQL

MySQL is an open-source relational database management system owned by Oracle Cor-poration. Besides this open-source component, there is also an enterprise edition with more features available and directed to companies.

This database was created to support a larger amount of data and faster than the existent databases. This brought the need of MySQL to become faster, reliable and scalable [42].

MySQL is still under improvement, but offers an important set of functions and aspects as speed, security and connectivity that provides reliability to the user [42].

As a client-server system, MySQL has a “multi-threaded SQL server that supports dif-ferent back ends, several difdif-ferent client programs and libraries, administrative tools, and a wide range of application programming interfaces (APIs)” [42].

As an open-source system, MySQL has a set of features available for the users and a large number of applications that can easily be combined with this system [42]. Also, the information available about this database management system is enormous considering its large community of users.

MongoDB

MongoDB is an open-source non-relational database and it is based on the principles marked by the NoSQL databases. They do not use the relational database management system principles and, as mentioned before, tables and rows are not used to save the data.

5

JSON - lightweight format for data exchange. JSON is an independent text format language, based on some conventions used by some languages such as C, C++, C#, Java, JavaScript, Perl, Python. This text format is built under two structures: key-value pairs and ordered list of values [41].

6API - set of protocols and tools to build application’s software, that defines methods for communication

(44)

22 Chapter 2. State-of-the-Art

Instead, it uses pairs of key-value. The key works as the unique identifier of the data and the value, in this case, is the saved data [43].

Despite using the key-value pairs, there are three different ways to save data in a non-relational database: document, column and graphic-oriented. If we take into account that MongoDB is under study, the focus will be on explaining the operation mode for this type of database. Therefore, the data persistence is based on documents. This provides us with a flexible database considering there are no pre-defined schema and there are different types of documents available to work with: JSON, XML, Binary JSON (BSON) and Binary Large Object (BLOB) [43].

JSON and XML were already explained before.

BSON is a binary-encoded format that MongoDB uses behind the scenes to represent JSON documents [44]. It is used to store documents and make remote procedure calls.

BLOB is a collection of binary data stored as a single entity in the database.

The different types described are a specialization of key-values databases. This kind of database is more flexible with attributes’ addition or removal because there is not a fixed schema [43].

PostgreSQL

PostgreSQL is an Object Relational Database Management System (ORDBMS) developed by a team from California University at Berkeley [45].

A ORDBMS is a very similar system compared to a relational database but it has an object-oriented database model. This system explored the use of classes and inheritance to block the difference between conceptual data modelling techiques and object relation mapping. Initially, PostgreSQL did not support SQL and it was only in 1994 that that feature was implemented. Nowadays, PostgreSQL supports many features that do not exist in other DBMS. These features include triggers, procedures, views, indexes beyond private and foreign keys and atomic operations [45].

Figure 2.13 shows some of the features supported by PostgreSQL.

Figure 2.13: PostgreSQL features [45] Some of the advantages of PostgreSQL’s usage are [45]:

• Immunity to over-deployment - the use of the software is free and there is no need for licensing.

• Better support than the proprietary vendors - existence of several experts in this area to answer the questions.

(45)

2.3. Database 23

• Significant saving on staffing costs - the lower maintenance reduces the costs. • Legendary reliability and stability - there are no indications of failures. • Extensible - the code is available for everyone to be completed.

• Cross platform - available for different platforms.

• Designed for high volume environments - use MVCC strategy to obtain good responses in situations with more volume of information. MVCC (Multiversion Concurrency Con-trol) is a control method to avoid several accesses at the same time to the same infor-mation, i.e., a concurrent strategy.

• GUI database design and administration tools - there are many interfaces to deal with PostgreSQL.

• ACID (Atomicity, Consistency, Isolation, Durability) compliant - Atomicity to guaran-tee that a transaction is made from the beginning to the end without failures; if there is a failure, the transaction will not be executed. Consistency to guarantee that database goes from a stable state to another. Isolation to prevent access at the same time from different entities. Durability for when a transaction is committed remains the same way, despite external events.

(46)

24 Chapter 2. State-of-the-Art

2.4

Web Frameworks

Some web frameworks were addressed along this section and studied within the scope of this dissertation. There is a performance and features’ analysis in order to realize which the best framework to fit this work specifications is.

A web framework is a software developed to support web applications development that in-cludes web resources, services and APIs. Web frameworks plan to automate web application’s development providing means, including libraries, to achieve a better and faster solution.

2.4.1 Web Framework Analysis

The frameworks chosen to be a comparison target were Flask, ASP.NET and Django. The next paragraphs will explain a software architecture model used frequently and each frameworks’ characteristics with more detail.

Flask

Flask is a microframework for web application development that uses Python. A mi-croframework is a web framework that rules by the minimum conditions to act as one. This means that a microframework has lack of features that are present on other frameworks such as authentication, authorization, database abstraction or input validation. This type of frame-work is more indicated to handle HTTP requests and give response to APIs requirements [46].

A microframework is lighter than other frameworks considering the small number of as-sociated dependencies. On the other hand, the developer has more work to be done, adding the list of plugins and dependencies needed to build the application [46].

The ASP.NET and Django frameworks use the same architecture. In that way, it will be described in the following lines.

Model-View-Controller Architecture

Some frameworks use an architecture that make a clearly separation between three es-sential components related to the web’s development. The Model-View-Controller (MVC) architecture split up the concepts of models, views and controllers.

The MVC design pattern is based on the division between the data layer and its repre-sentation to the final user. Taken this model into account, it is more straightforward to build a project which can easily be adapted to the existing needs without drastic changes. All this is consequence of the layer independences presented previously.

The ’model’ includes all the interaction to the database without considering any parame-ter related to the data’s visualisation. The database is the beginning of every application. It is at the database level that all the needed information is presented so that everything works properly and accomplishes a successful interaction. A well-structured database can prevent several problems and inconsistencies along the application’s development process. The sepa-ration of this part from the logic one revealed to be essential. This way, it will not allow any critical changes that can trigger serious faults on an application.

(47)

2.4. Web Frameworks 25

The ’views’ have as main goal the interface creation for the user’s interaction. This component defines the way that information is shown to the user, whose definition comes from the MVC model. Through the views it is possible to make controlled changes over the created model, i.e., over the database. As mentioned before, although the data modification is possible, that is not an operation executed with a high independence level due to the fact that the views are kept away from the models.

Through the inputs received, the ’controllers’ have the capability to allow the users to communicate with the model and return possible results by the defined views.

This is one of the design patterns with a high attendance in many web’s applications. ASP.NET

ASP.NET is an open-source web development model and it is part of .NET framework, including its inherent services.

C# is used to develop the web’s application and benefits from type safety and inheritance, among others characteristics. For the visualisation’s purpose, HyperText Markup Language (HTML)7, Cascading Style Sheets (CSS)8 and JavaScript (JS) 9 were adopted [47] [48].

ASP.NET includes three types of web frameworks to build web applications: ASP.NET Web Forms, ASP.NET MVC and ASP.NET Web Pages [47]. The choice must settle upon the requirements and the final result intended for the application.

The focus will be on the ASP.NET MVC considering MVC usage both by ASP.NET and Django.

ASP.NET MVC

ASP.NET MVC follows patterns and principles based on “test-driven development, sep-aration of concerns, inversion of control and dependency injection” and it is proposed for developers who look for a separation between the business logic and the presentation layer.

The concept of MVC is based on models, views and controllers and this separation can lead to a lower building complexity.

When compared to Web Forms, MVC has a better control over HTML and HTTP con-tents, enabling us to understand how the application works and what is its behaviour in the web environment is [47].

Django

Django is a free and open-source web framework developed in Python, which follows the architecture Model-Template-View (MTV), originated from the MVC model.

This framework is known for having a lot of characteristics that facilitates the web’s development. Some of those attributes are defined as [49]:

• Speed - the design of Django was thought to build quick web applications without many complications.

7

HTML - standard markup language frequently used to build web pages and handle their visual aspect.

8CSS - style sheet language used for describing the style used when elements are written using a markup

language, such as HTML.

9JS - dynamic programming language used together with HTML and CSS to build web applications/pages.

(48)

26 Chapter 2. State-of-the-Art

• Fully loaded - has extras to help handle some essential tasks in web’s development like user’s authentication, administration, maps, among others.

• Secure - guarantees a good level of security to avoid attacks as cross-site scripting and request forgery and SQL injection. The user’s authentication system ensures a secure management for user’s accounts and passwords.

• Scalable - can handle large data traffic quickly using the system’s flexibility. • Versatile - several type of platforms can be developed using this framework. These are the main points that characterize Django as a web framework.

Django’s architecture is based on the MVC pattern, yet there are some changes to consider and that should be emphasized.

Django’s model is MTV, as seen in figure 2.14. This model has controllers being replaced by templates.

Figure 2.14: Model-Template-View Architecture

The logic around the views and models are the same described before about MVC. Considering the templates, these allow the wanted appearance for the web’s application pages that show the information hold by the database using views. The files used are usually HTML and describe the structure presented to the user. The place, where the information shown is kept, can be previously defined. The templates make the communication with the views and its result is placed in the template in a way to display the correct information.

According to Django’s conditions, the models do the interaction with the database using Python,without the need to query execution. The views combine Python files that describe the way the information will be displayed and consequently communicate with the database and eventually with the templates.

(49)

2.5. Mobile Frameworks 27

2.5

Mobile Frameworks

Along this section some mobile frameworks were addressed and studied within the scope of this dissertation. There is a performance and features analysis in order to realize which the best framework to fit with this work specifications is.

A mobile framework is a software developed to support mobile application’s development and plan to automate all the process providing means, including libraries, to achieve a better and faster solution.

There are two types of mobile frameworks: native and cross-platform. Platforms such as Android, iOS and Windows Phone have their own features allowing access to specific hardware and characteristics in the mobile phone. Each platform has a different way to handle its own structure and for its developers, it is a challenge to build applications that run in all platforms equally [50] [51].

Therefore, building an application using the native solution may not be the right approach. This would involve development of a different code for each platform, which is not efficient regarding costs and resources.

The solution found to outline this problem was the development of cross-platform appli-cations, that implies building an application consistent with most platforms. The code base is the same for all the applications and according to the platform where it runs, the native features are applied without the developer’s effort [50].

Inside cross-platform frameworks there are four types to consider: web, hybrid, interpreted and cross compiled approaches.

Web approach is thought to execute the application in the web browser of the device and the languages used are HTML, CSS and JS. Considering the browser based application, it will be independent from the platform [50].

Hybrid is the balance between web and native platforms, where the development is achieved through web technologies. The result is executed inside a native container of the mobile device. A browser is used to render and display the HTML pages and the mobile device runs an abstraction layer that allows the access to its capabilities as JS APIs [50].

An interpreted applications code is deployed on mobile device and interpreted thereafter, i.e., the interpreter executes the code during runtime. Native features are accessed through an abstraction layer to get native APIs for further use [50].

Cross compiled platforms convert the source code into native binaries to a specific plat-form. Any language is supported, and as soon as the development finishes, the cross compiler compiles the code to native to be ready to run in different platforms [50].

Assuming the importance of having applications with the widest range of platforms and people possible, the frameworks studied were cross-platform.

(50)

28 Chapter 2. State-of-the-Art

2.5.1 Mobile Frameworks Analysis

The frameworks under study were Ionic and PhoneGap. The next paragraphs will thor-oughly explain the characteristics of each.

Ionic

Ionic is an open-source mobile framework used to build hybrid applications that will run as natives over the different operating systems.

Some characteristics of this framework go through free and open-source, fully cross-platform, which have native plugins and great support documentation.

Ionic is a project under Massachusetts Institute of Technology (MIT) available to all the community. This framework allows development for several types of operating systems using the same code base, saving some hard work. The code used is based in HTML, CSS and JS. Ionic has native plugins such as Bluetooth or finger print authentication which is suitable for each of the platforms it proposes to serve. There are also several examples, tutorials and full documentation available about the Ionic way of working that will help in mobile development [52].

About performance, Ionic is known for having great performance power on the latest devices, having “efficient hardware accelerated transitions and touch-optimized gestures” [52]. This framework combines the standard and features of native applications to the web’s flexibility. It also has a clean, simple and functional design as a benefit [52].

Currently, Ionic requires Angular JS to get a full advantage of its capabilities. This allows us to have access to the user’s interface interactions, gestures, animations, among others. PhoneGap

“PhoneGap is an open-source mobile development tool developed by Adobe System Inc. under Apache 2.0 license” [53]. This tool allows developers to build free applications with no licenses needed.

One of the several advantages of this tool is the ability to build cross-platform applications with support for Android, iOS, Windows Phone, BlackBerry, Bada, Symbian and webOS [53]. The usage of PhoneGap brings the need to use more recent web programming languages such as HTML, CSS and JS allowing a cross programming instead of a native one, which leads to an easy integration when we consider different operating systems [53]. This tool works as a “wrapper” and that allows developers to include applications written in web to native languages. The applications are written using the previously mentioned languages and the code is built only once and is made available for all the accessible platforms.

PhoneGap includes several components and extensions to allow a better experience to the developers. The outcome applications are called hybrid since they are structured using both web and native languages [53].

Among several other associated advantages, some of them are [54]:

• Cross-platform development - leads to a greater reach in terms of operating sys-tems. Building applications with native languages have many limitations considering, for example, the market commercialisation. Limiting an application to just one market decreases the population’s reach. But this is not the only advantage when talking about

(51)

2.5. Mobile Frameworks 29

cross-platform; the base code needs to be written just once and there is no concern about specifications for each supported platform.

• Open source - this tool remains free and for that reason, accessible to a enormous number of developers. This huge community provides a big support.

• Native APIs - the development is done by using web languages, but this is not a synonym of resignation from native functionalities available in each device. Phone-Gap allows developers to access to native APIs like Global Positioning System (GPS), accelerometer, camera, among others.

• Rapid development - resulting in better applications. The development facility allied to the web’s development skills ends in better and quicker applications results in happier clients.

Frameworks comparison

According to the analysis produced in “Comparative analysis of tools for development of native and hybrid mobile applications” [3], it is possible to counterbalance Ionic and Phone-Gap in some parameters such as supported platforms and operating systems, programming languages and complexity of installation or development.

Both frameworks are cross-platform and work with a hybrid approach and showed some similar characteristics related to the parameters mentioned before. These parameters are referred to in table 2.2:

Ionic PhoneGap

Supported computer Windows, Linux, Windows, Mac OSX operating systems Mac OSX

Supported mobile Android, iOS Android, iOS,

platforms BlackBerry 10,

Windows and Windows Phone, Firefox OS, Ubuntu, Tizen, Amazon Fire OS

Programming JavaScript JavaScript

languages

Official documentation and 5 5

community (1-5)

Speed and complexity 5 5

of installation (1-5)

Complexity of 5 5

development (1-5)

(52)

30 Chapter 2. State-of-the-Art

PhoneGap does not support Linux as operating system but has the others in common to Ionic. According to supported platforms, Ionic is limited only to Android and iOS while PhoneGap allows a lot of other platforms like BlackBerry or Windows Phone.

The three last parameters are classified in a 1 to 5 scale, and both frameworks are rated as a 5 in all of them. Official documentation and community categorized with a 5 rate means the support is clear, detailed and easy to find and understand, which help newcomers and even more experienced developers to find answers for the existing questions. Speed and complexity of installation with a 5 rate, shows these tasks are easy and do not take much time. Finally, the development complexity is also rated with 5, showing the frameworks are intuitive and the languages used are straightforward [3].

Imagem

Figure 2.1: Aquatic pH levels [6]
Figure 2.5: IoT applications
Figure 2.6: Characteristics Zibgee vs Wi-Fi vs Bluetooth [24]
Figure 2.7: MQTT communication [28]
+7

Referências

Documentos relacionados

The probability of attending school four our group of interest in this region increased by 6.5 percentage points after the expansion of the Bolsa Família program in 2007 and

Analyzing the full development cycle, the combination T3 for the EM-AN phase with minimum, optimum and maximum temperatures of 4, 22 and 30 °C, respectively, and

The application of the decision tree allowed identifying that the maximum EVI, date of sowing, date of maximum vegetative development, cycle, and the major integral

Organic matter, physical properties and water retention Table 2 presents the minimum, maximum, and mean values of the database samples for each soil class used to generate and

The enriched control bioassay, presented minimum and maximum values of 0.051 and 2,152µg/m, on the first and ninth days, respectively The minimum and maximum concentrations observed

Caso utilizado em neonato (recém-nascido), deverá ser utilizado para reconstituição do produto apenas água para injeção e o frasco do diluente não deve ser

O grande objetivo da educação aritmética e algébrica, hoje, deve ser o de encontrar um equilíbrio entre três frentes: i) o desenvolvimento da capacidade de pôr em jogo