diva portal945110/fulltext01.pdfconnectingarduinosensorstosensiblethings xiaoguan 2016-06-06...

49
Självständigt arbete på grundnivå Independent degree project - first cycle Datateknik Computer Engineering Connecting Arduino Sensors to SensibleThings Xiao Guan

Upload: others

Post on 16-Mar-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Självständigt arbete på grundnivå

Independent degree project - first cycle

DatateknikComputer Engineering

Connecting Arduino Sensors to SensibleThings

Xiao Guan

Page 2: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

MID SWEDEN UNIVERSITYDepartment of Information and Communication Systems (IKS)

Examiner: Ulf Jennehag, [email protected]: Forsström Stefan, [email protected]: Xiao Guan, [email protected] field of study: Computer EngineeringSemester, year: Spring, 2016

ii

Page 3: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

AbstractThe Internet of Things is going to bring the Internet into every objectsaround us. To enable this ambitious idea, tiny devices have to be con-nected within the global Internet. Such devices are extreme small so it’sbecoming a challenge to connect it to the Internet via TCP/IP. The thesispresents away of connectingmicrocontrollerswith other devices to jointlyform a distributed network.

The thesis investigates and takes advantage of Internet of Things plat-form to implement the connection. SensibleThings is used as the plat-form. Limited by the hardware, microcontroller can’t run such a bloatedplatform. The thesis investigates different microcontrollers characteris-tics and chooses Arduino as a representative in the work. Then it real-izes a bridge connection between Arduino and SensibleThings. Arduinois connected with a single-board computer, Raspberry Pi by a USB cable.SensibleThings is running on Raspberry Pi to process the network mes-sages. The channel throughput, latency and general usability are mea-sured and interoperated. As a result, the data indicates this is a promis-ing, flexible, cost effective network topology. Microcontroller can join adistributed network by the bridge. Comparing to dedicate hardware so-lution, the bridge connection cuts down the implementation difficultiesand cost. The thesis also covers possible problems in such connection andproposes future work.

Keywords: Internet of Things, SensibleThings, Arduino, Microcontroller,Singleboard Computer, Serial Communication, USB

iii

Page 4: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Table of ContentsAbstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii

Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1 Background and Problem Motivation . . . . . . . . . . . . . 11.2 Overall Aim . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Concrete and Verifiable Goals . . . . . . . . . . . . . . . . . . 31.4 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.5 Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.1 Internet of Things . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Internet of Things Platform . . . . . . . . . . . . . . . . . . . 52.3 Single-board Computer . . . . . . . . . . . . . . . . . . . . . 72.4 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.4.1 Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.5 Serial Communication Methods . . . . . . . . . . . . . . . . . 92.6 Communication Port (COM) . . . . . . . . . . . . . . . . . . 102.7 USB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.8 Arduino Serial Communication . . . . . . . . . . . . . . . . . 11

2.8.1 Virtual Serial Communication over USB . . . . . . . . 112.8.2 Arduino UNO’s Serial Communication over USB . . . 112.8.3 GPIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.9 Serial Communication Protocol . . . . . . . . . . . . . . . . . 122.10Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.10.1Arduino Service Interface Protocol . . . . . . . . . . . 122.10.2 XBee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.1 Learn Internet of Things . . . . . . . . . . . . . . . . . . . . . 133.2 Choose Devices . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3 Investigate Connection Methods . . . . . . . . . . . . . . . . 133.4 Implement Connection . . . . . . . . . . . . . . . . . . . . . . 143.5 Evaluate Results . . . . . . . . . . . . . . . . . . . . . . . . . . 14

4 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.1 Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.1.1 Computer . . . . . . . . . . . . . . . . . . . . . . . . . . 174.1.2 Single-board Computer . . . . . . . . . . . . . . . . . . 174.1.3 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . 18

4.2 Internet of Things Platform . . . . . . . . . . . . . . . . . . . 19

iv

Page 5: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

4.2.1 ThingWorx . . . . . . . . . . . . . . . . . . . . . . . . . 194.2.2 Xively . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.2.3 SensibleThings . . . . . . . . . . . . . . . . . . . . . . . 19

4.3 Arduino Serial Communication . . . . . . . . . . . . . . . . . 204.3.1 Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.3.2 Deployment . . . . . . . . . . . . . . . . . . . . . . . . 22

4.4 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.4.1 Direct Connection . . . . . . . . . . . . . . . . . . . . . 224.4.2 Bridge in SensibleThings . . . . . . . . . . . . . . . . . 23

4.5 Sample Application . . . . . . . . . . . . . . . . . . . . . . . . 24

5 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265.1 Direct Connection . . . . . . . . . . . . . . . . . . . . . . . . . 26

5.1.1 Throughput . . . . . . . . . . . . . . . . . . . . . . . . . 265.1.2 Latency . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

5.2 Bridge Connection . . . . . . . . . . . . . . . . . . . . . . . . 285.2.1 Throughput . . . . . . . . . . . . . . . . . . . . . . . . . 285.2.2 Latency . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

5.3 Sample Application . . . . . . . . . . . . . . . . . . . . . . . . 31

6 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336.1 Ethical Consideration . . . . . . . . . . . . . . . . . . . . . . . 336.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

A Documentation of Code . . . . . . . . . . . . . . . . . . . . . . . 37

B Detailed Test Environment . . . . . . . . . . . . . . . . . . . . . 38

C Complementary Result Figures . . . . . . . . . . . . . . . . . . . 40

v

Page 6: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

TerminologyADC Analog-to-Digital Converter

ASIP Arduino Service Interface Protocol

COM Communication Port

DHT Distributed Hash Table

FTDI Future Technology Devices International

EEPROM Electrically Erasable Programmable Read-Only Memory

GPIO General Purpose Input/Output

GC Garbage Collection

HTTP HyperText Transfer Protocol

IoT Internet of Things

IP Internet Protocol

ISDN Integrated Services for Digital Network

JVM Java Virtual Machine

MIDI Musical Instrument Digital Interface

MIPS Millions of Instructions Per Second

OSI Open Systems Interconnection

PWM Pulse Width Modulcation

RFID Radio-Frequency IDentification

RUDP Reliable User Datagram Protocol

SRAM Static Random-Access Memory

SPI Serial Peripheral Interface

TCP Transmission Control Protocol

TTL Transistor-Transistor Logic

UART Universal Asynchronous Receiver/Transmi er

UCI Universal Context Identifiers

URL Uniform Resource Locator

USB Universal Serial Bus

XBee ZigBee and IEEE 802.15.4 Radio Modules by Digi, Inc.

vi

Page 7: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

1 IntroductionThe Internet of Things (IoT) is the vision of connecting a network of manydifferent physical objects to evolve a information society and enable moreadvanced services around people [1]. The term ”Internet of Things” it-self is used as an umbrella keyword to cover complicated nature amongembedded systems, wireless communication and Internet [2]. Currently,people around the world rely on the Internet for emails, surfing on theWorldWideWeb, realtime communication, E-commerce, social networksand many other tasks. The vision of IoT is a step forward to enable evensmall objects to be connected in the Internet to further enrich our source ofinformation and perform various kinds of tasks. It’s foreseeable to havean Internet with such networks of objects as well as traditional Internetworking together within the next decade. These networks of objects arebuilt upon actuators, sensors, mobile phones, Radio-Frequency IDentifi-cation (RFID) tags and other objects [2–5].

IoT promises a new world by bringing contents and services close to us,emerging new interaction experiences and paving new applications. De-spite the IoT future images, it has to overcome numerous technical chal-lenges and ethical issues. Since IoT is a vague concept, the regulations, ac-tual deployed devices, technical difficulties and mitigations may divergedevelopment during the IoT revolution. Generally, the challenges cometo security, performance, distributed network, privacy, interoperability,legal problems and prices [6, 7]. Along with the difficulties, devices likesmart phones, smart watches, activity tracker 1 and other intellectual de-velopment boards is becoming smaller and smallerwhich leads to a harderimplementation difficulty while keeping the same level of functionality,privacy and security comparing to high performance devices.

1.1 Background and Problem Motivation

Within just few decades, laptop, smart phones, smart watches are becom-ing main stream. It’s evidently people want more and more smaller elec-tronic products [8]. This trend also applies to the development of IoT.

