You are on page 1of 97

MINISTRY OF EDUCATION AND TRAINING university

HANOI UNIVERSITY OF SCIENCE AND ,ju:ni'və:siti TECHNOLOGY


- UK

---------------------------------------
DANH TỪ
JOÃO FILIPE OFIÇO

1. trường đại học


2. tập thể (của một) trường đại học
3. đội đại học (đội thể thao của một trường
đại học)

JOÃO FILIPE OFIÇO


TELECOMMUNICATIONS

STUDY ON INTERNET OF THINGS

MASTER OF SCIENCE
2014B

HANOI – 2016
MINISTRY OF EDUCATION AND TRAINING
HANOI UNIVERSITY OF SCIENCE AND TECHNOLOGY
---------------------------------------

JOÃO FILIPE OFIÇO

STUDY ON INTERNET OF THINGS

MAJOR : TELECOMMUNICATIONS

MASTER THESIS IN SCIENCE

SCIENTIFIC SUPERVISOR:
Dr. TRƯƠNG THU HƯƠNG

Hà Nội – 2016
CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM

Độc lập – Tự do – Hạnh phúc

BẢN XÁC NHẬN CHỈNH SỬA LUẬN VĂN THẠC SĨ

Họ và tên tác giả luận văn : João Filipe Ofiço


Đề tài luận văn: Nghiên cứu về internet của Vạn vật
Chuyên ngành: Kỹ thuật viễn thông
Mã số SV: CB141072

Tác giả, Người hướng dẫn khoa học và Hội đồng chấm luận văn xác nhận tác
giả đã sửa chữa, bổ sung luận văn theo biên bản họp Hội đồng ngày 24/08/2016
với các nội dung sau:

1) Thay đổi đoạn 3.2 thành “M2M standard and protocols”


2) Luận án đã gần như tuân theo đúng chuẩn yêu cầu của một luận án thạc sĩ
cần có. Nhưng các liên kết giữa các tiểu mục trong luận án cần được
chỉnh sửa chính xác hơn.
3) Cần thay đổi tiêu đề của luận án thành “Nghiên cứu về internet của Vạn
vật”.
4) Cần xem xét và chỉnh sửa các lỗi ngữ pháp trong luận án.

Ngày 26 tháng 08 năm 2016

Giáo viên hướng dẫn Tác giả luận văn

TS. Trương Thu Hương João Filipe Ofiço

CHỦ TỊCH HỘI ĐỒNG

PGS.TS. Nguyễn Hữu Thanh


DECLARATION
I hereby declare that master’s Thesis of my authorship and of the orientation of
my supervisor.

The data and results presented in this thesis are honest and not yet published in
any previous study.

All cited information is appreciated in the reference list.

Author

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

(João Filipe Ofiço)

July, Hanoi

i
LIST OF FIGURES
Figure 2.1: Internet of Things is "born" between 2008 and 2009 [3] .........................7
Figure 2.2: Common IoT devices and Technologies [9] ............................................9
Figure 2.3: Real Time Stream Processing- Google IoT [11] ....................................12
Figure 2.4: IBM IoT Foundation [12] .......................................................................13
Figure 2.5: ThingWorx IoT foundation [13] .............................................................14
Figure 2.6: Electric Imp and ThingSpeak IoT [14] ...................................................16
Figure 2.7: Digital Service Cloud IoT foundation [10] ............................................17
Figure 2.8: Data streaming from Gateway to cloud by Amazon Kinesis [10] .........18
Figure 2.9: Microsoft IoT foundation [15] ................................................................20
Figure 2.10: IoT Connectivity [18] ...........................................................................22
Figure 2.11: IoT Architecture [22] ............................................................................28
Figure 2.12: Applications of IoT [6] .........................................................................33
Figure 3.1: Three basic stages of M2M technology [26] ..........................................36
Figure 3.2: M2M Protocol Stack and Technical Challenges [29] ............................42
Figure 3.3: Architecture of M2M system [30] ..........................................................45
Figure 3.4: Examples of components of M2M system [30] .....................................45
Figure 4.1: House design with distribution of the smart devices in each area..........47
Figure 4.2: Structure of the Internet of Things system .............................................48
Figure 4.3: Duty Cycle PWM [31]. ...........................................................................51
Figure 4.4: PIR sensor ...............................................................................................52
Figure 4.5: Raspberry Pi 3 [33] .................................................................................54
Figure 4.6: Raspberry Pi interface after installing Rasbian OS ................................56
Figure 4.7: Connection diagram of Arduino LED and Motion sensor [38]..............57
Figure 4.8: Bluetooth connection between smart devices with Gateway .................68
Figure 4.9: IoT ecosystem .........................................................................................69
Figure 4.10: PIR sensor data .....................................................................................71
Figure 4.11: Node-Red ..............................................................................................72
Figure 4.12: Login for access the interface RockMongo ..........................................73

ii
Figure 4.13: Interface RockMongo (management software MongoDB) ..................74
Figure 4.14: Testbed for the Usecase Ecosystem .....................................................75

iii
LIST OF ACRONYMS

6LoWPAN - IPv6 over Low-power Wireless Personal Area Networks

API- Application Programming Interface

ARAT – Active Reader active tag

AWS – Amazon Web Service

BLE - Bluetooth Low Energy

BSS – Billing Support system

CoAP - Constrained Application Protocol

DSC – Digital service cloud

DSL - Digital Subscriber Line

EC2 – amazon Cloud Compute

ETSI - European Telecommunications Standards Institute

GSM - The Global System for Mobile Communication

HTTP - Hyper-Text Transfer Protocol

IEEE – Institute of electrical and electronics Engineers

IETF – Internet Engineering Task Force

IoT - Internet of Things

IP - Internet Protocol

IPv6 - Internet Protocol version 6

ISM - Industrial, Scientific and Medical radio band

JSON - JavaScript Object Notation

LAN- Local Area Network.

LTE - Long-Term Evolution

iv
M2M – Machine to Machine

MCU - Microcontroller

MQTT - Message Queuing Telemetry Transport

NFC - Near Field Communication

PaaS - platform as a service

PAN - Personal Area Network

REST - Representation State Transfer

RF - Radio Frequency

RF4CE - Radio Frequency for Consumer Electronics

RFID- Radio frequency Indentification

ROM - Read-Only Memory

RTOS – Real Time Operating System

TCP - Transmission Control Protocol

TIA - Telecommunications Industry Association

UDP - User Datagram Protocol

UI - Unique Identifier

URL - Universal Resource Locator

WiMAX - Worldwide Interoperability for Microwave Access

WPAN - Wireless Personal Area Network

WSN - Wireless Sensor Network

XML- Extensible Markup Language

v
ACKNOWLEDGEMENTS
I would like to thank my supervisor, Dr. Trương Thu Hương and the IoT research
group for their support during the course of this thesis.

I also would like to thank my adorable family, who always support me in my


whole life. My wonderful parents and my bride, who have emotionally supported
me during my master degree study abroad. Without their support, I could not have
had the opportunity to even start my studies.

vi
ABSTRACT
This work aims to explain the concepts of the M2M communication and IoT
concept, reference models, architectures and protocols used in the Internet of
Things. My thesis intends to give an overview on the Internet of Things, as well as
helps beginners build Internet of Things applications by their own.

In this research, the IoT and M2M communication will be discussed, terms that
have arisen with the creation of devices that can access the network to communicate
and exchange information. Those can optimize and facilitate tasks like collecting
information of things and of the environments where they are.

The implementation of this thesis aims to build an infrastructure for an IoT


ecosystem with the server responsible for collecting, storing data and also to allow
the viewing of the data generated by the motion sensors and cloud, which are
responsible for light monitoring. Despite some difficulties encountered during the
work, the defined goals were met.

vii
Contents
DECLARATION ..............................................................................................................i

LIST OF FIGURES ..........................................................................................................ii

LIST OF ACRONYMS...................................................................................................iv

ACKNOWLEDGEMENTS ............................................................................................vi

ABSTRACT ...................................................................................................................vii

CHAPTER 1 - INTRODUCTION ................................................................................... 2

1.1 Introduction ........................................................................................................ 2

1.2 Motivations ......................................................................................................... 3

1.3 Goals ................................................................................................................... 4

1.4 Research Questions ............................................................................................. 4

1.5 Structure of the thesis ......................................................................................... 5

CHAPTER 2 - INTERNET OF THINGS OVERVIEW ................................................. 6

2.1 Internet of Things vision..................................................................................... 6

2.1.1 What is Internet of Things? ......................................................................... 7

2.1.2 Smart Objects ............................................................................................... 7

2.1.3 IoT Devices .................................................................................................. 8

2.2 Advantages and disadvantages of IoT ................................................................ 9

2.2.1 Advantages of IoT ....................................................................................... 9

2.2.2 Disadvantages of IoT ................................................................................. 10

2.3 Internet of Things platform .............................................................................. 10

2.3.1 Introduction to IoT platform ...................................................................... 10

2.3.2 Some platform of IoT ................................................................................ 11

2.4 Transmission Technology................................................................................. 20


2.4.1 Process of IoT ............................................................................................ 20

2.4.2 Connectivity for the Internet of Things ..................................................... 21

2.5 Internet of Things Architecture ........................................................................ 28

2.5.1 Sensor Layer .............................................................................................. 28

2.5.2 Gateways and Networks Layer .................................................................. 29

2.5.3 Management Service Layer ....................................................................... 30

2.5.4 Application Layer ...................................................................................... 31

2.6 Application ....................................................................................................... 31

2.7 Operating System for the Internet of Things .................................................... 33

2.8 Chapter conclusion ........................................................................................... 34

CHAPTER 3 - MACHINE TO MACHINE COMMUNICATION .............................. 35

3.1 What is M2M? .................................................................................................. 35

3.1.1 M2M Platforms .......................................................................................... 36

3.1.2 Types of M2M Platforms........................................................................... 37

3.2 M2M standards and protocols .......................................................................... 38

3.2.1 Protocols and networking standards .......................................................... 38

3.2.2 Protocols .................................................................................................... 39

3.3 M2M protocol stack and technical challenges ................................................. 41

3.4 Architecture and components of M2M ............................................................. 42

3.5 Chapter conclusion ........................................................................................... 45

CHAPTER 4 - CASE STUDY TESTBED ESTABLISHMENT AND RESULTS ...... 47

4.1 IoT system ........................................................................................................ 48

4.1.1 Smart device .............................................................................................. 48

4.1.2 Gateway ..................................................................................................... 52


4.1.3 Cloud server ............................................................................................... 54

4.2 Hardware selection ........................................................................................... 55

4.3 Description of the experience ........................................................................... 55

4.3.1 Protocol for the connection between Smart Device Gateway ................... 68

4.3.2 Architecture ............................................................................................... 68

4.3.3 Operation Modes........................................................................................ 69

4.4 Results .............................................................................................................. 70

CONCLUSION .............................................................................................................. 76

REFERENCES ............................................................................................................... 77

Appendix A: Arduino code for the Second Floor .......................................................... 81


CHAPTER 1 - INTRODUCTION
This chapter is composed by the introduction, the motivation, and the goals of
this study.
The general goal describes, in few words, the whole investigation and the
specific goal will describe each of the steps that compose this research.

1.1 Introduction
Nowadays the Internet is one of the most important and the most used means of
communicating.

The internet makes a big impact in many areas and also for all of the humanity.
Therefore, the internet can be considered one of the greatest creations in the history
[1].