Since this kind of small devices are becoming more and more popular,there is the need to communicate with other devices, otherwise it’s use-less because one sensor can’t do much in a complicated system. The mostpowerful functionality always adds up to a conclusive complete servicewhich can be the final product selling by a company. In order to achievebuilding the IoT service, it’s obviously a necessity for a network solution toconnect all components together. The network solution is however basedon the existing technology. On the one hand, the components have to bephysically connected. The connection can be done either by a cable or

1A life saving occasion because of a Fitbit activity tracker. h p://tinyurl.com/zgoel9n

1

Page 8: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

wireless communication. Many components can be connected by differ-ent technologies as long as it provides their functionality.

These complicated configuration of network is hard to manage for a soft-ware developer. Thus the research has so far produced IoT platform asa cornerstone for sharing information and managing the network. Theseplatforms define the rules and construct away to connect different compo-nents based on the rules. The platforms can run onmany different devicessuch as smart phones, single board computers and desktop computers.Moreover, the platform can provide existing functions as API for otherdevelopers to build new applications.

However, small devices are harder to be connectedwithin an IoT networkeven with the help of an IoT platform. This kind of devices are called em-bedded devices sometimes since they have a dedicate purpose, limitedfunctionalities and even a limited power source. Therefore, they only of-fer limited computation power rather than general purpose desktop com-puters. For this reason, the chance of these devices not having enoughabilities to perform well with IoT platforms is high.

1.2 Overall Aim

Internet of Things is an ambitious vision to connect physical objects to ex-isting Internet. However, new devices are becoming smaller and smaller.On one hand, customers want smaller devices so they can bring them inthe pocket. On the other hand, more devices are installed in a limited en-vironment, for example, in the factories. Space and energy constrains onthe size of devices. They may have to use a ba ery and wireless commu-nication based on the fact that sites don’t have space for cables.

These constraints promote a harder implementation difficulties. Desktopcomputers give many more opportunities to application developers be-cause of rapid involving computation power. The same trend also appliesto smart phones. In a form of sense, we want IoT devices to be able to per-form the same level functionalities as more powerful devices. With thelimitation of size, a complex feature may be divided into different devicesin reality. The devices can be connected within a distributed network. Incoordinationwith an IoT platform, they can perform their own functional-ity together to achieve such a complex feature, even they are connected bywireless and used ba ery as the power source. Nevertheless, distributednetwork is hard to control by applications as well as higher implementa-tion cost. IoT platform is used in such case to help building a distributednetwork with lots of different devices and provide basic application pro-graming interfaces.

Although exists IoT platform, it’s still hard to connect a lightweight devicewithin a distributed network. An IoT platform may be built upon inter-faces the operation system provides. As a ma er of fact, a lightweight

2

Page 9: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

device may not be able to run a operation system at all. In the otherway, these sensors and actuators have to be connected in a IoT networkto perform functions which requires them communicate with each oth-ers. As a conclusion, the IoT platform needs to make communicating withlightweight devices possible.

Therefore, the problem Iwill solve in this thesis is to connect a lightweightcomputer to the Internet of Things network by an IoT platform as well asevaluation about how the system performs together.

1.3 Concrete and Verifiable Goals

More specifically, the concrete and verifiable goals of the project are:

1. Reading three papers about what is Internet of Things and choosingan IoT platform in this thesis as well as three papers for each IoTplatform.

2. Choosing a lightweight computer and reading five articles about it.

3. Finding two different methods to connect the device with the IoTplatform.

4. Implementing one of these methods to verify the possibilities forconnecting small devices with an IoT platform.

5. Evaluate how well the system performs in terms of throughput andlatency as well as general usability.

1.4 Scope

There are thousands of different lightweight devices in the market basedon their distinct use cases. There are also hundreds of Internet of Thingsplatforms based on different principles. Diversities contributes the de-velopment of IoT, but it also takes time to experiment with each. There-fore, because of the limited time, I will choose one lightweight device andone IoT platform. And the thesis are mostly focusing on connecting thislightweight device with one particular IoT platform. The majority focusis to realize and evaluate the connection. Thus the comparison within de-vices and platforms are moderate. The communication protocol withinthe devices are meant to demonstrate instead of many premium features.And the evaluation only concerns the throughput in terms of the num-ber of messages as well as latency. A working application, reliable datatransportation and quality of service are beyond the scope of the thesis.

1.5 Outline

Chapter 1 gives an introduction about the Internet of Things and prob-lems which will be solved in the thesis. Goals and scopes are defined in

3

Page 10: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

this chapter. Chapter 2 introduces related theories used in following chap-ters. Chapter 3 describes how I research the theories and how I implementthe connection method. Chapter 4 details the steps of implementation aswell as justified decisions along the development. Chapter 5 demonstratesevaluation results and a technical review to the methods. Chapter 6 sum-marizes the thesis and proposes future work.

4

Page 11: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

2 TheoryThe thesis aims to brining small computer to Internet of Things platform.Naturally, it covers a huge area of field. The major part will focus on thenetwork protocol, hardware and relevant considerations in a scope of cho-sen devices.

2.1 Internet of Things

Internet of Things is to build a interconnect network for every ordinalobjects instead of devices using Ethernet, such as popular widespreadPersonal Computer (PC). Those physical objects can be devices, vehicles,buildings, electronics, websites and sensors. IoT enables those objects tocollect and exchange data, either by wired connection or wireless connec-tion.

IoT objects are used to assist human by monitoring, operating and inter-acting objects which the human is not very good at. Although, they arebuilt around the human experience. Therefore, small objects have to beconnected wireless for convenience and environment.

Another fact is IoT is built upon Internet infrastructure. Internet connectsdifferent sizes of network into a open global network experience. It al-ready comes into major part of world and becoming the cornerstone. In-ternet is mostly encompassed with TCP/IP protocol suites in which oper-ates on different levels of OSI model.

OSI defines 7 levels to abstract communication functions. The first layer,Physical layer is responsible for transmission raw bitstreams over a phys-ical medium. For example, Ethernet, ISDN and RS-232. The second layer,data link layers helps transmission of data frames across two identitiesconnected by a kind of physical layer. The third layer, Network layer,offers abilities to manage and connect to a multi-node network. IPv4, isone of important protocol si ing upon Network layer. It’s de facto stan-dard for Internet. IPv4 becomes a standard around 1980 and provides 4.3billion addresses approximately. Only twenties years later, due to rapidexpansion of Internet, IPv4 address is basically exhausted. NAT andCIDRwere introduced to ease the intense trend. For that ma er, IPv6 was regu-lated to offer next generation protocol for Network Layer. It has 3.4×1038

addresses. For enabling IoT, IPv6 has to be widespread. In fact, as of 2016,IPv6 nodes are slowly increased due to the price and many other reasons.

2.2 Internet of Things Platform

Internet of Things Platform is ambiguous as IoT itself is not a standard.Nor does different kinds of hardwares and softwares reach an consensusof implementation. Internet of Things Platform can also be called Internet

5

Page 12: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

of Things Framework.

[9] would argue Internet of Things Platform may be referred as a systembuilt on specific hardware and software components. The platform offerscloud ability, deployment, maintenance and network structure. While In-ternet of Things middleware provides network services for the devices toenable common functions of IoT network. In the thesis, Internet of ThingsPlatform are aligned with Internet of Things middleware in terms of thatpaper.

Internet of Things Platform helps the application connecting and manag-ing devices, reading and monitoring devices and even offering controlsover network. With the platform, developers can build an distributed ap-plication across a variety of environments.

It can be an open source software running in different devices. Those de-vices works in conjunction with each other to regulate a distributed net-work upon existing network infrastructure. Many cloud companies alsopromotes a cloud core for those platform, such as AWS IoT, Google CloudPlatform and Azure IoT. Thus a core backend service can achieve withouta strong endpoint. On the other hand, many

The other kind of platform can be based on a local LAN network, such asApple’s HomeKit.

Many different protocols comes about to exchange the data. For exam-ple, XMPP is an open protocol and scales very well. REST can be usedto present resources based on HTTP for web servers. MQTT builds apublish-subscribe mechanism to decouple the devices for bidirectionalcommunication between the object and brokers.

By all means, being into Internet, one have to access a Internet ServiceProvider or becoming one of them. Some applications can be restricted ina local area network (LAN). The application can also sends out the dataoutside LAN to interchange the message. With proper encryption andnetwork infrastructure, the messages can also be transmi ed securely.