The next generation of the Internet will be the Internet of Things which can be
acknowledged as a worldwide network of interconnected objects [2]. In this new
model, any object has a unique ID and can join a common and known network
which is the Internet [1].

The Internet of Things is a new way of information exchanging that is different


from that one that is frequently used. Now things can communicate not only with
people but also with other devices.

If we analyze the impact that the internet brought to the humanity in general, we
can conclude that the internet is one of the most important and powerful creations in
the history. IoT represents a progress that will make use of revolutionary
applications [3].

For connection within the internet, wireless communication can be used as it is


popularly presented nowadays. With the increasing universal demand in wireless
connections, the applications such as wireless sensors networking and the internet
of things become more and more popular [4]. Sensors are devices which are used to

2
get information about the environments. These can be used as a network to
communicate with other devices.

A sensors network has many sensors devices distributed in a certain


environment. This kind of network can be applied for controlling, tracking and
processing in different situations, for example, security monitoring [3].

The IoT thesis title is supported by the fact that it represents an innovation in the
network concept. This is a system that collects useful data, through sensing devices
and to process the collected data. Many data are collected through IoT, it can be an
advance to the society.

1.2 Motivations
As we all know that the global network of computers that are interconnected
through TCP/IP is called internet. Internet changed the way long distance
communication was conducted, it created new ways to share and acquire
knowledge; it changed the way awareness was spread across communities and so
on. Internet also changed the entertainment and media industry. It was a great leap
when people from different parts of the world were able to connect with each other
through internet to share, learn and care.

A new concept associated with the “Future Internet” is called “Internet of


Things” describes a vision where real objects become part of the internet: where
each object is uniquely identified, and accessible to the network [5].

To create a real life scenario, one can imagine a smart home; a house full of
smart objects: smart TV, smart phone, lights, heating system and etc. All these
objects are connected to each other creating an IoT network and connected to the
internet with a special Gateway device. The owner is able to control these devices
with his smart phone or laptop from his job or anywhere he can connect to the
internet. For a more specific situation: the owner of the house checks the
temperature sensor values and decides to turn the heating system of the house on
just before he left his job so that he can have a "warm" welcome when he reaches

3
the house. Since variety of smart objects are on the market, working with Bluetooth,
ZigBee, ANT or 6LoWPAN, the most important component of this scenario is to
build the IoT network inside the house; while the main challenge is to avoid the
unauthorized people to get control of your house [6].

These were the major motivations of the study, since the topic is of public
interest today.

1.3 Goals
General:
 To implement an Internet of Things infrastructure using the communication
protocol.
Specific:
 To study IoT;
 To learn M2M communication;
 To identify the Internet of Things reference model;
 To identify some protocols that are used in the Internet of Things;
 To check the operating system used in the Internet of Things.

1.4 Research Questions


What is the Internet of things?

What is the M2M communication?

What are the protocols used in the Internet of Things?

What are operating systems used in the Internet of Things?

4
1.5 Structure of the thesis
The rest of the thesis is structured as follows:

Chapter 2: Presents the overview of the Internet of Things, including advantages


and disadvantages of the internet of things;

Chapter 3: Presents some theories about M2M communication, M2M protocols


stack and technical challenges, M2M standards and protocols, Architecture and
components of M2M.

Chapter 4: Presents the case study testbed establishment, description the material
used for the implementation and the final results.

In the end, it presents the conclusion, some recommendations for future work and
references.

5
CHAPTER 2 - INTERNET OF THINGS OVERVIEW
In this chapter we discuss the concept of the Internet of Things, transmission
technologies and architecture of the Internet of Things, applications, Smart objects,
Smart devices, Internet of Things platform, advantages and disadvantages of IoT
and Operating System for the Internet of Things.

2.1 Internet of Things vision


The term was first proposed by Kevin Ashton in 1999. IoT represents the
moment that the things connected to the internet over trough the quantity of the
people, making and receiving lots of traffics. In 2003, there were about 6.3 billion
of people in the planet and 500 millions of devices connected to the internet,
resulting 0.08 devices per person. In that period IoT didn’t exist yet, if we consider
the number of the objects connected [3].

With crescent use of smartphones and tablets it was increased the number of
devices connected to the internet, about 12.5 billion in 2010, increasing the number
of devices connected per person to more than 1.84 for the first time [3].
Observing the figure 2.1, which belongs to an investigation of cisco internet
Business solutions Group, it was observed that that the quantity of devices
connected to the internet will grow in next years. Consequently the number of
devices connected per person will also increase [3].

In this new model of internet, the communication will be done not only by
people, but also by people and things and by own object. It will be the join of the
physical world with the information world. It will be possible if each machine
communicates with another machine, with the aid of one unique identification form,
as occurs on the Internet current [2].

6
Figure 2.1: Internet of Things is "born" between 2008 and 2009 [3]
2.1.1 What is Internet of Things?
In 2005, ITU published an annual report of the Internet of Things, which
extended the concept of the Internet of things and posed the foreground of "Any
Time, and Any Place, and Any Things Connection", “Ubiquitous networks” and
“Ubiquitous Computing”, except RFID technology, sensor technology,
nanotechnology and smart things technology will be more widely applied [7].

The IoT is defined as a dynamic global network infrastructure with self-


configuring capabilities based on standard and interoperable communication
protocols where physical and virtual “things” have identities, physical attributes and
virtual personalities, use intelligent interfaces and are seamlessly integrated into the
information network [8].

2.1.2 Smart Objects

Any object which not only has a state, which has certain data associated with a
state but an object which can also determine nature of connectivity, duration of
connectivity and connectivity protocol are called smart objects.

RFID, Bluetooth Low Energy and NFC make it possible to use our phone as
readers. We can extract information from certain objects just by tapping it or

7
bringing our device close to it. RFID tags do not have any embedded system or does
a NFC tag has. But data can still be brought to internet by reading through a reader.
These are called smart objects. Non-processor entity whose data can be acquired
and migrated over internet falls under these category.

Short-range low-energy sensor technology has given rise to smart objects. So


say a T-Shirt comes with a smart tag. We can tap our phone over it and we get
information about the quality of material, it's size, other color variants, dye
information and so on which helps us making our purchase decision. As the
information is acquired, it can be passed as a search query to obtain similar results
where we can compare the price-quality for similar tags.

2.1.3 IoT Devices

Anybody who keeps track of the Silicon Vally is sure to know that IoT is the
latest buzz. So many of the startups now are focusing towards IoT. Therefore when
we are talking about IoT, we are basically talking about infinite possibilities,
hardware and software platform. So when trying to find a list of IoT devices on the
internet, one might end up getting frustrated purely because it's is difficult to
provide such list.

Therefore, researching in this particular subsection has taken significant time.


Finally, we have put together some most common and popular technologies in IoT
to make an overview of what devices we are really talking about.

We divide the IoT devices into two broad categories: The wearable ones and
Microcontroller/Microprocessor driven embedded IoT ones. Some of the embedded
devices like Arduino Lilly pad are minisque and anybody can further utilize them to
make their own wearable solution. However, wearable hardware which is pretty
standard and IoT has only software scope for the developer [9].

8
Here is a diagram of common peripheral hardware that one might have to learn
while working with IoT hardware in embedded level.

Figure 2.2: Common IoT devices and Technologies [9]

So not being a hardware geek can be started with Wearable and start making
apps for popular wearable platforms. Being a hardware enthusiast, can be started
with Embedded IoT platform. Any of the broader technologies like Raspberry Pi,
Arduino or Galileo and startup with IoT development, must be selected [9].

2.2 Advantages and disadvantages of IoT


2.2.1 Advantages of IoT
Some of the most important advantages of IoT are as follows [6]:

Transportation: IoT eases and simplifies the entire process by introducing a


monitory sensor that helps to track distance and time locations and other
contributing factors.

Inventory Management: IoT is used to tag radio frequency sensors to track the
location of products in real time. It has been instrumental in tracking the level of

9
inventory and to stock it in advance, making alerts for unforeseen stoppages,
automatically placing orders, etc.

Assessing web user intelligence: IoT is used by third party web data aggregators
to have a better understanding of their key customer by tracking them on social
media networks to know their preferences.

Integration into Health Care Systems: This could prove to be incredibly


beneficial for both an individual and a society. A chip could be implemented into
each individual, allowing for hospitals to monitor the vital signs of the patient.

2.2.2 Disadvantages of IoT


Considering that IoT is still an emerging technology, it has its unfulfilled
drawbacks [6]:

Compatibility: Currently, there is no international standard of compatibility for


the tagging and monitoring equipment. The manufacturing companies of this
equipment need to agree to a standard, such as Bluetooth, USB, etc.

Privacy: In light of the NSA spying revelations, having more information


accessible on the web to government agencies, data aggregators, and hackers may
not be a comforting thought for members of the public.

Potential of widespread malware: The interconnection of devices could make it


much easier for malware to spread throughout a home’s integrated system, with
results ranging from complete corruption to minor inconveniences.

Complexity: As with all complex systems, there are more opportunities of failure.
With the Internet of Things, failures could sky rocket. Infrastructure is still being
developed and it will still take quite some time to overcome these disadvantages.

2.3 Internet of Things platform


2.3.1 Introduction to IoT platform
Platform: A platform could be a hardware plus software suite upon which other
applications can operate. Platform could comprise hardware above which Operating

10
system can reside. This Operating system will allow application to work above it by
providing necessary execution environment to it [10].

2.3.2 Some platform of IoT


Various IoT platforms are now a day available that can be used for developing an
IoT solution but in this thesis we have covered seven popular platforms that are
widely used for IoT solution building.

2.3.2.1 Google Cloud Platform


Google Cloud Platform provides the infrastructure to handle streams of data fed
from millions of intelligent devices.

Google is one of the popular IoT platforms because of: Fast global network,
Google's BigData tool, Pay as you use strategy, Support of various available
services of cloud like RiptideIO, BigQuery, Firebase, PubSub, Telit Wireless
Solutions, Connecting Arduino and Firebase and Cassandra on Google Cloud
Platform and much more [10].

Figure 2.3 shows real time stream processing by Google. Devices send their
status information to App Engine. So first load balancer makes sure that the load is
balanced among various app engines. Then compute engine performs data
computation and publication of data. Multiple instances of compute engine are
available to insure reliability and scalability. The data is stored and backed up using
cloud storage. Big query allows speedy insertion of data in tables of cloud database.
The results can be presented to the end users by means of various analysis and
visualization technique.

Key features:

 Run on Google's infrastructure;


 Scalability;
 Compute, storage and services
 Higher performance;

11
 Provided support if required;
 Assurance of Google Grade security and compliance for your applications;
 Environment safe cloud.

Figure 2.3: Real Time Stream Processing- Google IoT [11]


2.3.2.2 IBM BlueMix
IBM BlueMix is a platform as a service cloud which is developed by IBM. It
supports programming languages like java, php, Python, Node.js, Go and much
more. Integrated DevOps allows to build, run, deploy as well as to manage
applications over IBM BlueMix cloud [10].

IoT foundation shown in Figure 2.4 combined with IBM BlueMix platform
provides powerful application access to IoT data and devices. IBM BlueMix
support rapid development of analytics applications, visualization dashboard, and
mobile IoT applications. We can create our IoT application with IBM Bluemix and
then IBM provide REST and secure API to connect our device data with our
application. IBM IoT foundation is the Hub where we can set up and manage our
connected devices. IBM IoT foundation uses MQTT protocol to securely transfer
device data to cloud [12].

Key features:

 Powerful web dashboard