Internet relies on TCP/IP stacks to route the packets from the source tothe destination. WorldWideWeb is consumed by millions daily. It’s con-structed byweb resources andURLs. URLswill need to be translated backto the IP addressed so the client can initial the request. This is achieve bythe Domain Name System. In a typical case, the web browser as a clientwill uses the IP address to initial the request by HTTP.

The mission of Internet of Things platform will be creating a fundamen-tal instruction to allow exchanging message over Internet or in the LAN.Given the complexity of different setup, the size of the nodes and proper-ties of network traffic, the complexity can be novel.

6

Page 13: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

2.3 Single-board Computer

ASingle-board computer is a computer built on a small circuit board, withmicroprocessors, memory, input/output and other features. It’s smallerthan a computer, even with less computing power, but essentially it’s acomputer of its kind.

2.4 Microcontroller

A microcontroller is usually a small computer with a single core proces-sor, memory, and IO ports. Memory space are often integrated in the chip.Such a small computer is used by embedded applications. Apart fromgeneral computers with many different kinds of chips for multiple func-tionality, it’s designed and programable with embedded application forone solely purpose.

With this embedded context, it has limited resources. For memory Evenso, it can’t run a operating system.

Microcontrollers are used in automatically controlled products and de-vices, such as automobile engine control systems, implantablemedical de-vices, remote controls, office machines, appliances, power tools, toys andother embedded systems. By reducing the size and cost compared to a de-sign that uses a separate microprocessor, memory, and input/output de-vices, microcontrollers make it economical to digitally control even moredevices and processes. Mixed signal microcontrollers are common, inte-grating analog components needed to control non-digital electronic sys-tems.

Some microcontrollers may use four-bit words and operate at clock ratefrequencies as low as 4 kHz, for low power consumption (single-digitmilliwa s or microwa s). They will generally have the ability to retainfunctionality while waiting for an event such as a bu on press or otherinterrupt; power consumption while sleeping (CPU clock and most pe-ripherals off) may be just nanowa s, making many of them well suitedfor long lasting ba ery applications. Other microcontrollers may serveperformance-critical roles, where they may need to act more like a digitalsignal processor (DSP), with higher clock speeds and power consumption.

2.4.1 Arduino

Arduino is a so called open source prototyping platform based on a mi-croprocessor development boards. Unlikely the general purpose devicessuch as a home computer and smart phones, it doesn’t providemuch com-putation power, dedicated user interfaces and softwares. Instead, Ar-duino only has a Atmel 8-bit AVR micro-controller, several digital andanalog pins for physical components and a provision to download andrun user applications based on serial port. A typical Arduino board onlyoffers 2 KB SRAM, 1KB EEPROM, 32 KB flash memory which made it

7

Page 14: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

incredibly hard to provide rich services to IoT network. Nevertheless, Ar-duino is quite popular among global communities of makers, especiallymany researches such as Mechanical Engineering. Inexpensive (less than50 dollars), easy to program and the highly extensible Arduino kit con-tributes its prestige.

Arduino UNO is shown as Figure 2.1, only some parts of it are interestedin the thesis.

Figure 2.1: An Arduino UNO board1

Firstly, 14 digital pins are highlighted in red. Those pins can be either in-put or output according to program controls. The special PWM is PulseWidth Modulation. Some of digital pins can use this on-off pa ern tosimulate analog output. 0 and 1 is used as transmit/receive pins of USB.Secondly, power pins are highlighted in purple. It’s used for providingpower source for external breadboard and ground. Thirdly, analog pinsare highlighted in blue. Those pins accepts analog signals. Later, an 10-bit analog-to-digital converter is used to interprets the result which hasa resolution of 4.9mV for 5V power supply. Fourthly, ATmega328p ishighlighted in orange. It’s the core of Arduino board and also the micro-controller. It’s produced by Atmel and uses AVR. At 20MHz, it can yield20 MIPS throughput. 2KB SRAM, 32KB flash memory and 1KB EEPROMis included [10]. Fifthly, Atmega16U2 with TX/RX LED is highlighted ingreen. The chip is another slightly less powerful AVR micro-controller.It’s programed and used to support serial communication over USB. It’sbasically works as a universal asynchronous receiver/transmi er (UART).

1This figure is modified based on a photo uploaded to Wikimediai as CC 2.0.

ihttps://commons.wikimedia.org/wiki/File:Arduino_UNO_unpacked.jpg

8

Page 15: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Two LEDs are useful for ge ing an clue of transmission. Lastly, USB portis highlight in brown. With USB cable connected, no power supply isneeded.

for sharing sensor and actuator information on the Internet, most notablythe SensibleThings platform. The SensibleThings platform can run onmany different devices such as smartphones, Raspberry Pi devices, anddesktop computers. However, SensibleThings is far from the only IoTplatform on the market [6][11].

The goal of this project is to enable Arduino devices to connect to Sensi-bleThings. The Arduino is however too weak to actually be a part of theSensibleThings DHT, hence some type of device need to act as a gateway.Preferably a Raspberry Pi could act as this device, but a normal desktopcomputer might also suffice. Hence, this thesis will investigate what is thebest way to connect Arduino sensors to the IoT. In detail the evaluationshould also determine how well the platforms handles the Arduino sen-sor devices, in terms of scalability, response times, and overall quality ofexperience.

2.5 Serial Communication Methods

Serial Communication is one of the most important connection methodfor computers. It sends data at a per bit basis instead of sending severalbits as parallel communication. At a glance, serial seems losing big onthroughput over parallel. In practice, serial often outperforms parallel bymuch higher clock rate. That owes to cheaper implementation and lesselectrical problem.

There are two kinds of serial communication, one is synchronous, theother is asynchronous. Synchronous may be easier since it requires sameclock rate. The “data is sent in a continuous stream at a constant rate.”[12] Being time, the clock will drifts. So resynchronization is required.Asynchronous might be another communication methods which requiresthe start and stop signal for synchronization. Before signaling, the cor-respondents have to agree several signaling parameters. They are full orhalf-duplex operation, the number of bits per character, endianness, bitsper seconds, parity (none, odd or even), the number of stop bits, mark andspace symbols.

Comparing to parallel communication, crosstalk happened less. Clockskew can bemitigated by un-clocked asynchronous serial communicationlinks.

Manywell-knownapplication adopts serial communication including sys-tem bus, peripheral devices connection and peripheral bus, such as PS/2,USB, Ethernet, ISDN, Serial ATA, PCI Express and SPI.

9

Page 16: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Serial communications requires physical instruments. That includes dif-ferent kinds of cables, scaling from jump circuits to complicated twisted-pair cable. Cable is strictly related with its protocol or bus design.

Baud rate is also called symbol rate. It’s the number of symbol changes,waveform changes, or signaling events, across transmission medium pertime unit. It’s measured by symbols per second.

2.6 Communication Port (COM)

COM is the original interface on IBM PC-compatible computers. Severalyears goes by, physical COM ports are long gone on PC. But it appears onUnix like system as a virtual ports. That includes ports for Bluetooth andUSB-to-serial devices.

A COM port redirector is a software designed for creating such virtualport. It provides remote serial access. In Unix like system, they may ref-erenced as a y port redirector.

2.7 USB

USB represents Universal Serial Bus, is an standard to connect peripheraldevices by defining cables, connectors and communication protocols usedin a bus for connection, communication and power supply between com-puters and electronic devices.

It’s designed to uniform the connection within various kinds of computerperipherals, including keyboards, printers, external disks and portabledevices. In practice, USB replaces old interfaces, such as parallel portsand RS-232 serial port.

USB consists of a host and a tiered-star topology. In the tree, a USB hubscan be used to connect more devices into single USB port. USB allowsbranching into a tree structure with up to five tier levels, 127 devices intotal. Devices are linked though hubs. The hub built into the host con-troller is the root hub.

A physical USB device may consists of several logical sub-devices calleddevice functions. A device with many functions is called composite de-vice. The alternative is called compound device. The host assigns theaddress to each logical device.

USB device communication builds upon logical channels called pipes. Adevice can have 32 pipes (16 IN, 16 OUT). Stream and message are twotypes of pipe. A message pipe is used to transmit control which sends/getshort commands and responses. It’s bi-directional. A stream pipe is a uni-directional. It’s used to transmit data using isochronous, interrupt andbulk transfers. Isochronous transfers often guarantees a data rate but with

10

Page 17: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