12
 Device Registration
 Scalable connectivity
 Security of communication
 Storage of data
 Provided support if required

Figure 2.4: IBM IoT Foundation [12]


2.3.2.3 ThingWorx
ThingWorx is the first software platform designed to build and run the connected
world applications. ThingWorx focuses on reducing the time, cost, and risk required
to build innovative M2M and IoT applications. ThingWorx accelerates IoT
application development by compressing the design-develop-deploy cycle and
reducing time to market. The ThingWorx Internet of Things Foundation is powered
by a ThingWorx's following leading products and services: ThingWorx Composer,
Codeless Mashup Builder, Event-Driven Execution and 3D Storage, ThingWorx
SQUEAL, ThingWorx Edge MicroServer [10].

As shown in figure 2.5 ThingWorx IoT platforms provide device cloud to


connect millions of device with IoT application. It provides always on
communication using REST, MQTT and sockets. Above the layer of
communication there are system service integration, 3D storage engine and business

13
logic. System service integration interact with business systems like ERP, CRM etc.
3D storage engine enables big data analytics. Above it there is a layer for REST
APIs that helps to implement and use social services and cloud services. Then the
data is presented via various visualization techniques [10].

Key features:

 Modern and Complete Platform provisioning;


 Faster deployment;
 Integrate People, Systems and Machines;
 Deploy in the way we Like to do it;
 Let your Application evolve and grow Over Time
 Search-based Intelligence;
 Allows collaboration;
 Flexible Connectivity Options.

Figure 2.5: ThingWorx IoT foundation [13]

14
2.3.2.4 ThingSpeak
ThingSpeak is an application platform for the development of IoT systems. It can
help to build the application which works upon the data collected by sensors.
ThingSpeak is an open data platform for IoT application development. ThingSpeak
is the perfect complement to an existing enterprise system to tap into the Internet of
Things. It provides the ability to integrate our data with a variety of third-party
platforms, systems and technologies, including other leading IoT platforms such as
ioBridge and Arduino. ThingsSpeak channel is used to send and store data [10].

Figure 2.6 shows ThingSpeak IoT with Electric Imp platform. Here Electric Imp
is a platform with provides connectivity of WiFi devices with cloud services. It
provides access to the Electric Imp modules. Once the connectivity to such modules
is simplified by Electric Imp cloud, data services from ThingSpeak are used to get
IoT experience [10].

Key features:

 It provides real time collection of data storage;


 Data analytics and Visualization using MATLAB;
 Device Communication;
 Open API support;
 Provides Geolocation data;
 Facilitates plugins.

15
Figure 2.6: Electric Imp and ThingSpeak IoT [14]
2.3.2.5 Digital Service Cloud
Digital service cloud is an open IoT platform. It allows IoT innovators to own
their customers the way customers own their products. It supports product start-ups,
global technological brands and product innovators. It is a platform that accelerates
time to market process for a new innovation. By using the readymade infrastructure
provided by DSC, one can build needed customized IoT solutions by connecting
devices and using plug and play dashboard. Then one has to monitor and manage
the product over its lifetime. It connects our product with a network of millions of
devices. It runs a UI-driven rules engine that requires no coding. It monitors and
streams a petabyte of real time data. It operates on a secure tenant based system and
provides quick launch of our application with a wizard based app builders [10].

Figure 2.7 shows Digital service cloud IoT foundation. Here consumer devices
equipped with variety of sensors can connect to IoT application available on cloud
and can communicate with application. Various networking and connectivity
techniques are available that can connect the devices over cloud. Cloud provides
device management and app development. Data analytics and visualization through
powerful dashboard are supported to end users [10].

Key features:

16
 Scalability;
 Security;
 Plug and Play;
 Unified customer service;
 Big data analytics;
 Monitoring, maintenance and management of devices;
 Multi-channel support delivery;
 Preventive support through support cloud;
 Users across diverse verticals.

Figure 2.7: Digital Service Cloud IoT foundation [10]


2.3.2.6 Amazon Web Services
Amazon Web Services allows Internet of Things on a global scale by facilitating
security, services and support. It facilitates immediate access to desired computing
power by means of EC2. Helps to performs big data analytics and supports high
volume data. Amazon Kinesis helps to ingest data from thousands of sensors. AWS
provides security to your data which can be in transit or at rest. AWS provide pay-
as-you-go model for IoT applications. It has it multiple pricing models like tiered
pricing, Reserved Instances, and an active marketplace. AWS supports on demand
infrastructure to accommodate need of IoT system. It provides access to more
storage, compute capability and global resources when needed. AWS provides

17
flexibility for IoT applications in terms of tools, programming languages, data
management and other infrastructure resources. ActiveMq and Mosquito servers
help in managing and analyzing IoT applications. User identity, device analytics,
and device messaging/notifications are all common parts of an Internet of Things
application Amazon Web Services provides services that take the effort out of these
important parts of your application. Services like Amazon Cognito, Amazon Mobile
Analytics, and Mobile Push to take care of the undifferentiated heavy lifting while
you focus on the differentiated benefits of application [10].

As shown in figure 2.8, Amazon Kinesis can collect high throughput data from
devices and gateways, and then it can analyze and store it over cloud so that
applications can consume it and can generate quick decision. It can support data up
to any scale.

Key features:

 Scalability;
 Privacy and Security;
 High availability and flexibility;
 Data analytics and storage of high volume data;
 On demand services like other platforms;
 Provides Hardware resources.

Figure 2.8: Data streaming from Gateway to cloud by Amazon Kinesis [10]

18
2.3.2.7 Microsoft Azure Cloud
Azure is Microsoft’s cloud computing platform, a rising collection of integrated
services analytics, database, computing, networking, mobile, storage and web for
moving quicker, accomplishing more and saving money.

Azure IoT Suite helps securely connect millions of Linux, RTOS (Real Time
Operating System), iOS, Android and Windows devices to reliably send telemetry
and receive commands from your application back-end in the cloud [15]

Figure 2.9 shows how Microsoft provides IoT solution. The core of Microsoft
IoT foundation is Microsoft Azure cloud platform. It provides connectivity of
millions of devices and sensors with IoT application. It provides remote access,
monitoring, and content distribution and configuration management facilities for
connected devices. It provides big data analysis, social as well as business
integration and dash boarding tools to IoT application to build an IoT solution.

Key features [10]:

 Build on what already established;


 Get more benefits from your existing assets;
 Small changes and big reflection;
 Trusted support;
 Expertise in development to deployment;
 Connectivity of any device;
 Skilled partners and powerful innovation;
 Data insights;
 Scalability;
 Easy way for business transformation;
 Agility.

19
Figure 2.9: Microsoft IoT foundation [15]
2.4 Transmission Technology
2.4.1 Process of IoT
To achieve a successful integration, IoT must be supported from some
innovational technologies. RFID is one of the key enablers of IoT. Connecting and
communicating with small objects require a uniquely identified system and real
time tracking, which RFID can provide by getting information about the location
and status of objects. The IoT can be divided into three processes [16]:

a) Items signing and identifying: The popular identification technology now is


radio frequency identification, in short RFID technology. RFID is a kind of
non-connecting Auto-ID technology, it uses the radio frequency to identify
the target item and acquire the relevant data .RFID consists of three
components: tag, which is made up by and IC, every single tag has a unique
electronic code, adhering to the items to identify the target; reader, a device
which can read(sometimes can write in) the tag’s information, has two forms,
handset or fixed one; antenna, sending the radio frequency signal between
the tag and the reader [17].
b) The process of information transmission: Information transmission can be
divided into a wired transmission and wireless transmission. In the Internet

20
of Things, the two transmissions will be involved in the transmission process
of data from the collection device to the background processing center. The
process that the item identification information is read by the collection
equipment and the process that the Information from the collection device
transmitted to the Internet backbone network are wireless transmissions. The
backbone of the Internet of Things refers to the current communication
network, including Internet, telecom net and Enterprise networks and so on,
which is a typical wired transmission mainly responsible for the transmission
between the information processing center and external communication
devices.
c) Backstage center intelligent processing: The center mainly does the work of
pooling, converting, analyzing on the collection of information and data, and
adapt the information according to the specific needs of the user's and trigger
the event. Because a large number of original data is obtained from the
ending note and only after the original data is converted, selecting and
analyzing has the actual value for the users. The center also arranges these
data collation according to the specific content of services and
correspondingly respond according to the user’s triggering event.

2.4.2 Connectivity for the Internet of Things

The embedded systems can use a range of connectivity to connect with other
devices or the internet, as show in figure 2.10.

21
Figure 2.10: IoT Connectivity [18]

The following are some communication technologies of smart devices:

2.4.2.1 Bluetooth
An important short-range communications technology is of course Bluetooth,
which has become very important in computing and many consumer product
markets. It is expected to be key for wearable products, in particular, again
connecting to the IoT albeit probably via a smartphone in many cases. The new
Bluetooth Low-Energy or Bluetooth Smart, as it is now branded is a significant
protocol for IoT applications. Importantly, while it offers similar range to Bluetooth
it has been designed to offer significantly reduced power consumption [19].

However, Smart/BLE is not really designed for file transfer and is more suitable
for small chunks of data. It has a major advantage certainly in a more personal
device context over many competing technologies given its widespread integration
in smartphones and many other mobile devices. According to the Bluetooth SIG,
more than 90% of Bluetooth-enabled smartphones, including iOS, Android and
Windows based models, are expected to be ‘Smart Ready’ by 2018. Devices that
employ Bluetooth Smart features incorporate the Bluetooth Core Specification

22
Version 4.0 (or higher the latest is version 4.2 announced in late 2014) with a
combined basic-data-rate and low-energy core configuration for an RF transceiver,
baseband and protocol stack. Importantly, version 4.2 via its Internet Protocol
Support Profile will allow Bluetooth Smart sensors to access the Internet directly
via 6LoWPAN connectivity (more on this below). This IP connectivity makes it
possible to use existing IP infrastructure to manage Bluetooth Smart ‘edge’ devices.
Bluetooth 4.2 core specification:

 Frequency: 2.4GHz (ISM)


 Range: 50-150m (Smart/BLE)
 Data Rates: 1Mbps (Smart/BLE)

2.4.2.2 ZigBee
ZigBee, like Bluetooth, has a large installed base of operation, although perhaps
traditionally more in industrial settings. ZigBee PRO and ZigBee Remote Control
(RF4CE), among other available ZigBee profiles, are based on the IEEE802.15.4
protocol, which is an industry-standard wireless networking technology operating at
2.4GHz targeting applications that require relatively infrequent data exchanges at
low data-rates over a restricted area and within a 100m range such as in a home or
building. ZigBee/RF4CE has some significant advantages in complex systems
offering low-power operation, high security, robustness and high scalability with
high node counts and is well positioned to take advantage of wireless control and
sensor networks in M2M and IoT applications. The latest version of ZigBee is
recently launched 3.0, which is essentially the unification of the various ZigBee
wireless standards into a single standard. An example product and kit for ZigBee
development are TI’sCC2538SF53RTQT ZigBee System-On-Chip IC and CC258
ZigBee Development Kit [19].

 Standard: ZigBee 3.0 based on IEEE802.15.4;


 Frequency: 2.4GHz;
 Range: 10-100m;

23
 Data Rates: 250kbps.

2.4.2.3 WiFi
WiFi connectivity is often an obvious choice for many developers, especially
given the pervasiveness of WiFi within the home environment within LANs. It
requires little further explanation except to state the obvious that clearly there is a
wide existing infrastructure as well as offering fast data transfer and the ability to
handle high quantities of data [19].

Currently, the most common WiFi standard used in homes and many businesses
is 802.11n, which offers serious throughput in the range of hundreds of megabit per
second, which is fine for file transfers, but may be too power-consuming for many
IoT applications. [19].

 Standard: Based on 802.11n (most common usage in homes today);


 Frequencies: 2.4GHz and 5GHz bands;
 Range: Approximately 50m;
 Data Rates: 600 Mbps maximum, but 150-200Mbps is more typical,
depending; on channel frequency used and number of antennas (latest
802.11-ac standard should offer 500Mbps to 1Gbps).

2.4.2.4 NFC
NFC is a technology that enables simple and safe two-way interactions between
electronic devices, and especially applicable for smartphones, allowing consumers
to perform contactless payment transactions, access digital content and connect
electronic devices. Essentially it extends the capability of contactless card
technology and enables devices to share information at a distance that is less than
4cm [19].

 Standard: ISO/IEC 18000-3;


 Frequency: 13.56MHz (ISM);
 Range: 10cm;

24
 Data Rates: 100–420kbps.

2.4.2.5 6LoWPAN
A key IP-based technology is 6LowPAN. Rather than being an IoT application
protocols technology like Bluetooth or ZigBee, 6LowPAN is a network protocol
that defines encapsulation and header compression mechanisms. The standard has
the freedom of frequency band and physical layer and can also be used across
multiple communications platforms, including Ethernet, WiFi, 802.15.4 and sub-
1GHz ISM. A key attribute is the IPv6 stack, which has been a very important
introduction in recent years to enable an IoT. IPv6 is the successor to IPv4 and
offers approximately 5 x 10 28 addresses for every person in the world, enabling any
embedded object or device in the world to have its own unique IP address and
connect to the Internet. Specially designed for home or building automation, for
example, IPv6 provides a basic transport mechanism to produce complex control
systems and to communicate with devices in a cost-effective manner via a low-
power wireless network [19].

Designed to send IPv6 packets over IEEE802.15.4-based networks and


implementing open IP standards including TCP, UDP, HTTP, COAP, MQTT, and
websockets, the standard offers end-to-end addressable nodes, allowing a router to
connect the network to IP. 6LowPAN is a mesh network that is robust, scalable and
self-healing. Mesh router devices can route data destined for other devices, while
hosts are able to sleep for long periods of time.

 Standard: RFC6282
 Frequency: (adapted and used over a variety of other networking media
including Bluetooth Smart (2.4GHz) or ZigBee or low-power RF (sub-
1GHz)
 Range: N/A
 Data Rates: N/A

25
2.4.2.6 Z-Wave
Z-Wave is a low-power RF communications technology that is primarily
designed for home automation for products such as lamp controllers and sensors
among many others. Optimized for reliable and low-latency communication of
small data packets with data rates up to 100kbit/s, it operates in the sub-1GHz band
and is impervious to interference from WiFi and other wireless technologies in the
2.4-GHz range such as Bluetooth or ZigBee. It supports full mesh networks without
the need for a coordinator node and is very scalable, enabling control of up to 232
devices. Z-Wave uses a simpler protocol than some others, which can enable faster
and simpler development, but the only maker of chips is Sigma Designs compared
to multiple sources for other wireless technologies such as ZigBee and others [19].

 Standard: Z-Wave Alliance ZAD12837 / ITU-T G.9959


 Frequency: 900MHz (ISM)
 Range: 30m
 Data Rates: 9.6/40/100kbit/s

2.4.2.7 LoRaWAN
Again, similar in some respects to Sigfox and Neul, LoRaWAN targets wide-area
network applications and is designed to provide low-power WANs with features
specifically needed to support low-cost mobile secure bi-directional communication
in IoT, M2M and smart city and industrial applications. Optimized for low-power
consumption and supporting large networks with millions and millions of devices,
data rates range from 0.3 kbps to 50 kbps [19].

 Standard: LoRaWAN
 Frequency: Various
 Range: 2-5km (urban environment), 15km (suburban environment)
 Data Rates: 0.3-50 kbps.

26
2.4.2.8 ANT
ANT is a proprietary WSN technology featuring a wireless communications
protocol stack that enables semiconductor radios operating in the 2.4 GHz
Industrial, Scientific and Medical allocation of the RF spectrum ("ISM band") to
communicate by establishing standard rules for co-existence, data representation,
signaling, authentication and error detection [20].

2.4.2.9 RFID
Radio frequency identification is the wireless use of electromagnetic fields to
identify objects. Usually, would install an active reader, or reading tags that
contain a stored information mostly authentication replies. Experts call that an
Active Reader Passive Tag (ARPT) system. Short range RFID is about 10cm, but
long range can go up to 200m. What many do not know is that Léon Theremin
invented the RFID as an espionage tool for the Soviet Union in 1945. An Active
Reader Active Tag (ARAT) system uses active tags awoken with an interrogator
signal from the active reader. Bands RFID runs on: 120 –150 kHz (10cm), 3.56
MHz (10cm-1m), 433 MHz (1-100m), 865-868 MHz (Europe), 902-928 MHz
(North America) (1-12m) [21].

a) Pros and Cons of RFID

Pros:

 Does not require power;


 Established and widely used technology.

Cons:

 Highly insecure;
 Ongoing cost per card;
 Tags need to be present as identifier and be handed over before;

27
 Not compatible with smartphones.

Examples include animal identification, factory data collection, road tolls, and
building access. RFID tag is also attached to an inventory such that its production
and manufacturing progress can be tracked through the assembly line. We believe
RFID technology will very soon be replaced by NFC technology in smartphone
[21].

2.5 Internet of Things Architecture


IoT architecture consists of different suite of technologies supporting IoT. It
serves to illustrate how various technologies relate to each other and to
communicate the scalability, modularity and configuration of IoT deployments in
different scenarios [22].

Figure 2.11: IoT Architecture [22]

The functionality of each layer are described follow:

2.5.1 Sensor Layer


The lowest layer is made up of smart objects integrated with sensors. The sensors
enable the interconnection of the physical and digital worlds allowing real-time

28
information to be collected and processed. The miniaturization of hardware has
enabled powerful sensors to be produced in much smaller forms which are
integrated into objects in the physical world [22].

There are various types of sensors for different purposes. The sensors have the
capacity to take measurements such as temperature, air quality, movement and
electricity. In some cases, they may also have a degree of memory, enabling them to
record a certain number of measurements. A sensor can measure the physical
property and convert it into signal that can be understood by an instrument. Sensors
are grouped according to their unique purpose such as environmental sensors, body
sensors, home appliance sensors and vehicle telematics sensors, etc [22].

Most sensors require connectivity to the sensor aggregators (Gateways). This can
be in the form of a LAN such as Ethernet and WiFi connections or PAN such as
ZigBee, Bluetooth and Ultra- Wideband (UWB). For sensors that do not require
connectivity to sensor aggregator their connectivity to backend servers/applications
can be provided using WAN such as GSM, GPRS and LTE. Sensors that use low
power and low data rate connectivity, they typically form networks commonly
known as WSNs. WSNs are gaining popularity as they can accommodate far more
sensor nodes while retaining adequate battery life and covering large areas [22].

2.5.2 Gateways and Networks Layer


Massive volume of data will be produced by these tiny sensors and this requires a
robust and high performance wired or wireless network infrastructure as a transport
medium. Current networks, often tied with very different protocols, have been used
to support M2M networks and their applications.

With demand needed to serve a wider range of IoT services and applications such
as high speed transactional services, context-aware applications, etc, multiple
networks with various technologies and access protocols are needed to work with
each other in a heterogeneous configuration. These networks can be in the form of a

29
private, public or hybrid models and are built to support the communication
requirements for latency, bandwidth or security [22].

A possible deployment could consist of a converged network infrastructure that


resolves the fragmentation by integrating disparate networks into a single network
platform. Converged network layer abstraction allows multiple organizations to
share and use the same network independently for their information to be routed
without compromising their privacy, security and performance requirements. Each
organization thus utilizes the network as if it is a private network resource to them
[22].

2.5.3 Management Service Layer


This layer is used for managing the IoT services. Management Service layer is
responsible for Securing Analysis of IoT devices, Analysis of Information (Stream
Analytics, Data Analytics), Device Management [23].

Data management is required to extract the necessary information from the


enormous amount of raw data collected by the sensor devices to yield a valuable
result of all the data collected. This action is performed in this layer.

Also, certain situation requires immediate response to the situation. This layer
helps in doing that by abstracting data, extracting information and managing the
data flow. This layer is also responsible for data mining, text mining, service
analytics etc.

From the figure 2.11, we can see that, management service layer has Operational
Support Service (OSS) which includes Device Modeling, Device Configuration and
Management and many more. Also, we have the Billing Support System (BSS)
which supports billing and reporting [23].

Also, from the figure 2.11, we can see that there are IoT/M2M Application
Services which includes Analytics Platform; Data which is the most important part;
Security which includes Access Controls, Encryption, and Identity Access

30
Management etc.; and then we have the Business Rule Management (BRM) and
Business Process Management (BPM) [23].

2.5.4 Application Layer


Application layer forms the topmost layer of IoT architecture which are
responsible for effective utilization of the data collected. Various IoT applications
include Home Automation, E-health, E-Government etc [23].

From the figure 2.11, we can see that there are two types of applications which
are Horizontal Market which includes Fleet Management, Supply Chain etc. And on
the Sector wise application of IoT we have energy, healthcare, transportation etc
[23].

2.6 Application
IoT has potential for societal, environmental as well as economic impact.
Accurate information about the status, location and identity of things, which forms
part of and impacts on the environment, allows for smarter decision making and
appropriate action taking. IoT concepts have been demonstrated in a variety of
domains, ranging from logistics, transport and asset tracking, smart environments
(homes, buildings, infrastructure), to energy, defense and agriculture. In essence,
IoT impacts and certainly has the potential to significantly influence all facets of
society [24].

IoT is relevant in every step in every value chain. He has identified seven main
value drivers. The first four based on value from M2M communication, while the
last three create value with the integration of users. The drivers as identified by
Fleisch are [24]:

Simplified manual proximity trigger – things can communicate their identity


when they are moved into the sensing space of a sensor. Once the identity is known
and communicated, a specific action or transaction can be triggered.

31
Automatic proximity trigger – an action is triggered automatically when the
physical distance of two things drops below (or passes) a threshold. The identity of
the thing is known, which when combined with the physical location and action
allows for better processes.

Automatic sensor triggering – a smart (or cooperative) thing can collect data via
any type of sensor including temperature, acceleration, orientation, vibration and
humidity. The thing senses its condition and environment, communicates the
information which enables prompt (and global) decision making.

Automatic product security – a thing can provide derived security (information)


based on the interaction between the thing and its cyberspace representation (e.g. a
QR-code containing a specific URL pointing to relevant information).

Simple and direct user feedback – things can incorporate simple mechanisms to
provide feedback to a human present in the environment. Often these feedback
mechanisms are in the form of audio (audible beep) or visual (flashing light)
signals.

Extensive user feedback – things can provide rich services to a human (often the
thing is linked to a service in cyberspace through a gateway device such as a smart
phone). Augmented product information is a good example of extensive user
feedback.

Mind changing feedback – the combination of real world and cyberspace might
generate a new level of changing behaviors in people. One possibility is changing
the driving behavior as sensors in the vehicle communicate driving patterns to an
outside agency.

Figure 2.12 shows some applications of the internet of things.