possible data loss. Interrupt transfers is used for ge ing quick responses,i.e. keyboards. Bulk transfers uses all available bandwidth without band-width or latency guarantees [13].

2.8 Arduino Serial Communication

Arduino itself doesn’t have enough computation capability to run an op-erating system or a complete network stack. Thus it either pushed thework to other a ached device called Arduino Shield or it simply connectsby a serial communication.

2.8.1 Virtual Serial Communication over USB

Based on the onboard converter chip, it’s easier for any hosts to talkwithinthat serial port. Thus a application protocol is feasible to achieve taskswith Arduino. By connecting IoT platform within hosts, those host willbecome the bridge towards Arduino.

There are many ways to communicate with serial port on a operating sys-tem. For this thesis, it bases on RXTXwhich available on Java and a work-ing Unix like operating system.

2.8.2 Arduino UNO's Serial Communication over USB

Arduino UNO board has a ATmega16U2 chip acting as a bridge betweenthe computer’s USB port and the main processor’s serial port 2. It runsa software called firmware. By rewriting the firmware, Arudino devicescan appeared as MIDI devices defined by USB.

Figure 2.2: Virtual Serial Communication over USB

Since personal computer or Single-board computer don’t have a serial portat all. Theywill emulate a virtual serial port by usingUSB cable. This pieceof software reuses the TCP/IP on the host machine. On Arduino side, thatATmega16U2 was programmed to be a USB-to-serial converter.

2h ps://www.arduino.cc/en/Hacking/DFUProgramming8U2

11

Page 18: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

A complete breakdown of USB cable connection is shown as Figure 2.2.

2.8.3 GPIO

A General Purpose Input/output (GPIO) is a generic pin on the microcon-trollers to allow programs to control its input and output behavior. Rasp-berry Pi and Arduino both have GPIO.

2.9 Serial Communication Protocol

Data link and hardware is clearly defined. But it doesn’t guarantee dataintegrity. Application may also needs a way to communicate in certainway. There are many existing protocol, like Firmata, Ardulink and ASIP.Firmata is based onMIDI but Ardulink and ASIP is defined as ASCII text.

2.10 Related Work

In here, the thesis presents some related work as the references.

2.10.1 Arduino Service Interface Protocol

The ASIP (Arduino Service Interface Protocol) is an software abstractions toexpose small hardware components, such as sensors by micro-controlleras services in order to achieve hardware agnostics protocol and reusingsource code [14]. Further, it investigates the networking support by dif-ferent strategies [15].

2.10.2 XBee

XBee is an coin sized modules to enable ZigBee network protocols. Itsupports a large quantitive devices, including Arduino and Raspberry Pi.An environmental monitoring project uses this modules to achieve an ad-vanced mesh networks [11].

12

Page 19: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

3 MethodologyI will do my thesis work in Mid Sweden University. Students and pro-fessors at Mid Sweden University conduct many researches in Internet ofThings as well as IoT platforms. I can ask and get support from them forthis thesis. More specific, I also make use of following methodology towork on this thesis.

3.1 Learn Internet of Things

Firstly, goal 1 is to get preliminary knowledge about Internet of Thingswhich helps further investigation and decision towards choosing an IoTplatform. Internet of Things, however, is a vague term used to cover theuniversal research. In order to orient direction of this thesis work, I willstart the survey in the beginning. Iwill searchGoogle Scholar for ”Internetof Things” to find out several most cited papers. After skipping throughdifferent survey papers, I can dig into their references in university libraryabout most interesting parts related to my thesis. In the end, I will limitmywork in one IoT platform. Then I will read papers and documentationabout the platform to understand the big picturewhich is helpful jumpingaround the code.

3.2 Choose Devices

Secondly, goal 2 is to choose device and to understand its underlying de-sign. They are not strictly only presented in papers. However, becausesmall development boards are meant to be sold in public, I will searchGoogle for online news posts about development boards, especially inGizmodo and SitePoint based on the fact that they are focused in this area.After comparison, I will choose one device for further investigation. Inparticular, official websites, tutorials, books, papers and other sources ofinformation will be collected and studied in which they are public avail-able online most cases.

3.3 Investigate Connection Methods

Thirdly, goal 3 is to investigate how to connect the device with the IoTplatform. I will read the source code of IoT platform if available. Thenwriting sample applications helps understanding how it works. On theother hand, the device needs a careful examination. Physical componentsmay be quite limited and many background electronic knowledge is re-quired. The development boards are often sold by a company. Therefore,companies provide tutorials, libraries, sample applications and documen-tation. I will read the introduction and tutorials to knowwhat the device itis. After I made a decision to devices for thesis, I will continue to look intosample applications and documentation to understand how to program

13

Page 20: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

in this development board. In the end, I will build naive communicationbetween the device and the IoT platform in order to get more knowledgeabout different communication methods and evaluation aspects.

3.4 Implement Connection

Fourthly, goal 4 is to connect the device with IoT platform. In this step,I’ll read publications about IoT platforms. If it’s open source framework,I’ll read its code to see how it works. Related algorithm and papers willalso be read. Later, I’ll look into the protocol and connection mechanismof this IoT platform. I will write example code to test the connection andunderstand its characteristics. In the end, I’ll look into how the bridgedevices can proxy the connection for small devices in IoT platform. I’lldraw topology and flow chart to understand how it works. Some moresamples will be wri en to grasp the structure.

3.5 Evaluate Results

Lastly, goal 5 is to evaluate results in terms of performance and stability.They are evaluated as throughput and latency. The throughput and la-tency both shows connection performance. While standard deviation andparameters are the metric to address stability. The throughput is mea-sured by the number of messages exchanged. The latency is measured bythe round-trip time. It’s a continuation to implementation. I’ll populate aflow chart to initiate, test chosen characteristics. The data is collected andplo ed so that it can be easily understand. I will compare collected met-rics. Also, an sample application will be formulated to test how this canwork in production. Then I can describe the overall experience, quantitiveresults.

14

Page 21: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

4 ImplementationInternet of Things got the a ention from all technical communities sincethe concept is brought up. It’s been a wide field for a long time. As aresult of limited time, the thesis focuses on implementing one connectionmethod to an IoT platform.

The software has to be build upon a specific hardware or a hardware archi-tecture. In a sense of IoT, the software design have to consider the networkarchitecture. Anticipating features and performance requirements. Thosecharacteristics and demands are further used to build software abstrac-tions and layers. Many solutions are emerging along the IoT evolution,including IoT platforms. The underlying obstacle is that IoT devices canbe small as fingernail. The size constraints the computation power as wellas hardware features. Or it’s ba ery powered and even passible so that itcould be fairly hard to sense those devices. And hardwares in real worldapplication may scales up to a data center. All those hardwares shouldbe able to communicate with each other to form a distributed network toenable IoT. On the other hand, the framework development may restrictits features according to hardware features. Such trades-off and large dis-tributed computing environment is extremely hard to develop applicationupon. One of among is to connect a micro-controller with a full-stack Eth-ernet capable Internet of Things platform.

Figure 4.1: Logical Distributed Network for Internet of Things

This thesis follows a top-down approach. It investigates the vision of In-ternet of Things and how different hardwares can be structured by soft-

15

Page 22: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

ware, for example, Internet of Thing platforms. Then it follows a compar-ison survey of IoT platforms, in which examines the different approachestowards distributed network for small sensors. At last, the detail of micro-controller is derived and the connection is investigated. The logical struc-ture of thesis will achieve is shown as Figure 4.1.

Internet of Things intends to connect physical objects to the Internet sothat Internet can comes closer to people. Devices are becoming smallerand smaller. They also become smarter, especially the smart phone evo-lutionary. A number of public cloud services are developed to supportdifferent services. Though, IoT still has a long way to go. Devices canbe extremely small until fingernail size to be integrated with daily ob-jects. Thus researches want to achieve communication over the Internetsince it’s the most powerful and open network solution for connectivity.When low cost, high performance and low power consumption have tobe achieve at the same time, the implementation difficulties can be novel.

4.1 Devices