32
Figure 2.12: Applications of IoT [6]

2.7 Operating System for the Internet of Things


OS Description

Raspbian OS Raspbian OS is a Debian [Linux] based operating system for


the Raspberry Pi developed and maintained independent of the
Foundation.

Risc OS This was an OS designed in Cambridge, England by Acorn in


1987. The team who developed the ARM microprocessor was
part of the team building the Risc OS. The OS is now owned
by Castle Technology Ltd and the source is managed by Risc
OS Open Limited [ROOL]

Plan 9 Plan 9 OS comes as a bundle of Operating system and


software’s. The software is written for Plan 9 and is not ported
from Unix or Linux. Most of the services like the window
system, compiler, file server and network services were freshly
written for the Plan 9 Operating system

Android The popular mobile OS android can also be run on the

33
Raspberry Pi.

Contiki Contiki is an open source, highly portable, multi-tasking


operating system for memory-efficient networked embedded
systems and wireless sensor networks. Contiki has been used
is a variety of projects, such as road tunnel fire monitoring,
intrusion detection, wildlife monitoring, and in surveillance
networks.Contiki is designed for microcontrollers with small
amounts of memory. A typical Contiki configuration is 2
kilobytes of RAM and 40 kilobytes of ROM.

RIOT RIOT OS is an operating system for Internet of Things


devices. It is based on a microkernel and designed for: energy
efficiency, hardware independent development, a high degree
of modularity.

Table 1: Operating system for IoT

2.8 Chapter conclusion


Through this chapter, we provide an overview of the Internet of Things as
applications, concepts, platforms, communication technologies, operating systems
and other. The Internet of Things brings several changes in controlling devices, and
will make it possible for us to control devices anywhere with the available Internet.
It uses some different communication technologies to connect the devices together.
Only when understand how IoT works can we build well our IoT ecosystem.

34
CHAPTER 3 - MACHINE TO MACHINE COMMUNICATION
In this chapter we discuss the concept of M2M, M2M Platforms, M2M standards
and protocols, M2M protocol stack and networking standards, Architecture and
components of M2M and some protocols.

3.1 What is M2M?


M2M communications is a broad term refers to technologies that allow
mechanical or electronic devices to connect with other devices and freely automate
data transmission and measurement using the wireless networks. The key
component of M2M is a small hardware module embedded in the main and larger
device such as sensor, monitoring system, automobile, air conditioner, surveillance
camera, or alarm system, which usually needs to communicate with other devices in
the network. In fact, there is not big difference between this small module and the
type of communication radio or transceiver circuits embedded in the cell phone and
smart objects [25].

In simple terms, it is a technology that enables devices to interact with each other
over a wired or wireless communication network without any human intervention.
M2M technology usually employs sensors, actuators, MCUs and/or RF
Transceivers that acquires data from an end device or an event which is then
transmitted via a communication network (either Global System for Mobile
Communications GSM/General Packet Radio Service GPRS, powerline or satellite)
to application software that processes the received data into meaningful
information. The three basic stages of M2M technology are illustrated in Figure 3.1.

35
Figure 3.1: Three basic stages of M2M technology [26]

3.1.1 M2M Platforms


Traditionally, M2M solutions have been conceived and deployed as ‘stovepipe’
(or standalone) solutions with the aim of improving (or enabling) a specific process,
but without consideration of how these solutions might one day be integrated into a
wider business context.

Today, M2M solutions are doing more than just monitoring the status of remote
assets and equipment. They are gathering real-time data from millions of connected
machines, for example, tractors, medical devices, vending machines, or storage
tanks, and translating it into meaningful information for quick decisions, automated
actions, and strategic analytics. The primary driver for M2M solutions is now
enabling new services, rather than just improving operational efficiency/cost saving.

A platform is considered to be a group of technologies that are used as a base


upon which applications, processes or other technologies are developed or
delivered.

36
Creating a platform is usually a complex and delicate task, and needs to serve
multiple purposes, but the primary purpose is to support and simplify the work of
those who will be using or consuming this platform. M2M platforms have
transformed the M2M market by making device data more accessible to application
developers, and also by offering well-defined software interfaces and making APIs
available so that application developers can readily integrate information sources
and control parameters into their applications.

3.1.2 Types of M2M Platforms


Over the past decade, the M2M platform space has developed rapidly, and now
includes the following broad platform functions [27]:

 Connectivity Support: it encompasses all of the most fundamental tasks that


must be undertaken to configure and support a machine-to-machine
connection. In a mobile environment, such tasks include connection
provisioning, usage monitoring, and some level of support for fault
resolution.
 Service Enablement: it has extensive capabilities in terms of solution support,
reporting and provision of a software environment and APIs to facilitate
solution development. Together, Connectivity Support, and Service
Enablement functions represent the ‘horizontal’ elements of the M2M
platforms industry.
 Device Management: it has typically been aligned to single device
manufacturers and potentially supports devices of multiple types and vendors
connected through multiple networks. Device management platforms
essentially exist to facilitate sales of devices (and device-centric solutions)
where those devices typically require some form of non-standard systems
support (reporting, management, etc.).
 Application Support: it is characterized by the provision of tailored solutions,
encompassing connected devices potentially of multiple types, connected

37
with multiple technologies, and connected to the networks of multiple CSPs
(Communication Service Providers).
 Solution Provider: it should be regarded typically as an enabler for a large
system development initiative, rather than as a standalone offering. These
M2M platforms are generally used by systems integrators to support turnkey
and client-specific solutions.

While many of these platform type implementations have some overlapping


functionality (further complicating the M2M delivery ecosystem while
simultaneously attempting to streamline it), the end goal is similar, i.e. mainly to
make sure that the data collected from all of these machines and sensors are actually
used to improve the business of the company investing in the collection [27].

3.2 M2M standards and protocols


Connecting M2M and also the services that they provide to people require the
wide range of technologies and standards. This brings many research fields for the
future Internet of Things. For that reason, many organizations like ITU, ETSI, TIA
start to cooperate and develop collaborative networks that will communicate even if
they talk different protocols. OneM2M initiative tries to provide unified definition
of M2M architecture that includes specifications in order to implement standard
API [20].
3.2.1 Protocols and networking standards
IEEE (Institute of Electrical and Electronics Engineers)
 IEEE 802.11 and 802.15
IETF (Internet Engineering Task Force)
 6LoWPAN
 CoAP (Constrained Application Protocol)
ITU (International Telecommunication Union)
 Focus group on M2M service layer
ETSI (European Telecommunications Standards Institute) - EU

38
 OneM2M
TIA (Telecommunications Industry Association) – USA
 OneM2M
BBF (Broadband Forum)
 TR-069 protocol specification
OMA (Open Mobile Alliance)
 OMA-DM
OASIS (Advancing Open Standards for the Information Society)
 XACML
NIST (National Institute of Standards and Technology)
 Access Control
CSA (Cloud Security Alliance)
3.2.2 Protocols
The table below shows some communication protocols

Protocol Descriptions

CoAP CoAP is a software protocol intended to be used in very


simple electronics devices that allows them to communicate
-IETF Page
interactively over the Internet. It is particularly targeted for
small low power sensors, switches, valves and similar
components that need to be controlled or supervised
remotely, through standard Internet networks.

CoAP is an application layer protocol that is intended for


use in resource-constrained internet devices, such as WSN
nodes. CoAP is designed to easily translate to HTTP for
simplified integration with the web, while also meeting
specialized requirements such as multicast support, very
low overhead, and simplicity"

39
RESTful HTTP "Representational State Transfer (REST) is a style of
software architecture for distributed systems such as the
World Wide Web. REST has emerged as a predominant
web API design model”.

MQTT "MQTT is an open message protocol for M2M


communications that enables the transfer of telemetry-style
-Homepage
data in the form of messages from pervasive devices, along
-(OASIS Page)
high latency or constrained networks, to a server or small
message broker."

XMPP "The Extensible Messaging and Presence Protocol (XMPP)

-Foundation is an open technology for real-time communication, which


powers a wide range of applications including instant
-IETF WG
messaging, presence, multi-party chat, voice and video
calls, collaboration, lightweight middleware, content
syndication, and generalized routing of XML data."

UDP A simple OSI transport layer protocol for client/server


network applications based on Internet Protocol (IP). UDP
is the main alternative to TCP and one of the oldest network
protocols in existence, introduced in 1980. UDP is often
used in applications specially tuned for real-time
performance.

AMQP An open standard application layer protocol for message-


oriented middleware. The defining features of AMQP are
message orientation, queuing, routing (including point-to-
point and publish-and-subscribe), reliability and security.

Table 2: Communication protocols

MQTT protocol

40
MQTT stands for Message Queue Telemetry Transport is a lightweight network
protocol used for publishing and subscribing to messages that are sent between
devices. It is invented by Dr Andy StanfordClark of IBM and Arlen Nipper of
Arcom, with the goal to create a protocol that is bandwidth-efficient and uses little
battery power. The protocol works on top of the TCP/IP protocol, and is ideal for
use in constrained environments or low-bandwidth networks with limited
processing capabilities, small memory capacities and high latency [28].

Publishing and subscribing

The MQTT protocol provides publish-and-subscribe messaging from clients to a


broker [28].

Clients

A MQTT client is any device from a micro controller up to a server that has a
MQTT library running and is connecting to a MQTT broker over any kind of
network. Clients can subscribe and publish on topics, the topic is the routing
information for the broker. A MQTT client app is responsible for collecting
information from the telemetry device, connecting to the server, and publishing the
information to the server. To create a MQTT client, we will need to use a MQTT
library. These libraries are available for a broad variety of devices and frameworks
[28].

Brokers

The broker is primarily responsible for receiving all the messages, filtering them,
decide who is interested in it and then sending the message to all subscribed clients.
Brokers receive messages from publisher clients on a topic, which they forward to
the subscribers of the topic [28].

3.3 M2M protocol stack and technical challenges


As Figure 3.2 illustrates, the protocol stack for the M2M communication includes
various standardized protocols at transport, network and data link layers, where

41
each layer is contributing to addressing at least one challenge in the M2M
communication, such as security and reliability [29].

Typically, M2M systems utilize IP-compatible open protocols that are


standardized, in order to be widely deployable. Despite the fact that IP-based
protocols requires large memory footprint, the IP-based approach is gaining more
momentum in large-scale deployments in the context of M2M. Recently, various
protocols have been proposed to support the M2M development, such as the CoAP
and MQTT, aiming to address the requirements resulting from integrating resource-
constrained devices. However, there are no sophisticated guidelines of protocol
stack deployment for the future M2M services. OneM2M protocol working group
has specified mapping standard APIs to several underlying transport protocols to
meet the requirements of various use cases. In addition to HTTP, which is the de
facto Internet transport protocol, specifications are defined to map CoAP/UDP and
MQTT/TCP to support integration of constrained devices in the IoT [29].

Figure 3.2: M2M Protocol Stack and Technical Challenges [29]


3.4 Architecture and components of M2M
The various components and elements of an M2M system are briefly described
below [30]:

42
M2M Device: Device capable of replying to request for data contained within
those devices or capable of transmitting data autonomously. Sensors and
communication devices are the endpoints of M2M applications. Generally, devices
can connect directly to an operator’s network, or they will probably interconnect
using WPAN technologies such as ZigBee or Bluetooth. Backhaul to an operator’s
network is than achieved via gateways that encapsulate and manage all devices.
Consequently, addressing and identifying, e.g., routing, of the devices relies heavily
on the gateways. Devices that connect via gateways are normally outside the
operator’s responsibility but belong to M2M applications that are provided by
service or application providers. Sensors and devices that connect directly into an
operator’s network (via embedded SIM, TPM and radio stack or fixed line access)
are endpoints of the network. Thus, the responsibility in terms of accountability,
SLAs etc., lies within the network operator (or virtual network operator). This holds
true especially with respect to TPM (Trusted Platform Module) where it is
necessary to ensure that the module is really that reliable and well protected [30].

M2M Area Network (Device Domain): Provide connectivity between M2M


Devices and M2M Gateways, e.g. personal area network.

M2M Gateway: Equipment that uses M2M capabilities to ensure M2M Devices
inter-working and interconnection to the communication network. Gateways and
routers are the endpoints of the operator’s network in scenarios where sensors and
M2M devices do not connect directly to the network. Thus, the task of gateways
and routers are twofold. Firstly, they have to ensure that the devices of the capillary
network may be reached from outside and vice versa. These functions are addressed
by the access enablers, such as identification, addressing, accounting etc., from the
operator’s platform and have to be supported at the gateway’s side as well. Thus,
platform and gateway form a distributed system, where generic and abstract
capabilities are implemented on the gateway’s side. Consequently, there will be a
control flow between gateway and operator’s platform that has to be distinguished
from the data channel that is to transfer M2M application data. Secondly, there may

43
be the need to map bulky internet protocols to their lightweight counterpart in low-
power sensor networks. However, the latter application might lose its relevance
since there are implementations of IPv6 for sensor networks available, that allow an
all-IP approach [30].

M2M Communication Networks (Network Domain): It covers the


communications between the M2M Gateway(s) and M2M application(s), e.g.
XDSL, LTE, WiMAX, and WLAN.

M2M Applications: It contains the middleware layer where data goes through
various application services and is used by the specific business-processing engines.
M2M applications will be based on the infrastructural assets (e.g., access enablers)
that are provided by the operator. Applications may either target at end users, such
as user of a specific M2M solution, or at other application providers to offer more
refined building blocks by which they can build more sophisticated M2M solutions
and services. e.g. customer care functionality, elaborate billing functions, etc.
Those services, or service enablers, may be designed and offered by an application
provider, but they might be offered by the operator via the operator platform itself
[30]. Figure 3.3 shows a simple architecture of M2M systems with its components.

44
Figure 3.3: Architecture of M2M system [30]
Figure 3.4 shows the M2M system with examples of various components and
applications.

Figure 3.4: Examples of components of M2M system [30]


3.5 Chapter conclusion
This chapter provides a general overview of some protocols and networking
standards that are important for creating one M2M communication.

45
The number of interconnected machines will very soon exceed the overall
population count. Therefore, it is important to understand well M2M interactions. In
this chapter we focus on the concepts of M2M, M2M standards and protocols basic
architecture and M2M protocols stack.

Also found that all the activities and with help of collaboration work of the
standards developing organizations in few years we will have generalized
framework for M2M communications that will support many heterogeneous devices

46
CHAPTER 4 - CASE STUDY TESTBED ESTABLISHMENT AND
RESULTS
After obtaining theoretical knowledge in previous parts of this thesis, in this
chapter we build a case study ecosystem in which, we intend to control the lighting
in a house that are assumed to have 3 areas (first floor, stairs and second floor). The
functions of the lighting system are described as follows:

1. Sensors are installed at each floor and staircases to sense the motion of persons.
Each time a motion is detected at a sensor, the light is turn on locally at that
point.
2. When a person passes by a sensor, for example, in the first floor, and pass by the
next sensor in the staircase connecting the first and second floor after a while,
the light bulb in the second floor should be turn on before the one reaches the
second floor.

Function (1) lights up the bulb at the needed area for a person. Function (2)
allows the system to smartly manage the lighting of a floor without person detection
beforehand. With this function, the lighting will be turn on before the person
reaches the floor based on the detection of his movement from the first floor to the
second floor.

Figure 4.1: House design with distribution of the smart devices in each area

47
An illustration of the smart device installation in a house can be described in
figure 16 house design with the distribution of the smart devices in each area.

4.1 IoT system


Figure 4.2 illustrates the Internet of Things system, the smart device sends data
via Bluetooth to the Gateway, and the gateway then sends to the cloud through
MQTT protocol.

Figure 4.2: Structure of the Internet of Things system


4.1.1 Smart device
A smart device is an electronic device, generally connected to other devices or
networks via different wireless protocols such as Bluetooth, NFC, WiFi, 3G, etc.,
that can operate to some extent interactively and autonomously. In this
implementation, we use Arduino Uno R3 and motion sensor (PIR) as smart devices.

Role:

48
 Arduino Uno reads the signal from PIR sensor every second and sends to
Gateway via Bluetooth.
 Receive command “turn on” or “turn off” from the Gateway to control the
light of the second floor through the cloud.
a) Arduino

The Arduino is a platform of hardware and software, built in single card that has
the aim of simplifying the application of objects or interactive environments. This
platform of low cost has analogic and digital writing and reading and has many
specific components that can interact with a simple and intelligent object.

Generally, these models use processors mega AVR, of Atmel corporation (2014),
the voltage is 5v, current 40mA per pin (reach 150m in wire 20 AWG,
unamplified), 32KB of flash memory, SRAM of 2KB, EEPROM of 1KB and watch
of 16MHz. The boards are programmable, libraries using the Arduino, with the
language C with an abstraction simplified. The board programming was abstracted;
so that the people without familiarity with the microcontrollers or with
programming languages can write the applications and that can be easily transmitted
to the board using integrated development environment.

The IDE Arduino, which includes Arduino library in written codes, is responsible
for transmitting and implementing automatically the program in the board. The
board has analogic and digital entrances. The digital writing or output in their pins
consists it is to convert the program code HIGH (1) or LOW (0), in constant signs
of 5v or 0v. The digital entrance in their pins consists of interpreting a to the voltage
of 5v or 0v and convert them to HIGH (1) or LOW (0) in their pins, respectively.
The analogic reading consists in reading the voltage between 0v and 5v, through an
analogic-digital converter (ADC), from 0 to 1023 to be transferred to the code as a
whole, and that the quantization used, has sensitivity / error 4,9mV.

The analogic Writing consists in taking the code which varies from 0 to 255 and
passes it to its pin using pulse width modulation (PWM). This technic can simulate

49
analogic results in analogic devices, using digital means altering the time when the
sign is between 5v and 0v. The time that pulse has to vary between 0v and 5v is 2
milliseconds and that is called duty cycle.

If the programmer sends 0 of analogic writing in its code, a pulse generated at


pin stays 0% of a duty cycle in 5V, an analogic device would be stimulated in the
same way if it received 0v during all time.

If the programmer sends 64 of analogic writing in its code, a pulse generated at


pin stays 25% of a duty cycle in 5v, an analogic device would be stimulated in the
same way if it received 0V during all time. If the programmer sends 127 of analogic
writing in its code, a pulse generated at pin stays 50% of a duty cycle in 5v, an
analogic device would be stimulated in the same way if it received 2.5v during all
time.

If the programmer sends 191 of analogic writing in its code, a pulse generated at
pin stays 75% of a duty cycle in 5v, an analogic device would be stimulated in the
same way if it received 3.75v during all time.

If the programmer sends 225 of analogic writing in its code, a pulse generated at
pin stays 100% of a duty cycle in 5v, an analogic device would be stimulated in the
same way if it received 05v during all time. These relations are presented in a figure
4.3-Duty Cycle PWM.

50
Figure 4.3: Duty Cycle PWM [31].
There are several components of low cost developed by many manufactories the
have hardware and software especially for compatibility with digital and analog
inputs and outputs of the Arduino. Among the most common components we find
temperature measurement of the air, humidity of air, humidity of soil, pressure,
distance, luminosity, fume, human touch, RFID reading director of fire wood, gyros
copy, infrared, accelerometer, detector of alcohol in air, detector of sound, GPS,
detector of metals, detector of locomotion, color identification and visible light.

b) Motion sensor (PIR)

PIR sensors detect a person’s body heat when the person comes in close
proximity. These sensors are small, low power, inexpensive and easy to use. Due to
these reasons, PIR sensors are generally used in gadgets, home appliances, business
enterprises, industries, etc. PIR gives digital output when it detects motion. It

51
consists of pyro-electric sensor that detects the infrared radiation emitted from
humans.

Figure 4.4: PIR sensor


Technical parameters

 Operating voltage: DC5V


 Static power consumption: 65 microamps
 Level output: high-5V, low-0V
 Delay Time: adjustable (0.3 seconds to 18 seconds)
 Embargo time: 0.2 seconds
 Sensing range: less than 120 degrees angle, 7 meters
 Operating temperature: -15 ~ +70 degrees

4.1.2 Gateway
A gateway is a network point that acts as an entrance to another network. On the
Internet, a node or stopping point can be either a gateway node or a host (end-point)
node [32]. we use Raspberry Pi 3 model B as Gateway.

Role:

 Gateway receives data from the smart device via Bluetooth and sends the
data to the cloud through MQTT protocol.
 Receive command “turn on” or “turn off” from the cloud and send to a smart
device of the second floor.

52
If we intend to extend the network, extended smart devices should be edited the
python code in Gateway and the javascript code in the cloud.

Raspberry Pi

Was given in 2006, the Raspberry pi is a microcontroller like a credit card, its
function is to help in procreation teaching and in electronic projects as home
automation, scientific experiments or music experiments. It's based on free
operation systems, like Debian or fedora and work through an SD card. The board is
fed by USB common when we connect to a keyboard, mouse and monitor; it can
function as a regular Linux computer. The Raspberry pi can have its developed
applications in languages as python, C, C++, java and Ruby, and can allow
additional software installations that can be compiled to platform ARMv6.

As Arduino, the Raspberry pi can also connect the GPIOs To a variety of circuits
developed by other manufacturers that allow controlling and feeling the
environment. The both places are small and of low cost, and the Arduino the
smallest and cheaper.

The main differential of Raspberry pi is in its capacity of process, storage, its


applications are bigger than Arduino.

Some Pi 3 Model B Technical Specifications

 40pin extended GPIO;


 4 x USB 2 ports;
 4 pole Stereo output and Composite video port;
 Full size HDMI output;
 CSI camera port for connecting the Raspberry Pi camera;
 DSI display port for connecting the Raspberry Pi touch screen display;
 Micro SD port for loading your operating system and storing data;
 Upgraded switched Micro USB power source (now supports up to 2.5
Amps);

53
 The same form factor as the Pi 2 Model B, the only difference is the location
of the onboard LEDs.

Figure 4.5: Raspberry Pi 3 [33]


4.1.3 Cloud server
A cloud server is a logical server that is built, hosted and delivered through a
cloud computing platform over the Internet. Cloud servers possess and exhibit
similar capabilities and functionality to a typical server but are accessed remotely
from a cloud service provider [34]. In cloud we have MongoDB, Mosquitto broker
and Node-Red, we use cloud server Amazon EC2.

Role:

 Receive data and compare data from the first floor and the stairs, afterwards
send "turn on" or "turn off" to the LED on the second floor;
 Store all data received in MongoDB.

MongoDB is a cross-platform and open-source document-oriented database, a


kind of NoSQL database. As a NoSQL database, MongoDB shuns the relational
database’s table-based structure to adapt JSON-like documents that have dynamic
schemas which it calls BSON [35].