Given the huge amount of available devices, the thesis focuses on therepresentatives. Production devices might be compact in size and inte-gratedwith highly-customized chips which dramatically changes the per-formance and features of a board. Thus, the thesis is not considering dif-ferent kinds of add-ins. Their performance and usability may need tobe measured on its own. For example, Google accelerates their machinelearning algorithm with an custom chip in which the performance will bequite different than general purpose hardware. In a way, micro-controlleror single-board computer are designed and work in a special application.But the thesis is concerning general hardwares instead so the conclusioncan apply to special hardware. Therefore, those many devices are catego-rized into 3 categories, micro-controller, single-board computer and com-puter (Personal Computer or Workstation). Their hardware and softwarecapability is compared as Table 4.1 shown. Micro-controller and Single-board computer may be called embedded devices sometimes.

Table 4.1: Comparison of 3 Major Kinds of Digital Devices

Device Microcontroller Single-board ComputerPerformance Slow Average FastPower Low Middle HighOperating System No Yes YesCustomizability High Average LowBoard Design Vendor Vendor StandardPeripheral Size Tiny Small All sizeRepresentative Arduino Raspberry Pi PC

16

Page 23: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

4.1.1 Computer

Personal computer has widely accepted for two decades. In general, itcan be either a laptop or desktop computer, even a workstation. They aremuch more powerful than single-board computer in many senses. Lyingbetween of single-board computer and computer, it may has many moreemerging devices, such as smart phones and tablets. In the thesis, a Mac-Book Pro is used as the computer. The model is described in AppendixB.

4.1.2 Single-board Computer

Single-board computers can be small as credit card. But it’s also strongenough to run popular general-purpose operating system, for example,Linux. It may provides different kinds of peripheral port for communi-cation, especially HDMI, USB and Ethernet. Some of them may supportGPIO for direct sensor installation and usage. Additional computationpower, small size and peripheral ports made the single-board computermuch suitable for IoT development. Single-board computers can be help-ful to be the bridge or proxy device for micro-controller given the fact ithas enough computation functionality to run the operating system andEthernet protocol stacks. A software framework can be deployed to thedevices and push the messages to micro-controller accordingly. Then, themessage can be collected by the device and forward to the network. Micro-controller in this kind of bridge can either be transparent as sensors andactuators or be public as a node where it delegates all sorts of networkprotocol to the bridge.

There are many kinds of single-board computers. VoCore is a Ethernetport sized block single-board computerwhich runs Linux and features theWiFi connection1. Another kind of 15 US dollars single-board computer,Pine64 features the 64-bit microprocessor2.

Raspberry Pi is used as the single-board computer for the experimentalevaluation. Raspberry Pi is a series of single-board computers which be-comes popular among the hackers, scientists and engineers since 2012. Ithas a great community to ask questions and solutions to many problems.It’s no large than a credit card but provides many exciting functionali-ties. There are a variety of models available featured in different size ofRAM, ARM CPU, peripheral ports and even graphical chip. The thesisuses a Raspberry Pi Model B. It has an single core ARM11 microprocessorrunning at 700 MHz, 512 MB RAM, 2 USB 2.0 ports and Ethernet whichis powerful enough for this thesis. And its size is nether big to bring itaround nor small to operate. The model is described in Appendix B.

1http://vocore.io/store/index2http://pine64.com/

17

Page 24: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

4.1.3 Microcontroller

Micro-controller usually consists of central processing unit, volatile mem-ory, flash memory, clock generator and some input/out pins.

It’s low-level so every peripheral devices might need to be programmedcarefully. Additional hardware components are connected by digital oranalog pins. Some components may need more than 1 pin. Those hard-ware components are driven by the micro-controller directly. The soft-ware is also low-level. It may interactive with hardware interrupts orwrapped as input/output functions to the application. Without program-ming correctly or connecting devices by wrong parameters may result inunsuccessful setup or even destroy the device physically.

Micro-controller has extremely low power consumptions. Thanks to itslimited functionalities, the chip may be specified to the application. Forexample, motes, sensor nodes are widely adopted by wireless sensor net-work. MICA2 is one type of mote which features an embedded system,TinyOS and wireless communication. TMS1000 developed by Texas In-struments in 1974 for the electronics industries which features 256 bitsRAM and 1K bits of RAM. Though beyond the scope of the thesis, othercompanies may offer additional modules to provide extra features. Forexample, XBee board by Digi is only a coin size in which it supports Zig-Bee network protocol.

In the thesis, ArduinoUNOv3 board is used as themicro-controller. Beingreleased for many years and enjoyed by scientists, engineers and hackers.It is a widespread and enjoys a global community to share the knowl-edge. The community also grows with increase number of devices. Ar-duino boards typically uses a AVR micro-controller with different sets ofconfiguration. Each one of them is customizable and the hardware likesensors can be directly connected to pins or a breadboard. Libraries, pro-tocols and researches are built around the projects are huge. The size ofthe board is rather big comparing to other micro-controllers. However,it’s be er for prototype and research where hardware and software re-configuration is needed. It’s not either fast than other micro-controllerswith an AVR micro-controller at 16 MHz and 2 KB SRAM. Unlike pro-duction microcontrollers, Arduino can be power hungry as it’s not designfor production usage. Other production microcontrollers may have dif-ferent strategies to reduce power drain. But Arduino offers the neededfeatures and easier to debug thus it’s a representative example of micro-controllers. Thus the measurements taken in the thesis is comparable toanother micro-controllers.

Arduino has a number of devices now in which there is a popular modelcalled Arduino UNO. The current version of Arduino UNO is ver3. Itmight be called Genuino UNO outside the United States.

18

Page 25: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

4.2 Internet of Things Platform

Computers and single-board computer are capable of running an operat-ing system thus the requirement of TCP/IP protocols are guaranteed to besupported. While micro-controllers may not be supported depending ontheir chip design. In a real working scenario with many devices joiningthe distributed network, one device can be in charge of communicatingwith one ormoremicro-controllers. All incoming and outgoingmessages,other maintenance overhead, deployment and continuos monitoring canbe delegated to the single-board computer.

In this thesis, an IoT platform will be chosen to build such an networkbackbone for demonstration. But it will also compare some other solu-tions. IoT platforms or IoT frameworks can be characterized as cloud-based,web-based and fully-distributed. They can also be categorized basedon its license, proprietary or open-source. ThingWorx, Xively and Sinsi-bleThings are 3 IoT platforms to be examined.

4.2.1 ThingWorx

ThingWorx builds a platform including Machine-to-Machine (M2M) andapplication lifecycle management features. ThingWorx can be deployedon the cloud or embedded devices. ThingWorx offers visualized develop-ment environment and semantic data storage which features their modeldrivendevelopment. REST endpoints,MQTT,CoAP,WebSockets are sup-ported transportation mechanism [9, 16, 17].

4.2.2 Xively

Xively is a PaaS IoT solution with provided SDK. Wireless serial gatewaycan also join the network. Device communication is done by REST end-point but no deployment andmanagement tools are provided. MQTT andwebsockets are supported. [16–18]

4.2.3 SensibleThings

There are multiple IoT platforms to be chosen. For my purpose, I wouldchoose one can run upon small single-board computers in which it shouldhas ability to run a Unix like system.

SensibleThings is a fully distributed and open source IoT platform. Itdoesn’t have a single point of failure and all nodes are equal. The underly-ing DHT supports Kelips and Chord algorithms. The kelips will be used.All tests will be performed in a LAN environment. Actual communicationis implemented upon transport layer protocols. It supports TCP, RUDPand proxy. RUDP builds upon UDP protocol which features fragment,rate control and acknowledgment to provide reliability. Proxy is used toexploit NAT in the router which sometimes prevent the connection.

19

Page 26: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure 4.2: SensibleThings DHT

IoT platform usually offers communication abilities among different net-works across LAN and Internet. While micro-controller may not run anoperating system at all. Hence, it’s almost always connected with anotherdevices as backend which simply pushes communication among the net-work to this device. This pa ern will be called bridge.

By using a so called bridge, Raspberry Pi will run as a SensibleThingsnode. Arduino delegates all kinds of network requests to Raspberry Pi.Arduino itself can connect to Raspberry Pi in numerous ways. Arduinocan appear as transparent in the SensibleThings network by registeringits pins or hardware components as UCI. UCI is an arbitrary string storedacross the DHT represents a sensor or an actuators. Physical IP address isalso presents in the underlying dissemination core of SensibleThings. Butit’s transparent to the application scenario.

4.3 Arduino Serial Communication

In such a bridge, Arduino has to be connected with Raspberry Pi. Themost easy way is the serial communication. Serial communication over-comes many disadvantages of parallel communication to become main-stream. It’s cheaper and easier to control.