54
This makes data integration for certain types of applications faster and easier.
MongoDB is built for scalability, high availability and performance from a single
server deployment to large and complex multi-site infrastructures.

Node- RED is a visual tool for wiring the Internet of Things, but it can also be
used for other types of applications to quickly assemble flows of services. The name
is not the most intuitive name. The reason why ‘Node’ is in the name is because the
tool is implemented as Node application but from a consumer point of view that is
really only an internal implementation detail. Node-RED is available as open source
and has been implemented by IBM emerging technology organization.

Mosquitto is an Open Source MQTT v3.1 message broker. It aims to provide the
same features (and more) as IBM's Really Small Message Broker but as fully Open
Source software [36].

The Amazon Elastic Compute Cloud (EC2) is an infrastructure as a service


(IaaS) cloud. This means that it provides computing power and resources that we
can use for a fee [37].

4.2 Hardware selection


 Arduino Uno R3;
 Raspberry Pi 3;
 LEDs;
 PIR sensor;
 Bluetooth Module;

4.3 Description of the experience


After the selection of the material, the operating system Raspbian was installed
into the raspberry pi 3 as shown in figure 4.6.

55
Figure 4.6: Raspberry Pi interface after installing Rasbian OS

After the installation of the operating system on Raspberry pi 3, we connect Pin 1


of the motion sensor connects to the 5V DC voltage terminal of the Arduino. Pin 3
connects to the ground (GND) pin of the Arduino. Pin 2, the output, connects to the
digital pin D2.

With this connection, pins 1 and 3 are powered with 5V by the Arduino, so it is
through these pin connections that the PIR motion sensor gets the 5V that it needs
to power on and operate.

And it is through pin 2 that the Arduino receives output from the motion sensor.
When the motion detector does not detect any motion, the output is LOW and the
Arduino receives no voltage signal. When the sensor detects motion, the output is
HIGH and the Arduino receives a voltage signal, which can then trigger another
device to turn on, such as an LED we will use for this circuit.

The LED we will light connects pin 13 and ground of the board. The anode
connects to pin 13 and the cathode connects to ground. No external resistor is
necessary to limit current to the LED, because pin 13 already has built-in resistance

56
to limit current flow. Figure 4.7 shows the connections between Arduino with PIR
Motion sensor and LED.

Figure 4.7: Connection diagram of Arduino LED and Motion sensor [38]

After connect the motion sensor and LED with Arduino, we connect Arduino
with Bluetooth module, as shown in table 3.

HC 05 Bluetooth module Arduino

Pin Vcc 3.3v

Pin GND GND

Pin TX 10~

Pin RX 11~

Table 3: Connection between Bluetooth module and Arduino

57
After all connections, we did the upload of the Arduino code for Arduino kit on
the first floor and in the stairs area. Following can be seen the Arduino code. The
Arduino code to the second floor can be found in the appendix A.

#include <SoftwareSerial.h>

#include <pt.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

static struct pt pt1,pt2,pt3;

boolean condition=false;

const int inputPin = 2;

const int led = 13;

char check_data = 0;

bool Motion_Detect = false;

int value;

int k;