Arduino has adopts serial communication enabled by ATmega16U2 chipwhich creates the serial port virtually by USB cable. The jump circuits canbe used to connect 0/1 digital pins to GPIO in the Raspberry Pi which issimilar to the USB scenario. Other communication depends on Arduinoboard configuration. Or it’s extended by hardware modules, so called Ar-duino Shield. They can be directly connected to pins for Ethernet, Blue-tooth, ZigBee support. Serial communication over USB will be the tested

20

Page 27: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

communication technique.

Serial Communication is one of the most important connection methodfor computers. It sends data at a per bit basis instead of sending severalbits as parallel communication. At a glance, serial seems losing big onthroughput over parallel. In practice, serial often outperforms parallel bymuch higher clock rate. That owes to cheaper implementation and lesselectrical problem.

There are two kinds of serial communication, one is synchronous, theother is asynchronous. Synchronous may be easier since it requires sameclock rate. The “data is sent in a continuous stream at a constant rate.”[12]Being time, the clock will drifts. So resynchronization is required. Asyn-chronousmight be the alternative way to send the data. It consists of data,start bits and stop bits which doesn’t needs to be synchronized.

Arduino boards have at least one serial port (UART or USART). Digitalpins 0 and 1 are used as receiving and transmi ing port. The board hasa USB connector for the connection. Arduino Uno in particular has a At-mega16U2 programmed as aUSB-to-serial converter instead of FTDIUSB-to-serial driver chip on prior models. But the UART TTL (5V) serial com-munication is enabled by main chip, ATmega328 over digital pins 0 and1.

Using a USB cable on Arduino should have the best possible connectionperformance which can be used as a baseline reference. To enable UART,both ends have to programmed accordingly. Based on the characteristicsof UART, the sender and the receives needs to agree upon on Start, Parityand Stop bits. The transmission between two opponent can be full-duplex.

4.3.1 Protocol

UART represents physical layer towards data link layer in the OSI model.Since Arduino is low level, many protocols are developed to reduce theprograming difficulties, such as Firmata and ASIP.

In the thesis, Ardulink protocol will be used to build the communication.Ardulink protocol defines several commands as URL for clarity. It’s atext-based stream protocol.

Table 4.2: Example Power Level Switch Command

Bytes 0 1 2 3 4 5 6 7 8 9 10 11Stream a l p : / / p p s w / 9Explanation Stands for Ardulink Toggle Pin PinComponent Protocol Command Pin

A example power switch command is shown as Table 4.2. It toggles powerpin a ached at 9. There are several commands available in Ardulink pro-tocol which all composite as the same as table shown. If a device wants

21

Page 28: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

to receive the message fromArduino, listen commands have to be used inthe front. A typical message will be around 11 bytes.

Other protocols are also available. Firmata library provides a messageprotocol based on MIDI. While ASIP claims a smaller memory comparedto Firmata. It works fine as of Python client but is rather wrong as ofmy Java client implementation. Such difficulties are occurred many timesas the text steam starts to be out of order and the protocol and devicebehavior goes wrong. This error is not recoverable for Arduino.

Nanopb is a minimized C implementation of Protocol Buffers aimed at32 bit microcontrollers. As its design goal, the model might be reusablefor microcontroller but it also requires a number of processing power andmemory footage 3.

4.3.2 Deployment

Arduino is built upon a AVR micro-controller. Its executable program isnot huge but rather small as less than 2 MB. While dynamic configura-tion of pins and hard-to-read text description like ASIP, a meta-compilerseems feasible to generate firmware. Single-board computer usually haveenough power to compile and upload the firmware. As the time limita-tion, this is a future work.

4.4 Evaluation

A direct connection is conducted. Then the bridge set-up will be used totest IoT scenario. Hereby, the thesis tests the throughput and latency. Thethroughput is defined as the message being transferred per second. Theserial communication is full-duplex. So messages sent and received arecounted separately. The latency is defined as round trip time.

4.4.1 Direct Connection

In the direct connection, the USB cable is used to connected between Ar-duino andRaspberry Pi or a computer. In each computer, a SensibleThingsplatform is running as a kelips bootstrap node at their own IP address.Only 1 node is presented in the network.

The throughput and latency is evaluated. The throughput is defined as thenumber ofmessages per second for 120 seconds. The link channel is firstlyset-up and running for 10 seconds to prevent connection failures. Aftera short break, the computer will start to flood the Arduino by flippingdigital pin at 9 which connected to a LED. Value changed event at 9 andanalog event are generated from analog pin 0. Though, the analog pin isconnected with a knob. ADCwill yield some twitching when quantize itsvolts which simulates a sensor. But the general idea is to exhaust the link

3http://koti.kapsi.fi/jpa/nanopb/

22

Page 29: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

to see the overall throughput. Sending and receiving is done by differentthreads. The hardware setup is shown as Figure 4.3.

Figure 4.3: Direct Connection for Throughput Test

For testing round trip latency, I watched the event happened at digital pin3. While the computer sends the message to pin 9, it will generates theoutput to pin 3 which will generate the digital pin value changed event.The message is transmi ed back to the computer. The sending momentand the received moment are used to get the round trip time.

Figure 4.4: Direct Connection for Latency Test

4.4.2 Bridge in SensibleThings

In the bridge connection, the throughput and latency is evaluated. Theirdefinitions are regulated as the same fashion as direct connection. Ex-cept, the topology is more completed. The USB cable is used to connected

23

Page 30: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

between Arduino and Raspberry Pi. This is the same as previous test.Raspberry Pi connects to the router as well as a computer. SensibleThingsplatform is running on both computers. But a kelips bootstrap node isnow located in the laptop.

The message is sent from the laptop towards an UCI registered by Rasp-berry Pi. Once upon a message, Raspberry Pi forwards the message inArdulink protocol to Arduino and also transmit it back towards the lap-top. This process implements the bridge connection for Arduino in Sensi-bleThings. The network topology is shown as Figure 4.5.

Figure 4.5: Bridge Topology

The detailed hardware and software environment is described in the Ap-pendix B.

4.5 Sample Application

The sample application is built to examine the usefulness of design. A Sen-sibleThings network is constructed with Arduino, Android App, Rasp-berry Pi and the gateway in a laptop. The structure is shown as Figure4.6.

24

Page 31: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure 4.6: Application Structure

Arduino is connected with a LED, potentiometer and a servo. The servocan be set to a precise angle. The potentiometer is used to control thatspecific angle. The angle control is done by Raspberry Pi. The Rasp-berry Pi reads the incoming number and manipulate the value in a saferange. Moreover, the angle is controlled by a software switch. The soft-ware switch is dedicated in the Android app. Once it’s enabled, the Rasp-berry Pi will issue the command to the servo. Otherwise, the servo main-tains a default position. The gateway is constructed as a data collectionpoint. All the commands and potentiometer reading will be sent to thegateway. The gateway pushed the message to a message broker. Thosemessages can be further received, processed and analyzed, probably inthe cloud.

25

Page 32: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

5 ResultsResults are included based on the tests described by Chapter 4. In thebeginning, Arduino is connected with laptop and single-board computerseparately. This test is called Direct Connection. Then Arduino is con-nected to the single-board computer. The single-board computer and lap-top is connected in the sameLANenvironment. Both tests address through-put and latency.

5.1 Direct Connection

Direct connection shows the how it’s bridge device can affects channelsand Arduino performance.

5.1.1 Throughput

The Throughput conducts in two environments, one is Raspberry Pi, theother one is Macbook Pro.

Figure 5.1: Throughput when Arduino is connected with each device

Due to duplex characteristics, the serial channel can transmit two streamsat the same time. The test puts the strong noise on Arduino and madethe micro-controller overwhelms. When the laptop starts to transmit, theArduino replies less comparing to Raspberry Pi. That is caused by hard-ware interrupt. The UART receives a full package and validates the result.Then it invokes the hardware interrupt to notify the Arduino to capturethe message which is shown as Figure 5.1.

26

Page 33: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Raspberry Pi has twitching over time. A possible cause is the JVMgarbagecollection. JVM stops the program and reclaims used variable memory.During this time, the messages stops to send. Arduino returns less mes-sages at the same time may caused by less packages to flip the LED. Ana-log events on the test are caused byADC errors, comparing to fast flippingactions and notification messages. It may not enough to fill the small gap.Overall, it doesn’t affects general throughput.

All sendingpackages have a shape curve in the beginning, thatmay causedby underlying buffers in RXTX library. To be notice, RXTX is a old librarywhich doesn’t receive a patch version update since almost 10 years ago.Especially it can not handle Linux serial port automatically. One of alter-natives, Java Simple Serial Connector (jSSC) can be a good choice. ASIP isusing jSSC for their Java client.

Received messages are not dramatically different. That’s because serialevent is a hardware interrupt which prevents Arduino enter processinglogic where checks the previous state and generates the reply. Since thetest is to exhaust the link, Arduino is actually trying its best to receive asmuch messages as possible. It may receives many messages as it can ac-tually process the messages so those messages may lost. And no messagewill be sent back to the host.

Table 5.1 show the throughput information in terms of Ardulink mes-sages.

Table 5.1: Statistics among 10 Tests

Scene Average Standard DeviationMac, send 775 0.41Mac, receive 441 4.33Mac, all 1216 3.94Pi, send 482 0.76Pi, receive 467 0.24Pi, all 949 0.78

5.1.2 Latency

The latency is defined as the round trip time of messages. The host senda message to change one pin status in Arduino. It deliveries the data backto the host. This time is the latency defined.

All tests confirm a huge increase at the same point for Raspberry Pi whichmay caused by JVM GC event. With powerful CPU, the latency on thelink can be slightly reduced as Figure 5.2 shows. Beyond that, the latencyis rather stable and is below 10ms.

27

Page 34: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure 5.2: Round-trip latency when Arduino is connected with each device

Table 5.2 show the latency towards two devices. Mac achieves 4.032 msround trip latency and Raspberry Pi achieves rather double as Mac, at8.266 ms.

Table 5.2: Statistics among 10 Tests

Device Average Standard DeviationMac 4.0 0.020Pi 8.3 0.004

5.2 Bridge Connection

As of the bridge connection, the message sent is simply the value from theMacbook Pro transferred across the network. The message will eventu-ally forward to the Arduino by the bridge. The received message is prop-agating from Arduino by the bridge. Based on implementation of Sensi-bleThings, the frame size of messages varies. Overheads maintained theDHT is not counted.

5.2.1 Throughput

SensibleThings is set to be TCP and RUDP. Figure 5.3 shows the through-put using RUDP over 2minutes, in which only 9ms and 12.5ms are shownin the result. The number of time is the sending interval of Macbook Pro.

28

Page 35: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure 5.3: Bridge Throughput using RUDP with 9ms and 12.5ms Interval

In RUDP, conceivable loss can be observed if the interval is shorter than9ms. The detailed information is shown in Table 5.3. At 9 ms, 11 ms and12.5 ms, it has a relative stable received result. But in the Figure 5.3, twospikes are shown as it could be buffer implementation of JVMor operatingsystem.

Table 5.3: AverageMessages per second at Different Sending Intervals (ms) using RUDP

Intervals 4 8 9 9.5 10 11 12.5 15 20Send 218 112 100 89 179 81 70 60 46Send Std. 4.12 1.60 0.96 1.02 2.47 0.98 0.76 0.91 0.58Receive 11 32 85 85 86 81 83 88 93Recv. Std. 38.60 47.70 35.87 26.80 93.53 26.66 20.33 22.47 22.91All 229 144 185 175 264 172 152 148 139All Std. 38.01 47.17 35.94 26.87 93.62 26.73 20.47 22.63 22.93

The TCP test is conducted as the same as previous RUDP test. But sendinginterval is much longer if no significant loss. As shown in Figure 5.4, thethroughput is less than RUDP in general.

29

Page 36: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure 5.4: Bridge Throughput using TCP with 20ms and 22.5ms Interval

In TCP, conceivable loss can be observed if the interval is shorter than9ms. The detailed information is shown as Table 5.4. At 9 ms, 11 ms and12.5 ms, it has a relative stable received result. But in the Figure 5.4, thereceivedmessages has many twitching, and it generally achieves less datarate than RUDP. What’s worse, it not stable. The detailed information isshown in Table 5.4.

Table 5.4: Average Messages per second at Different Sending Intervals (ms) using TCP

Intervals 15 17.5 20 22.5 25 27.5 30 35 50Send 60 51 45 40 36 33 31 27 19Send Std. 0.67 0.76 0.67 0.56 0.48 0.58 0.58 0.39 0.44Receive 14 20 22 31 41 50 56 66 91Recv. Std. 14.62 15.56 13.10 16.98 19.63 21.32 24.37 22.97 28.29All 74 70 66 72 77 83 88 92 110All Std. 14.64 15.76 13.18 17.08 19.68 21.47 24.28 22.99 28.30

5.2.2 Latency

The latency is performed in the similar way as direct connection. Themes-sage is sent from MacBook Pro. While the Raspberry Pi receives the mes-sage and convert the message to Arduino, then the response is convertedback to Macbook Pro by Raspberry Pi. As shown in the Figure 5.5, thespike of around 200ms and the other around 100ms should be JVM GCevent on the Raspberry Pi node.

30

Page 37: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure 5.5: Throughput bridge is connected with each device

Table 5.5 show the latency details for bridge connection. It is roughly 2times more than direct connection with Mac. However, the link is ratherstable.

Table 5.5: Statistics among 10 Tests

Average Standard Deviation19 0.29

The complete data of all tests are plo ed. See the Appendix C for figures.

5.3 Sample Application

According to the Section 4.5, a distributed network is connected by Sensi-bleThings. Arduino operates the servo and reading from the potentiome-ter but the control work is done by Raspberry Pi which is also a node inthe network. The Android app controls whether servo can be operated.The sink can collect data to further process.

The sample application runs successfully with a minor package loss sinceRUDP implementation is not solid. The control panel in the Android isshown as Figure 5.6. If the bu on is toggled, the message will be sent toRaspberry Pi node since it registers the corresponding UCI for Arduino aswell as the gateway for log aggregation. Arduino connects every devicesas Figure 5.7.

The gateway receives logs and delivery it to the message broker which areshown as Figure 5.8 and Figure 5.9.

31

Page 38: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure 5.6: Control panel in an Android app Figure 5.7: Arduino UNOv3 with thea ached hardware component

Figure 5.8: Arduino UNOv3 with thea ached hardware component

Figure 5.9: Received pending messages in themessage broker

Therefore, theworking distributed application is feasible and can be easilydone.

Sample code and test code are available as Appendix A shows.

32

Page 39: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

6 ConclusionsIn this thesis, I investigated the general concept of Internet of Things aswell as other IoT platforms. SensibleThings is chosen as the tested IoTplatform since it provides distributed DHT and open source. I made thecomparison among various of devices, among them I chose the micro-controller and single-board computer as the experimental configuration.Given the community popularity, Arduino is used as micro-controller de-vice. Raspberry Pi is used as single-board computer. SensibleThings isrunning on the computer and Raspberry Pi for the specific experiments.With the Raspberry Pi, I used it as a bridge device to enable Arduino toconnect with other nodes in SensibleThings network. As of the bridgeconnection, serial communication over GPIO and USB is investigated. Iused the USB virtual serial communication port to conduct a series testabout throughput and latency. In the beginning, a set of direct connectionis investigated as a reference. Later, the bridge connection is conducted inthe same way. As a result, by using RUDP, we can hold around 170 mes-sages transmi ed or received within 18 ms latency which is acceptable foradvanced controls. With such performance,micro-controller is proven ap-plicable to join a high-level Internet of Things platform. It opens a boarderapplication possibilities.

6.1 Ethical Consideration

As the small micro-controller can be easily embedded into daily objects,it raises the privacy concern. Unlike a RFID tag, it’s passive and often re-quires another devices to read it. Thus potential users are fully informedof its existence. But a micro-controller might just a ached with a sensorand sampling the temperature. Moreover, image collection is also possi-ble. In the worse case, the device can be too small so the user might notnotice that. To some extend, it might collect enough data to recover a casewhere privacy is a concern. Law can enforce a consensus use case butthe clause should not restrict on its power consumption, size, communi-cation methods and abilities. Otherwise, a micro-controller is just uselesscomparing to other solutions. Such loss may impact possible productioninnovation a lot.