void setup() {

pinMode(led, OUTPUT);

digitalWrite(led, LOW);

// put your setup code here, to run once:

Serial.begin(9600);

Serial.println("Start");

BTSerial.begin(38400);

PT_INIT(&pt1); // initialise the two

PT_INIT(&pt2);

58
PT_INIT(&pt3);

void SensorMotion(void);

void action();

void loop() {

// put your main code here, to run repeatedly:

protothread2(&pt2, 1000);

protothread1(&pt1, 1000);

protothread3(&pt3, 1000);

// SensorMotion();

int protothread1(struct pt *pt, int interval) {

static unsigned long timestamp = 0;

PT_BEGIN(pt);

while(1) {

PT_WAIT_UNTIL(pt, millis() - timestamp > interval );

timestamp = millis(); // take a new timestamp

getDataFromSensor();

PT_END(pt);

int protothread2(struct pt *pt, int interval) {

static unsigned long timestamp = 0;

59
PT_BEGIN(pt);

while(1) {

PT_WAIT_UNTIL(pt, millis() - timestamp > interval );

timestamp = millis();

act();

PT_END(pt);

int protothread3(struct pt *pt, int interval) {

static unsigned long timestamp = 0;

PT_BEGIN(pt);

while(1) {

PT_WAIT_UNTIL(pt, millis() - timestamp > interval );

timestamp = millis();

action();

PT_END(pt);

void getDataFromSensor()

{ int value = digitalRead(inputPin);

if (value == 1)

k=15;

60
}

void act()

if(k>0)

Serial.println("1");

BTSerial.print("1");

digitalWrite(led, HIGH);

--k;

else

BTSerial.print("0");

Serial.println("0");

digitalWrite(led, LOW);

void action()

String ch= BTSerial.readString();

Serial.println(ch);

if (ch=="ON"){

61
digitalWrite(led, HIGH);

After uploading the Arduino codes, it was written the code to the raspberry pi 3
in python, as can be seen in the following code:

from threading import Thread, Event

import threading

import thread

import time

import bluetooth

import paho.mqtt.client as mqtt

import re

import md5

from multiprocessing import Queue

global message

message = {}

macEncryp=[]

macNonEncryp=[]

result=[]

global controlMesg

controlMesg = ''

global status

62
status = ''

global sockActuator

global q

# This function scan bluetooth devices around Pi and return a tupple


{namedevice,macaddress}

# Call this funtion first!

nearby_devices = bluetooth.discover_devices(duration=3,lookup_names=True)

print nearby_devices

q=Queue()

pkt={}

packet={}

sock={}

myThread=[]

in_topic="Ofico/controls/in/#"

out_topic="Ofico1/controls/#"

client = mqtt.Client()

client.username_pw_set("ioteam","ioteam")

client_control = mqtt.Client()

client_control.username_pw_set("ioteam","ioteam")

client_control.connect("52.77.88.152", 1883, 60)

#client_control.connect("192.168.1.104", 1883, 60)

def on_publish(client, userdata, mid):

print("Published: ",mid)

63
def on_connect(client, userdata, rc):

print("Connected with result code "+str(rc))

client.subscribe(out_topic,2)

def on_message(client, userdata, msg):

q.put(msg.payload)

print msg.payload

def on_messageControl(client, userdata, msg):

global controlMesg

controlMesg=''+str(msg.payload)

print '123'+controlMesg

client_pub = mqtt.Client()

client_sub = mqtt.Client()

client_pub.username_pw_set("ioteam","ioteam")

client_pub.connect("52.77.88.152", 1883, 60)

#client_pub.connect("192.168.1.104", 1883, 60)

client_pub.on_connect = on_connect

client_pub.on_publish = on_publish

client_sub.username_pw_set("ioteam","ioteam")

client_sub.connect("52.77.88.152", 1883, 60)

#client_sub.connect("192.168.1.104", 1883, 60)

client_sub.on_connect = on_connect

client_sub.on_message = on_message

client_control.on_message = on_messageControl

64
lock = threading.Lock()

def sub_command():

client_sub.loop_forever()

def analyse_data():

lock.acquire()

data_queue=q.get()

fileMac=data_queue.split("|")

print fileMac

q.put(fileMac)

lock.release()

def pub_request():

#while 1 :

client_pub.publish(in_topic,"request")

#time.sleep(60)

lock_m= threading.RLock()

class exampleThread(Thread):

def __init__(self, threadID, threadName,targetadd):

threading.Thread.__init__(self)

self.threadID= threadID

self.threadName=threadName

self.targetadd= targetadd

def run(self):

sock[self.threadID]=bluetooth.BluetoothSocket(

65
bluetooth.RFCOMM )

sock[self.threadID].connect((self.targetadd,1))

pkt[self.threadID]=''

global message

global controlMesg

while 1:

message[self.threadID] = []

message[self.threadID].append(sock[self.threadID].recv(4))

pkt[self.threadID]=''.join(message[self.threadID])

lock_m.acquire()

print str(self.targetadd) + '-' +


pkt[self.threadID][len(pkt[self.threadID])-1]

client.connect("52.77.88.152", 1883,60)

#client.connect("192.168.1.104", 1883,60) # MQTT Broker


Server OnLAN

client.publish("Ofico/",
self.targetadd+','+pkt[self.threadID][len(pkt[self.threadID])-1]) # MQTT Topic,
MQTT Message = (MAC+Sensor_Status)

msg = ''.join(controlMesg)

if (str(self.targetadd) == "20:15:04:09:09:10") :

#~ msg = ''.join(controlMesg)

print msg

66
if msg is not '':

sock[self.threadID].send(msg)

controlMesg=''

lock_m.release()

time.sleep(1)

fileMac=['20:15:04:08:35:23','20:15:04:09:09:10','20:15:04:09:09:14']

for i in range(0,len(fileMac)):

for j in range(0,len(nearby_devices)):

if fileMac[i]==nearby_devices[j][0]:

result.append(nearby_devices[j])

arrayThread=[]

print result

for i in range(0,len(result)):

print i

topicname=str(result[i][1])

thread=exampleThread(i+1,topicname,result[i][0])

arrayThread +=[thread]

client_control.subscribe(out_topic,2)

client_control.loop_start()

for x in arrayThread:

print x

x.start()

67
4.3.1 Protocol for the connection between Smart Device Gateway
When running the python code, firstly it receives the signal of smart devices via
Bluetooth modules as shown in figure 4.8.

Figure 4.8: Bluetooth connection between smart devices with Gateway

4.3.2 Architecture
After the understanding of some of the IoT platforms, an ecosystem was built, as
shows in figure 4.9. Here, is shown that the Arduino and Raspberry pi communicate
via Bluetooth, while Raspberry Pi and cloud communicate through the MQTT
protocol. In the Cloud, we have Node-Red, MongoDB and Mosquitto broker.

68
Figure 4.9: IoT ecosystem
4.3.3 Operation Modes
In all areas (first floor, stairs and second floor), we use motion sensors to turn on
the LEDs, in addition, in the second floor it is also controlled through the cloud.

The Gateway support is demonstrated by connecting the Arduino Uno to a


Raspberry Pi, where the Raspberry Pi acts as a Gateway and publishes
events/receives commands.

When someone passes by the motion sensor of the first floor the locally control
“turn on” the LED of the first floor;

When that one passes by the sensor in the Stair area, then locally control to turn
on the LED in the stairs, all sensors (first floor, stair and second floor) sends their
data via Bluetooth to Raspberry Pi 3 in every one second, upon receiving the sensor
readings, Raspberry Pi Gateway published and stores the data in MongoDB through
MQTT protocol, then when the cloud detects that a smart device on the first floor
sends value "1" to the cloud and a smart device of the stairs also sends the value "1"

69
to the cloud, so the cloud sends “turn on” to the LED on the second floor after 5
seconds.

All sensors, when LEDs are turned on, they sends the signal 1(value) by 15
seconds to the cloud.

4.4 Results
When running python code in Raspberry Pi, we observed the PIR sensor data
being transmitted as shown in figure 4.10. The figure shows that we have three
devices transmitting data, one device is in the first floor (UI:'20:15:04:08:35:23');
two devices are in the stairs area (UI:'20:15:04:09:09:14') and in the second floor
(UI:'20:15:04:09:09:10') Where we have:

 20:15:04:08:35:23-1 meaning that the sensor detects movement in the first


floor and the LED light turns on;
 20:15:04:09:09:14-1 meaning that the sensor detects movement in the stairs
and the LED light turns on;
 20:15:04:09:09:10-1 meaning that the sensor detects movement in the second
floor and the LED light turns on or the cloud detected that the LED of the first
floor and of the stair are turned on;
 20:15:04:08:35:23-0 meaning that the sensor does not detect movement in the
first floor and the LED remains off;
 20:15:04:09:09:14-0 meaning that the sensor does not detect movement in the
stairs area and the LED remains off;
 20:15:04:09:09:10-0 meaning that the sensor does not detect movement in the
second floor or the cloud detects that the LED of the first floor and of the stair
are remain off;

 ON meaning that the cloud detects that in the first floor and stairs the LED
turns on, so it sends “turn on” to the LED of the second floor;
 123ON meaning that all LEDs are “turns on”.

70
Figure 4.10: PIR sensor data

When a Gateway receives data sensors sends to the cloud through MQTT
protocol and in the cloud found the Node-Red, and then our Node-RED receives the
data from the MQTT broker to saves it in a Mongo DB. Figure 4.11 shows Node-
Red of our implementation.

71
Figure 4.11: Node-Red

In the cloud, we write code in that when detecting that the LED in the first floor
and the stairs are turned on it sends “turn on” command to the LED of the second
floor, as shown in the following code. The code was written in JavaScript and is in
the Node-Red on the function block, where we have “f”.

var newMess = {};

messArr = (msg.payload).split(",");

newMess.mac = messArr[0];

newMess.value = messArr[1];

if (newMess.mac === "20:15:04:08:35:23"){

context.global.floor1 = Number(messArr[1]);

} else if (newMess.mac === "20:15:04:09:09:14"){

context.global.stair = Number(messArr[1]);

72
if ((context.global.floor1 === 1)&&(context.global.stair === 1)){

context.global.floor2 = "ON";

} else {

context.global.floor2 = "OFF";

return newMess;

The access of the Interface RockMongo is done by using a browser, typing the IP
address of the server in the URL address bar, where appears the displayed window
as in figure 4.12.

Figure 4.12: Login for access the interface RockMongo

The data sensor is stored in MongoDB through the communication protocol


MQTT, as shown the figure 4.13. Here is shown the stored data that is organized by
the unique identifier of Bluetooth module with sensor data 1 or 0, where 1 show that
detect motion in PIR sensor and 0 shows that don't detect motion in PIR sensor.

73
Figure 4.13: Interface RockMongo (management software MongoDB)
Figure 4.14 illustrates Testbed for the Usecase Ecosystem where we can check in
figure three smart devices connected the power in each area, the Gateway and the
LEDs.

74
Figure 4.14: Testbed for the Usecase Ecosystem

75
CONCLUSION
Concluding this thesis, it was possible to understand how the IoT has a great
potential for developing applications that will fringe many benefits, not only for the
Network areas but also for the humanity.

IoT allows many advances and discoveries for the society. This occurs with
increasing amount of data available for processing that the IoT provides, along with
the capability of data communications in the Internet. Thus, the more data is
generated, the more knowledge and wisdom people will get. During the
development of this thesis, we noted the lack of information related to the subject of
national origin, which shows the lack of studies in this area. On the other hand, we
found a wide variety of documents, applications, and studies about Internet of
Things developed in countries such as China, the United States, and some European
countries. At the end of this thesis, the main goal which is the implementation of an
Internet of Things infrastructure using the communication protocol, is reached.

Future Work

During the implementation of practical work, we have faced many problems with
the Internet connection to achieve significant successes. We recommend that
Internet with good speed and connectivity must be used. Also the related theory
must be studied before in order to understand more about the Internet of Things.
The reason is because proponents of the Internet of Things promise us a world in
which we will be connected with literally every kind of things we can think of.

76
REFERENCES
[1] D. Evans.(2011), "The Internet of things-How the Next Evolution of the
Internet Is Changing Everything," Cisco Internet Business Solutions Group.

[2] L. TAN and N. WANG.(2010), "Future Internet: The Internet of Things.,"


computer science and Tecnology Department East China Normal university,
Shanghai.

[3] A. A. LOUREIRO.(2003), "WSN", Minas Gerais: Departamento de Ciencias


da Computacão da Universidade Federal de Minas Gerais, Belo Horizonte.

[4] Y. JIANG, L. ZHANG and L. WANG. (2013), "Wireless Sensor Networks


and the Internet of Things. International Journal of Distributed Sensor
Networks. Research Center for Mobile Computing," Tsinghua University,
Institute of Microelectronics, China.

[5] L. Coertzee and J. Eksteen. (2011), "The Internet of Things - promise for the
future? An introduction," in IST- Africa conference Proceedings.

[6] R.Arpita and et al. (April 2015), international Journal of Engineering


Studies and technical Approach, vol. 01.

[7] H.-X. ZHAO. (2010), "Internet of Things key technology Analysis and
Discussion [J] Western Technology," China.

[8] V. Ovidiu and P. Friess. (2014), "Internet of things-From research and


Innovation to market Deployment", River pbublishers, pp. 11-19.

[9] [Online]. Available: http://www.codeproject.com/Articles/832492/Stage-


Introduction-to-the-Internet-of-Things. [Accessed 20 08 2015].

[10] N. Bhumi and C. Tushar. (December 2015), "study of various internet of


things platforms," International Journal of Computer Science & Engineering
Survey (IJCSES, vol. 6.

77
[11] [Online]Available:https://cloud.google.com/solutions/architecture/streampro
cessing. [Accessed 15 05 2016].

[12] [Online]. Available: https://internetofthings.ibmcloud.com. [Accessed 28 04


2016].

[13] [Online].Available:http://www10.mcadcafe.com/blogs/jeffrowe/2015/05/14/
ptc-thingworx-converges-on-iot/. [Accessed 20 04 2016].

[14] [Online]. Available: http://community.thingspeak.com/2014/05/connecting-


electric-imp-to-thingspeak-iot-data-services/ . [Accessed 21 04 2016].

[15] [Online]. Available: https://www.linkedin.com/pulse/microsoft-azure-iot-


complete-cloud-platform-your-modern-pvt-ltd-. [Accessed 10 05 2016].

[16] C. Qu, "Development trend and Prospect of the Internet of Things


information construction," 2009.

[17] [Online].Available:http://www.rs-
online.com/designspark/electronics/knowledge-item/eleven-internet-of-
things-iot-protocols-you-need-to-know-about. [Accessed 20 05 2016].

[18] [Online]. Available: http://www.codeproject.com/Articles/833234/Internet-


of-things-Overview. [Accessed 28 02 2016].

[19] [Online]. Available: http://postscapes.com/internet-of-things-protocols .


[Accessed 22 04 2016].

[20] R. Stefanov. (2013), "Security and trust in IoT/M2M – Cloud based


platform," Aalborg University.

[21] I. T. Union. (2005), " The Internet of Things. Executive Summary," ITU
Internet Reports , Geneva.

[22] [Online].Available:https://www.ida.gov.sg/~/media/Files/Infocomm%20Lan

78
dscape/Technology/TechnologyRoadmap/InternetOfThings.pdf. [Accessed
20 04 2016].

[23] [Online]. Available: https://opentechdiary.wordpress.com/tag/internet-of-


things/. [Accessed 26 02 2016].

[24] S. KALYONCU. (2013), "Wireless Solutions and Authentication


Mechanisms for Contiki Based Internet of Things Networks,".

[25] A.-Q. A.S. and e. al. (December 2015), "inter. Journal of Engineering
Research and Applications", vol. 05.

[26] [Online]. Available: http://www.ecnmag.com/article/2012/11/machine-


machine-communications-%E2%80%93-facebook-smart-devices .
[Accessed 01 05 2016].

[27] ITU. (2014), "ITU-T Focus Group on M2M Service Layer: M2M service
layer: APIs and protocols overview".

[28] [Online].Available:http://dspace.howest.be/bitstream/10046/1184/1/LanderA
rnoys.pdf. [Accessed 02 06 2016].

[29] E. Asma, R. Steinke and T. Magedanz. (2016), "AdM2M: Adaptable


Machine-to-Machine Transport Framework," Technical University Berlin,
Berlin.

[30] [Online].Available:http://tec.gov.in/pdf/Studypaper/White%20Paper%20on
%20Machine-to-Machine%20(M2M)Communication.pdf. [Accessed 20 05
2016].

[31] [Online]. Available: http://nerduino.blogspot.com/2013/04/o-que-e-


pwm.html. [Accessed 18 05 2016].

[32] [Online].Available:http:
//internetofthingsagenda.techtarget.com/definition/gateway. [Accessed 08 07

79
2016].

[33] [Online]. Available: http://www.ecnmag.com/article/2012/11/machine-


machine-communications-%E2%80%93-facebook-smart-devices. [Accessed
01 05 2016].

[34] [Online]. Available: https://www.techopedia.com/definition/29019/cloud-


server. [Accessed 08 07 2016].

[35] [Online].Available: https://www.techopedia.com/definition/30340/mongodb.


[Accessed 08 07 2016].

[36] [Online]. Available: https://github.com/mqtt/mqtt.github.io/wiki/Mosquitto-


Message-Broker. [Accessed 9 07 2016].

[37] [Online]. Available: https://www.e-education.psu.edu/geog865/node/261.


[Accessed 08 07 2016].

[38] [Online].Available:http://www.learningaboutelectronics.com/Articles/Ardui
no-motion-sensor-light-circuit.php. [Accessed 20 05 2016].

80
Appendix A: Arduino code for the Second Floor
#include <SoftwareSerial.h>

#include <pt.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

static struct pt pt1,pt2,pt3;

boolean condition=false;

const int inputPin = 2;

const int led = 13;

char check_data = 0;

bool Motion_Detect = false;

int value;

int k;

void setup() {

pinMode(led, OUTPUT);

digitalWrite(led, LOW);

// put your setup code here, to run once:

Serial.begin(9600);

Serial.println("Start");

BTSerial.begin(38400);

PT_INIT(&pt1); // initialise the two

PT_INIT(&pt2);

PT_INIT(&pt3);

81
void SensorMotion(void);

void action();

void loop() {

// put your main code here, to run repeatedly:

protothread2(&pt2, 1000);

protothread1(&pt1, 1000);

protothread3(&pt3, 1000);

// SensorMotion();

int protothread1(struct pt *pt, int interval) {

static unsigned long timestamp = 0;

PT_BEGIN(pt);

while(1) {

PT_WAIT_UNTIL(pt, millis() - timestamp > interval );

timestamp = millis(); // take a new timestamp

getDataFromSensor();

PT_END(pt);

int protothread2(struct pt *pt, int interval) {

static unsigned long timestamp = 0;

PT_BEGIN(pt);

while(1) {

82
PT_WAIT_UNTIL(pt, millis() - timestamp > interval );

timestamp = millis();

act();

PT_END(pt);

int protothread3(struct pt *pt, int interval) {

static unsigned long timestamp = 0;

PT_BEGIN(pt);

while(1) {

PT_WAIT_UNTIL(pt, millis() - timestamp > interval );

timestamp = millis();

action();

PT_END(pt);

void getDataFromSensor()

{ int value = digitalRead(inputPin);

if (value == 1)

k=15;

83
void act()

if(k>0)

Serial.println("1");

BTSerial.print("1");

digitalWrite(led, HIGH);

--k;

else

BTSerial.print("0");

Serial.println("0");

digitalWrite(led, LOW);

void action()

String ch= BTSerial.readString();

Serial.println(ch);

if (ch=="ON"){

if (k<5) {

k = 5;

84
}

85

You might also like