Considered the fact the distributed network can operate many physicalcomponents, misbehavior may cause property loss, even human death.Fault tolerance is hard to achieve by a general policy. Thus the physi-cal component as well as micro-controllers should be designed in a fault-tolerant way. Even parts or all distributed network refuses to work, thephysical objects can be retain a safe position or raise the confirmation fromhuman operator.

Besides its disadvantage, it shows a promising future. Cheaper hard-

33

Page 40: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

wares often results in more interesting application development. Micro-controllers are usually cheaper than single-board computer or more ad-vanced devices. Installation like amain host with several micro-controllercomponents are likely to be useful to cut down some extra costs and pro-vide customization. Itwould be good to see a complicated surgery devicescan be installed depend on situation with cheap deployment cost. Thus itcertainly opens up more possibilities.

6.2 Future Work

Arduino can be connected with additional hardware to extend its func-tions. Those devices are called Arduino Shield. They are directly con-nected by pins or connected by serial communication. Some Shield pro-vides IEEE 802.11 network or Ethernet. The performance will varies sinceadditional hardware is connected. Those modules may not be powerfulenough to run SensibleThings. But it can be still connected with a deviceas bridge, for example, Raspberry Pi. If time permits, I can build suchbridge as the same as this thesis by replacing Ardulink with libraries com-municating with shield instead. And I can expect reduced performance inwireless communication and more or less similar performance in Ether-net.

A JSON file can describe services on Arduino and its underlying pins.A meta-compiler can generate client code for single-board computer andmicrocontrollers. It generally isolates different layers of abstraction andcan offer ability to deploy new firmware for microcontrollers in a existingnetwork. For Arduino, a meta-compiler can generate and cross-compilea C++ protocol class with other code. Then it can be delivery to the con-nected bridge where the firmware can be uploaded.

34

Page 41: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

References[1] International Telecommunication Union, “Overview of the internet

of things”, Series Y: Global information infrastructure, internet protocolaspects and next-generation networks - Frameworks and functional archi-tecture models, p. 22, 2012.

[2] D. Miorandi, S. Sicari, F. De Pellegrini, and I. Chlamtac, “Internet ofthings: vision, applications and research challenges”, Ad Hoc Net-works, vol. 10, no. 7, pp. 1497–1516, 2012.

[3] L. A ori, A. Iera, and G. Morabito, “The internet of things: a sur-vey”, Computer Networks, vol. 54, no. 15, pp. 2787–2805, 2010.

[4] J. Gubbi, R. Buyya, S. Marusic, and M. Palaniswami, “Internet ofthings (iot): a vision, architectural elements, and future directions”,Future Generation Computer Systems, vol. 29, no. 7, pp. 1645–1660,2013.

[5] L. Coe ee and J. Eksteen, “The internet of things – promise for thefuture? an introduction”, Conference Proceedings, pp. 978–1, 2011.

[6] S. Forsström, V. Kardeby, P. Österberg, and U. Jennehag, “Chal-lenges when realizing a fully distributed internet-of-things - howwe created the sensiblethings platform”, ICDT 2014, The Ninth In-ternational Conference on Digital Telecommunications, no. c, pp. 13–18,2014.

[7] R. H. Weber, “Internet of things – new security and privacy chal-lenges”, Computer Law & Security Review, vol. 26, no. 1, pp. 23–30,2010.

[8] R. R. Schaller, “Moore’s law: past, present and future”, Spectrum,IEEE, vol. 34, no. 6, pp. 52–59, 1997.

[9] B.Nakhuva andT.Champaneria, “Study of various internet of thingsplatforms”, International Journal of Computer Science & EngineeringSurvey, vol. 6, no. 6, pp. 61–74, 2015.

[10] Atmel, Atmel 8-bit microcontroller with 4/8/16/32kbytes in-system pro-grammable flash datasheet, 2015.

[11] S. Ferdoush and X. Li, “Wireless sensor network system design us-ing raspberry pi and arduino for environmental monitoring appli-cations”, Procedia Computer Science, vol. 34, pp. 103–110, 2014.

[12] J. Cowley, Communications and networking: An introduction (under-graduate topics in computer science): John cowley: 9781447143567: Ama-zon.com: Books.

[13] Usb 2.0 specification.[14] M. Bordoni, M. Bo one, B. Fields, N. Gorogiannis, M. Margolis, G.

Primiero, and F. Raimondi, “Towards cyber-physical systems as ser-

35

Page 42: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

vices: the asip protocol”, Proceedings - International Workshop on Soft-ware Engineering for Smart Cyber-Physical Systems, SEsCPS 2015, pp. 52–55, 2015.

[15] G. Barbon, M. Margolis, F. Palumbo, F. Raimondi, and N. Weldin,“Taking arduino to the internet of things: the asip programmingmodel”, Computer Communications, vol. 00, pp. 1–15, 2016.

[16] OMazhelis and P Tyrvainen, “A framework for evaluating internet-of-things platforms: applicationprovider viewpoint”, Internet of Things(WF-IoT), 2014 IEEEWorld Forum on, no. February 2011, pp. 147–152,2014.

[17] H. Derhamy, J. Eliasson, J. Delsing, and P. Priller, “A survey of com-mercial frameworks for the internet of things”, IEEE InternationalConference on Emerging Technologies and Factory Automation, ETFA,vol. 2015-October, 2015.

[18] K. Vandikas and V. Tsiatsis, “Performance evaluation of an iot plat-form”, Proceedings - 2014 8th International Conference on Next Gener-ation Mobile Applications, Services and Technologies, NGMAST 2014,pp. 141–146, 2014.

36

Page 43: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

A Documentation of CodeSource code and development happens at:

• https://bitbucket.org/fantasticfears/miun-ba-thesis

• https://bitbucket.org/fantasticfears/sensible-things-node

• https://bitbucket.org/fantasticfears/miun-ba-thesis-arduino

• https://bitbucket.org/fantasticfears/miun-ba-thesis-android

• https://bitbucket.org/fantasticfears/miun-ba-thesis-report

37

Page 44: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

B Detailed Test Environment

Macbook Pro

• Hardware Model: Retina, 13inch, Early 2015, 2.9 GHz Intel Core i5.MF841LL

• Operating System: OS X 10.11.4

• JVM: Oracle JDK 8 (build 1.8.0_60-b27)

• JVM options:

["-Xmx1024m", "-XX:+UseParallelGC","-XX:-UseAdaptiveSizePolicy", "-XX:NewSize=400m","-XX:MaxNewSize=400m", "-XX:SurvivorRatio=6"]

Raspberry Pi

• Hardware Model: Model B 1 Revision 2.0, revision code 000e

• Operating System: Raspbian GNU/Linux 8 (jessie)

• JVM: Oracle JDK 8 (build 1.8.0_65-b17)

• JVM options:

["-Xmx250m", "-XX:+UseParallelGC","-XX:-UseAdaptiveSizePolicy", "-XX:NewSize=70m","-XX:MaxNewSize=70m", "-XX:SurvivorRatio=6"]

With the gradle daemon enabled.

Arduino

Hardware Model: Arduino UNO ver3

Router

• Hardware Model: Netgear N300, JWNR2010v5

• Firmware: V1.1.0.32_1.0.1

38

Page 45: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Libraries

• SensibleThings: An fork of Public Beta 6 at 46bb7c8 1.

• Ardulink: 2.0 snapshot with a lot of unit tests deleted at 76532f 2.

• RXTX binaries: 2.2pre2 binaries

• Arduino IDE: 1.6.9

• Arduino AVR Boards Definition: 1.6.11

1https://github.com/fantasticfears/SensibleThings2https://github.com/Ardulink/Ardulink-2

39

Page 46: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

C Complementary Result Figures

Figure C.1: Messages per second with MacBook Pro

Figure C.2: Messages per second with Raspberry Pi

40

Page 47: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure C.3: Round Trip Latency with MacBook Pro

Figure C.4: Round Trip Latency with Raspberry Pi

41

Page 48: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure C.5: Messages per second with Bridge using RUDP

Figure C.6: Messages per Seconds with Bridge using TCP

42

Page 49: DiVA portal945110/FULLTEXT01.pdfConnectingArduinoSensorstoSensibleThings XiaoGuan 2016-06-06 Terminology ADC Analog-to-DigitalConverter ASIP ArduinoServiceInterfaceProtocol COM CommunicationPort

Connecting Arduino Sensors to SensibleThingsXiao Guan 2016-06-06

Figure C.7: Round Trip Latency with Bridge using RUDP

43