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

lOMoARcPSD|30789968

IOT Notes All Units PDF

Internet of things (Anna University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)
lOMoARcPSD|30789968

CP4251 - INTERNET OF THINGS

UNIT I - INTRODUCTION

Internet of Things -Domain Specific IoTs -IoT and M2M -Sensors for IoT Applications–
Structure of IoT - IoT Map Device- IoT System Management with NETCONF-YANG

UNIT II - IoT ARCHITECTURE, GENERATIONS AND PROTOCOLS

IETF architecture for IoT - IoT reference architecture -First Generation – Description &
Characteristics–Advanced Generation – Description & Characteristics–Integrated IoT
Sensors – Description & Characteristics

UNIT III - IoT PROTOCOLS AND TECHNOLOGY

SCADA and RFID Protocols - BACnet Protocol -Zigbee Architecture - 6LowPAN - CoAP
-Wireless Sensor Structure–Energy Storage Module–Power Management Module–RF
Module–Sensing Module

UNIT IV - CLOUD ARCHITECTURE BASICS

The Cloud types; IaaS, PaaS, SaaS.- Development environments for service development;
Amazon, Azure, Google Appcloud platform in industry

UNIT V - IOT PROJECTS ON RASPBERRY PI

Building IoT with RASPBERRY Pi- Creating the sensor project - Preparing Raspberry Pi -
Clayster libraries – Hardware Interacting with the hardware - Interfacing the hardware-
Internal representation of sensor values - Persisting data - External representation of
sensor values - Exporting sensor data

Page 1

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

UNIT I - INTRODUCTION
Internet of Things -Domain Specific IoTs -IoT and M2M -Sensors for IoT Applications–
Structure of IoT - IoT Map Device- IoT System Management with NETCONF-YANG

1. DOMAIN SPECIFIC IoTs

1) Home Automation:

a) Smart Lighting: helps in saving energy by adapting the lighting to the ambient
conditions and switching on/off or diming the light when needed.

b) Smart Appliances: make the management easier and also provide status information
to the users remotely.

c) Intrusion Detection: use security cameras and sensors(PIR sensors and door
sensors) to detect intrusion and raise alerts. Alerts can be in the form of SMS or email
sent to the user.

d) Smoke/Gas Detectors: Smoke detectors are installed in homes and buildings to


detect smoke that is typically an early sign of fire. Alerts raised by smoke detectors can
be in the form of signals to a fire alarm system. Gas detectors can detect the presence
of harmful gases such as CO, LPGetc.,

2) Cities:

a) Smart Parking: make the search for parking space easier and convenient for drivers.
Smart parking are powered by IoT systems that detect the no. of empty parking slots
and send information over internet to smart application backends.

b) Smart Lighting: for roads, parks and buildings can help in saving energy.

c) Smart Roads: Equipped with sensors can provide information on driving condition,
travel time estimating and alert in case of poor driving conditions, traffic condition
and accidents.

d) Structural Health Monitoring: uses a network of sensors to monitor the vibration


levels in the structures such as bridges and buildings.

e) Surveillance: The video feeds from surveillance cameras can be aggregated in cloud
based scalable storage solution.

f) Emergency Response: IoT systems for fire detection, gas and water leakage
detection can help in generating alerts and minimizing their effects on the critical
infrastructures.

Page 2

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

3) Environment:

a) Weather Monitoring: Systems collect data from a no. of sensors attached and send
the data to cloud based applications and storage back ends. The data collected in
cloud can then be analyzed and visualized by cloud based applications.

b) Air Pollution Monitoring: System can monitor emission of harmful gases(CO2, CO,
NO, NO2 etc.,) by factories and automobiles using gaseous and meteorological
sensors. The collected data can be analyzed to make informed decisions on pollutions
control approaches.

c) Noise Pollution Monitoring: Due to growing urban development, noise levels in


cities have increased and even become alarmingly high in some cities. IoT based
noise pollution monitoring systems use a no. of noise monitoring systems that are
deployed at different places in a city. The data on noise levels from the station is
collected on servers or in the cloud. The collected data is then aggregated to generate
noise maps.

d) Forest Fire Detection: Forest fire can cause damage to natural resources, property
and human life. Early detection of forest fire can help in minimizing damage.

e) River Flood Detection: River floods can cause damage to natural and human
resources and human life. Early warnings of floods can be given by monitoring the
water level and flow rate. IoT based river flood monitoring system uses a no. of sensor
nodes that monitor the water level and flow rate sensors.

4) Energy:

a) Smart Grids: is a data communication network integrated with the electrical grids
that collects and analyze data captured in near-real-time about power transmission,
distribution and consumption. Smart grid technology provides predictive information
and recommendations to utilities, their suppliers, and their customers on how best to
manage power. By using IoT based sensing and measurement technologies, the
health of equipment and integrity of the grid can be evaluated.

b) Renewable Energy Systems: IoT based systems integrated with the transformers at
the point of interconnection measure the electrical variables and how much power is
fed into the grid. For wind energy systems, closed-loop controls can be used to
regulate the voltage at point of interconnection which coordinate wind turbine outputs
and provides power support.

c) Prognostics: In systems such as power grids, real-time information is collected using


specialized electrical sensors called Phasor Measurment Units(PMUs) at the
substations. The information received from PMUs must be monitored in real-time for
estimating the state of the system and for predicting failures.

5) Retail:

a) Inventory Management: IoT systems enable remote monitoring of inventory using


data collected by RFIDreaders.

Page 3

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

b) Smart Payments: Solutions such as contact-less payments powered by technologies


such as Near Field Communication(NFC) and Bluetooth.

c) Smart Vending Machines: Sensors in a smart vending machines monitors its


operations and send the data to cloud which can be used for predictive maintenance.

6) Logistics:

a) Route generation & scheduling: IoT based system backed by cloud can provide first
response to the route generation queries and can be scaled upto serve a large
transportation network.

b) Fleet Tracking: Use GPS to track locations of vehicles inreal-time.

c) Shipment Monitoring: IoT based shipment monitoring systems use sensors such as
temp, humidity, to monitor the conditions and send data to cloud, where it can be
analyzed to detect foods poilage.

d) Remote Vehicle Diagnostics: Systems use on-board IoT devices for collecting data
on Vehicle operations(speed, RPMetc.,) and status of various vehicle subsystems.

7) Agriculture:

a) Smart Irrigation: to determine moisture amount in the soil.

b) Green House Control: to improve productivity.

8) Industry:

a) Machine diagnosis and prognosis

b) Indoor Air Quality Monitoring

9) Health and Lifestyle:

a) Health & Fitness Monitoring

b) Wearable Electronics

Page 4

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

2. IoT Systems Management with


NETCONF-YANG

YANG is a data modeling language used


to model configuration and state data
manupulated by the NETCONF protocol.

The generic approach of IoT device


management weith NETCONF-YANG.
various componentsare:

1. Management System
2. Management API
3. Transaction Manager
4. Rollback Manager
5. Data Model Manager
6. Configuration Validator
7. Configuration Database
8. Configuration API
9. Data Provider API

1. Management System : The operator uses a management system to send NETCONF


messages to configure the IoT device and receives state information and notifications
from the device as NETCONF messages.

2. Management API : allows management application to start NETCONF sessions.

3. Transaction Manager: executes all the NETCONF transactions and ensures that
ACID properties hold true for the transactions.

4. Rollback Manager : is responsible for generating all the transactions necessary to


rollback a current configuration to its original state.

5. Data Model Manager : Keeps track of all the YANG data models and the
corresponding managed objects. Also keeps track of the applications which provide
data for each part of a data model.

6. Configuration Validator : checks if the resulting configuration after applying a


transaction would be a valid configuration.

7. Configuration Database : contains both configuration and operational data.

8. Configuration API : Using the configuration API the application on the IoT device can
be read configuration data from the configuration datastore and write operational data
to the operational datastore.

9. Data Provider API: Applications on the IoT device can register for callbacks for
various events using the Data Provider API. Through the Data Provider API, the
applications can report statistics and operational ldata.

Page 5

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

3. Structure of IoT

Internet of Things (IoT) is a system of interrelated, internet-connected objects which


are able to collect and transfer data over a wireless network without human intervention.
For example, smart fitness bands or watches, driverless cars or drones, smart homes that
can be unlocked through smartphones and smart cars, etc.

IoT architecture varies from solution to solution, based on the type of solution which we
intend to build. IoT as a technology majorly consists of four main components, over which
an architecture is framed.

1) Sensors 2) Devices 3) Gateway 4) Cloud

Stages of IoT Architecture

Stage 1: Sensors/actuators
Sensors collect data from the environment or object under measurement and turn it
into useful data. Think of the specialized structures in your cell phone that detect the
directional pull of gravity and the phone's relative position to the ―thing‖ we call the earth
and convert it into data that your phone can use to orient the device.

Page 6

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Actuators can also intervene to change the physical conditions that generate the
data. An actuator might, for example, shut off a power supply, adjust an air flow valve, or
move a robotic gripper in an assembly process.

The sensing/actuating stage covers everything from legacy industrial devices to


robotic camera systems, water level detectors, air quality sensors, accelerometers, and
heart rate monitors. And the scope of the IoT is expanding rapidly, thanks in part to low-
power wireless sensor network technologies and Power over Ethernet, which enable
devices on a wired LAN to operate without the need for an A/C power source.

Stage 2: The Internet gateway


The data from the sensors starts in analog form. That data needs to be aggregated
and converted into digital streams for further processing downstream. Data acquisition
systems (DAS) perform these data aggregation and conversion functions. The DAS
connects to the sensor network, aggregates outputs, and performs the analog-to-digital
conversion. The Internet gateway receives the aggregated and digitized data and routes it
over Wi-Fi, wired LANs, or the Internet, to Stage 3 systems for further processing. Stage 2
systems often sit in close proximity to the sensors and actuators.

For example, a pump might contain a half-dozen sensors and actuators that feed
data into a data aggregation device that also digitizes the data. This device might be
physically attached to the pump. An adjacent gateway device or server would then process
the data and forward it to the Stage 3 or Stage 4 systems. Intelligent gateways can build
on additional, basic gateway functionality by adding such capabilities as analytics,
malware protection, and data management services. These systems enable the analysis
of data streams in real time.

Stage 3: Edge IT
Once IoT data has been digitized and aggregated, it's ready to cross into the realm
of IT. However, the data may require further processing before it enters the data center.
This is where edge IT systems, which perform more analysis, come into play. Edge IT
processing systems may be located in remote offices or other edge locations, but
generally these sit in the facility or location where the sensors reside closer to the sensors,
such as in a wiring closet. Because IoT data can easily eat up network bandwidth and
swamp your data center resources, it's best to have systems at the edge capable of
performing analytics as a way to lessen the burden on core IT infrastructure. You'd also
face security concerns, storage issues, and delays processing the data. With a staged
approach, you can preprocess the data, generate meaningful results, and pass only those
on. For example, rather than passing on raw vibration data for the pumps, you could
aggregate and convert the data, analyze it, and send only projections as to when each
device will fail or need service.

Stage 4: The data center and cloud


Data that needs more in-depth processing, and where feedback doesn't have to be
immediate, gets forwarded to physical data center or cloud-based systems, where more
powerful IT systems can analyze, manage, and securely store the data. It takes longer to
get results when you wait until data reaches Stage 4, but you can execute a more in-depth
analysis, as well as combine your sensor data with data from other sources for deeper
insights. Stage 4 processing may take place on-premises, in the cloud, or in a hybrid cloud
system, but the type of processing executed in this stage remains the same, regardless of
the platform.

Page 7

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

4. IoT and M2M

Machine-to-Machine (M2M)

Machine-to-Machine (M2M) refers to networking of machines(or devices) for the purpose


of remote monitoring and control and data exchange.

• Term which is often synonymous with IoT is Machine-to-Machine (M2M).


• IoT and M2M are often used interchangeably.

Fig. Shows the end-to-end architecture of M2M systems comprises of M2M area networks,
communication networks and application domain.

• An M2M area network comprises of machines( or M2M nodes) which have


embedded network modules for sensing, actuation and communicating various
communication protocols can be used for M2M LAN such as ZigBee, Bluetooth, M-
bus, Wireless M-Bus etc., These protocols provide connectivity between M2M
nodes within an M2M area network.

• The communication network provides connectivity to remote M2M area networks.


The communication network can use either wired or wireless network(IP based).
While the M2M are networks use either properietorary or non-IP based
communication protocols, the communication network uses IP-based network.
Since non-IP based protocols are used within M2M area network, the M2M nodes
within one network cannot communicate with nodes in an external network.

• To enable the communication between remote M2M are network, M2M gateways
are used.

Page 8

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Fig. Shows a block diagram of an M2M gateway. The communication between M2M nodes
and the M2M gateway is based on the communication protocols which are naive to the
M2M are network. M2M gateway performs protocol translations to enable Ip-connectivity
for M2M are networks. M2M gateway acts as a proxy performing translations from/to
native protocols to/from Internet Protocol(IP). With an M2M gateway, each mode in an
M2M area network appears as a virtualized node for external M2M area networks.

Differences between IoT and M2M:

1) Communication Protocols:
• Commonly uses M2M protocols include ZigBee, Bluetooth, ModBus, M-Bus,
Wireless M-Bus tec.,
• In IoT uses HTTP, CoAP, WebSocket , MQTT ,XMPP ,DDS ,AMQP etc.,

2) Machines in M2M Vs Things in IoT:


• Machines in M2M will be homogenous whereas Things in IoT will be heterogeneous.
3) Hardware Vs Software Emphasis: the emphasis of M2M is more on hardware with
embedded modules, the emphasis of IoT is more on software.

4) Data Collection &Analysis


• M2M data is collected in point solutions and often in on-premises storage
infrastructure.
• The data in IoT is collected in the cloud (can be public, private orhybrid cloud).

5) Applications
• M2M data is collected in point solutions and can be accessed by on-premises
applications such as diagnosis applications, service management applications, and
on- premisis enterprise applications.
• IoT data is collected in the cloud and can be accessed by cloud applications such as
analytics applications, enterprise applications, remote diagnosis and management
applications, etc.

Page 9

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

UNIT II - IoT ARCHITECTURE, GENERATIONS AND PROTOCOLS


IETF architecture for IoT - IoT reference architecture -First Generation – Description &
Characteristics–Advanced Generation – Description & Characteristics–Integrated IoT
Sensors – Description & Characteristics

1. IETF architecture for IoT

➢ 6LoWPAN (IPv6 over Low-power WPAN), CoRE (Constrained RESTful


Environments), and ROLL (Routing Over Low power and Lossy networks).
➢ Each set of specifications makes an attempt to address a different part of
the communication stack of a constrained device.
➢ One layer called Application Support which includes the Presentation and
Session Layers combined. one intermediate layer is introduced: the
Adaptation Layer
➢ It positioned between the Physical/Data Link and the Network Layer and
whose main function is to adapt the Network Layer packets to Phy/Link
layer packets among others.
➢ An example of an adaptation layer is the 6LoWPAN layer designed to adapt
IPv6 packets to IEEE 8021.5.4/Bluetooth Low Energy (BLE)/DECT Low
Energy packets.
➢ An example of an Application Support Layer is IETF Constrained
Application Protocol (CoAP), which provides reliability and RESTful
operation support to applications; however, it does not describe the specific
names of resources a node should host.
➢ The IETF CoAP draft specification describes the Transport and Application
Support Layers, which essentially defines the transport packet formats,
reliability support on top of UDP, and a RESTful application protocol with
GET/PUT/POST/DELETE methods similar to HTTP with CoAP clients
operating on CoAP server resources.
➢ A CoAP server is just a logical protocol entity, and the name “server” does
not necessarily imply that its functionality is deployed on a very powerful
Page 10

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

machine; a CoAP server can be hosted on a constrained device.

➢ The CoRE Link Format specification describes a discovery method for the
CoAP resources of a CoAP server.
➢ For example, a CoAP client sending a request with the GET method to a
specific well defined server resource (./well-known/core) should receive a
response with a list of CoAP resources and some of their capabilities (e.g.
resource type, interface type).
➢ The CoRE interface specification describes interface types and
corresponding expected behavior of the RESTful methods.
➢ The IETF stack for IoT does not currently include any specifications that are
similar to the profile specifications of other IoT technologies such as ZigBee
➢ Profile specification means a document that describes a list of profile
names and their mappings to specific protocol stack behavior, specific
information model, and specific serialization of this information model over
the relevant communication medium.
➢ An example of a profile specification excerpt would mandate that an
exemplary “Temperature” profile:
(a) should support a resource called /temp,
(b) the resource /temp must respond to a GET method request from a client, and
(c) the response to a GET method request shall be a temperature value in
degrees Celsius formatted as a text string with the format “,temperature
value encoded in a decimal number ._C”
➢ A Resource Directory is a CoAP server resource (/rd) that maintains a list of
resources, their corresponding server contact information (e.g. IP
addresses or fully qualified domain name, or FQDN), their type, interface,
and other information similar to the information that the CoRE Link Format
document specifies.

Page 11

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

➢ An RD plays the role of a rendezvous mechanism for CoAP Server


resource descriptions, in other words, for devices to publish the descriptions
of the available resources and for CoAP clients to locate resources that
satisfy certain criteria such as specific resource types. (e.g. temperature
sensor resource type).
➢ Resource Directory is a rendezvous mechanism for CoAP Server resource
descriptions, a Mirror Server is a rendezvous mechanism for CoAP Server
resource presentations.
➢ A Mirror Server is a CoAP Server resource (/ms) that maintains a list of
resources and their cached representations (Figure 6.8b).
➢ A CoAP Server registers its resources to the Mirror Server, and upon
registration a new mirror server resource is created on the Mirror Server
with a container (mirror representation) for the original server
representation.
➢ The original CoAP Server updates the mirror representation either
periodically or when the representation changes.
➢ A CoAP Client that retrieves the mirror representation receives the latest
updated representation from the original CoAP Server. The Mirror Server is
useful when the CoAP Server is not always available for direct access.
➢ An example of such a CoAP Server is one that resides on a real device
whose communication capabilities are turned off in order to preserve
energy, e.g. battery- powered radio devices whose radio and/or processor
goes to sleep mode.
➢ Typically, a Mirror Server is hosted on a device or machine that is always available.
➢ The IETF CoRE workgroup has included the fundamentals of a mapping
process between HTTP and CoAP in the IETF CoAP specification as well
as a set of guidelines for the interworking between HTTP and CoAP.
➢ The main is the different transport protocols used by the HTTP and CoAP:
HTTP uses TCP while CoAP uses UDP.
➢ The guidelines focus more on the HTTP-to-CoAP proxy and recommend
addressing schemes (e.g. how to map a CoAP resource address to an
HTTP address), mapping between HTTP and CoAP response codes,
mapping between different media types carried in the HTTP/CoAP
payloads, etc.
➢ HTTP Client sends an HTTP request to a CoAP server (Figure 6.9a)
through a Gateway Device hosting an HTTP-CoAP Cross Proxy.
➢ The Gateway Device connects to the Internet via an Ethernet cable using a
LAN, and on the CoAP side the CoAP server resides on a Sensor/Actuator
(SAN) based on the IEEE 802.15.4 PHY/MAC.
➢ The HTTP request needs to include two addresses, one for reaching the
Cross Proxy and one for reaching the specific CoAP Server in the SAN.
➢ The request is in plain text format and contains the method (GET). It
traverses the IPv4 stack of the client, reaches the gateway, traverses the

Page 12

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

IPv4 stack of the gateway and reaches the Cross proxy.


➢ The request is translated to a CoAP request (binary format) with a
destination CoAP resource coap://s.coap.example.com/foo, and it is
dispatched in the CoAP stack of the gateway, which sends it over the SAN
to the end device.
➢ A response is sent from the end device and follows the reverse path in the

SAN in order to reach the gateway.


➢ The Cross proxy translates the CoAP response code to the corresponding
HTTP code, transforms the included media, creates the HTTP response,
and dispatches it to the HTTP client.

2. IoT Reference Architecture

➢ Architecture Reference Model (ARM) consists of two main parts:


1. a Reference model
2. a Reference Architecture.
➢ The foundation of an IoT Reference Architecture description is an IoT reference
model.
➢ A System Architecture is a communication tool for different stakeholders of the
system.
➢ Developers, component and system managers, partners, suppliers, and
customers have different views of a single system based on their
Page 13

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

requirements and their specific interactions with the system.


➢ The high-level abstraction is called Reference Architecture as it serves as a
reference for generating concrete architectures and actual systems, as
shown in the Figure 7.2.

➢ Concrete architectures are instantiations of rather abstract and high-level


Reference Architectures.
➢ A Reference Architecture captures the essential parts of an architecture,
such as design principles, guidelines, and required parts (such as entities),
to monitor and interact with the physical world for the case of an IoT
Reference Architecture.

➢ A concrete architecture can be further elaborated and mapped into real


world components by designing, building, engineering, and testing the
different components of the actual system.
Page 14

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

➢ The general essentials out of multiple concrete architectures can then are
aggregated, and contribute to the evolution of the Reference Architecture.

➢ It has two types of Architecture:


Three Layered Architecture
Five Layered Architecture

Three Layer Architectures

➢ It has three layers, namely, the perception, network, and application layers.

(i) The perception layer is the physical layer, which has sensors for
sensing and gathering information about the environment. It senses some
physical parameters or identifies other smart objects in the environment.
(ii) The network layer is responsible for connecting to other smart things,
network devices, and servers. Its features are also used for transmitting and
processing sensor data.
(iii) The application layer is responsible for delivering application specific
services to the user. It defines various applications in which the Internet of
Things can be deployed, for example, smart homes, smart cities, and smart
health.

➢ The three-layer architecture defines the main idea of the Internet of Things,
but it is not sufficient for research on IoT because research often focuses
on finer aspects of the Internet of Things.

Five Layer Architectures

➢ The five layers are perception, transport, processing, application, and business
layers.
➢ The role of the perception and application layers is the same as the
architecture with three layers. We outline the function of the remaining three
layers.
(i) The transport layer transfers the sensor data from the perception layer
to the processing layer and vice versa through networks such as wireless,
3G, LAN, Bluetooth, RFID, and NFC.
(ii) The processing layer is also known as the middleware layer. It stores,
analyzes, and processes huge amounts of data that comes from the
transport layer. It can manage and provide a diverse set of services to the
lower layers. It employs many technologies such as databases, cloud
computing, and big data processing modules.
(iii) The business layer manages the whole IoT system, including
applications, business and profit models, and users’ privacy.
Page 15

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

➢ The layers are :


✓ Client/external communications - Web/Portal, Dashboard, APIs
✓ Event processing and analytics (including data storage)
✓ Aggregation/bus layer – ESB and message broker
✓ Relevant transports - MQTT/HTTP/XMPP/CoAP/AMQP, etc.
✓ Devices
➢ The cross-cutting layers are :
✓ Device manager
✓ Identity and access management

A. The Device Layer


➢ The bottom layer of the architecture is the device layer.
➢ Devices can be of various types, but in order to be considered as IoT
devices, they must have some communications that either indirectly or
directly attaches to the Internet.
➢ Examples of direct connections are :
• Arduino with Arduino Ethernet connection
• Arduino Yun with a Wi-Fi connection
• Raspberry Pi connected via Ethernet or Wi-Fi
• Intel Galileo connected via Ethernet or Wi-Fi Examples of indirectly
connected device include
• ZigBee devices connected via a ZigBee gateway
• Bluetooth or Bluetooth Low Energy devices connecting via a mobile phone
• Devices communicating via low power radios to a Raspberry Pi
➢ Each device typically needs an identity.
➢ The identity may be one of the following:
• A unique identifier (UUID) burnt into the device
• A UUID provided by the radio subsystem (e.g. Bluetooth identifier, Wi-
Fi MAC address)
Page 16

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

• An OAuth2 Refresh/Bearer Token


• An identifier stored in nonvolatile memory such as EEPROM

B. The Communications Layer

• The communication layer supports the connectivity of the devices.


• There are multiple potential protocols for communication between the
devices and the cloud.

➢ The most well known three potential protocols are :

• HTTP/HTTPS (and RESTful approaches on those)


• MQTT 3.1/3.1.1
• Constrained application protocol (CoAP)

➢ HTTP supports many libraries. Because it is a simple textbased protocol,


many small devices such as 8-bit controllers can only partially support the .
➢ The larger 32-bit based devices can utilize full HTTP client libraries that
properly implement the whole protocol.
➢ MQTT solve issues in embedded systems and SCADA.
➢ MQTT is a publish-subscribe messaging system based on a broker model.
The protocol has a very small overhead.
➢ It is designed to support lossy and intermittently connected networks.
➢ MQTT was designed to flow over TCP.
➢ In addition there is an associated specification designed for ZigBee-style
networks called MQTT-SN (Sensor Networks).
➢ CoAP is a protocol from the IETF that is designed to provide a RESTful
application protocol modeled on HTTP semantics. CoAP is a more
traditional client-server approach
➢ CoAP is designed to be used over UDP.

C. The Aggregation/Bus Layer

➢ This layer aggregates and brokers communications.


➢ This is an important layer for three reasons:

1. The ability to support an HTTP server and/or an MQTT broker to talk to the
devices

2.The ability to aggregate and combine communications from different


devices and to route communications to a specific device (possibly via a
gateway)

3.The ability to bridge and transform between different protocols, e.g. to


offer HTTP based APIs that are mediated into an MQTT message going to
the device.

Page 17

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

➢ The bus layer may also provide some simple correlation and mapping
from different correlation models (e.g. mapping a device ID into an owner’s
ID or vice-versa).
➢ It must be able to act as an OAuth2 Resource Server (validating Bearer
Tokens and associated resource access scopes).
➢ It must also be able to act as a policy enforcement point (PEP) for policy-based
access.

D. The Event Processing And Analytics Layer

➢ This layer takes the events from the bus and provides the ability to process
and act upon these events.
➢ A core capability here is the requirement to store the data into a database.
➢ It has the following approaches:
• Highly scalable, column-based data storage for storing events
• Map-reduce for long-running batch-oriented processing of data
• Complex event processing for fast in-memory processing and near real-
time reaction and autonomic actions based on the data and activity of
devices and other systems

E. Client/External Communications Layer

➢ The reference architecture needs to provide a way for these devices to


communicate outside of the device-oriented system.
➢ This includes three main approaches.

• Firstly, we need the ability to create web-based front-ends and portals that
interact with devices and with the event-processing layer.

• Secondly, we need the ability to create dashboards that offer views into
analytics and event processing.
• Finally, we need to be able to interact with systems outside this network
using machine-to-machine communications (APIs).

➢ The API management layer provides three main functions:


• The first is that it provides a developer-focused portal where developers
can find, explore, and subscribe to APIs from the system. There is also
support for publishers to create, version, and manage the available and
published APIs;

• The second is a gateway that manages access to the APIs, performing


access control checks (for external requests) as well as throttling usage
based on policies. It also performs routing and load-balancing;

• The final aspect is that the gateway publishes data into the analytics layer
where it is stored as well as processed to provide insights into how the APIs
are used.

Page 18

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

G. Device Management

➢ Device management (DM) is handled by two components.


➢ A server-side system (the device manager) communicates with devices
via various protocols and provides both individual and bulk control of
devices.
➢ It also remotely manages software and applications deployed on the device.
➢ It can lock and/or wipe the device if necessary.
➢ The device manager works in conjunction with the device management agents.
➢ There are multiple different agents for different platforms and device types.
➢ The device manager also needs to maintain the list of device identities and
map these into owners.
➢ It must also work with the identity and access management layer to
manage access controls over devices.
➢ There are three levels of device: non-managed, semi-managed and fully
managed (NM, SM, FM).
➢ A full DM agent supports:
• Managing the software on the device
• Enabling/disabling features of the device (e.g. camera, hardware, etc.)
• Management of security controls and identifiers
• Monitoring the availability of the device
• Maintaining a record of the device’s location if available

H. Identity and Access Management

➢ The final layer is the identity and access management layer.


➢ This layer needs to provide the following services:

• OAuth2 token issuing and validation


• Other identity services including SAML2 SSO and OpenID Connect
support for identifying inbound requests from the Web layer

• XACML PDP

• Directory of users (e.g. LDAP)

• Policy management for access control (policy control point)

Page 19

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

UNIT III - IoT PROTOCOLS AND TECHNOLOGY


SCADA and RFID Protocols - BACnet Protocol -Zigbee Architecture - 6LowPAN - CoAP
-Wireless Sensor Structure–Energy Storage Module–Power Management Module–RF
Module–Sensing Module

1. SCADA and RFID Protocols

SCADA:
SCADA (supervisory control and data acquisition) is a category of software applications for
controlling industrial processes, which is the gathering of data in real time from remote
locations in order to control equipment and conditions. SCADA provides organizations with
the tools needed to make and deploy data-driven decisions regarding their industrial
processes.
SCADA PROTOCOL:
Industrial automation has a variety of vertical markets and there are also many types of
SCADAs. IEEE created a standard specification, called Std C37.1™, for SCADA and
automation systems [116] in 2007, targeting mostly power SCADA applications. It’s
recognized in the specification that in recent years, network-based industrial automation
has greatly evolved with the use of intelligent electronic devices (IEDs), or IoT devices in
our terms, in substations and power stations. The processing is now distributed, and
functions that used to be done at the control center can now be done by the IED, that is,
M2M between devices. Despite the fact that many functions can be moved to the IED,
utilities still need a master station, the IoT platform, for the operation of the power system.
Due to the restructuring of the electric industry, traditional vertically integrated electric
utilities are replaced by many entities such as GENCO (Generation Company), TRANSCO
(Transmission Company), DISCO (Distribution Company), ISO (independent system
operator), RTO (regional transmission organization), and so forth. To fulfill their role, each
of these entities needs a control center, that is, a substation, to receive and process data
and take appropriate control actions.

Page 20

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Scenario showing integrated SCADA system to IoT

OPC, which stands for Object Linking and Embedding (OLE) for Process Control, is the
original name for a standard specification developed in 1996 by an industrial automation
industry task force. The standard specifies the communication of real-time plant data
between control devices from different manufacturers.
OPC was designed to provide a common bridge for Windows-based software applications
and process control hardware. Standards define consistent methods of accessing field
data from plant floor devices. This method remains the same regardless of the type and
source of data. An OPC server for one hardware device provides the same methods for an
OPC client to access its data as each and every other OPC server for that same or
another hardware device. The aim was to reduce the amount of duplicated effort required
from hardware manufacturers and their software partners, and from the SCADA and other
HMI producers, in order to interface the two. When a hardware manufacturer had
developed their OPC server for the new hardware device, their work was done to allow
anyone to access their device; and when the SCADA producer had developed their OPC
client, their work was done to allow access to any hardware, existing or yet to be created,
with an OPC-compliant server.
OPC has achieved great success in many application areas, most of them closely related
to or part of IoT applications. However, OPC’s success story is accompanied by some
caveats. For example, standard OPC DA (data access) is based on Microsoft’s COM and
DCOM technology and is consequently restricted to the Windows operating system. In
addition, DCOM communication is easily blocked by firewalls that prevent OPC clients
from accessing data over a wide-area network and the World Wide Web. New approaches,
such as XML-DA and United Architecture (UA) [234], have been developed to make OPC
technology available on other platforms or accessible by other systems.
The RFID protocols and data formats are relatively well defined, mostly by EPCglobal, and
unified compared with protocols and formats of the other three pillars of IoT. The RFID
protocols (such as PML, Object Naming Service [ONS], Edgeware, EPC Information

Page 21

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Service [EPCIS], Application Level Event [ALE], etc.) have been described in the previous
chapters, so we will talk only about protocols for the related contactless smart cards here.

RFID:
RFID or Radio Frequency Identification is an automatic identification method that uses
wireless non-contact radio frequency waves in which data is digitally encoded in RFID tags
or smart labels which can be read by reader through radio waves.
RFID PROTOCOL:

The RFID protocols and data formats are relatively well defined, mostly by EPC global,
and unified compared with protocols and formats of the other three pillars of IoT. The RFID
protocols (such as PML, Object Naming Service [ONS], Edgeware, EPC Information
Service [EPCIS], Application Level Event [ALE], etc.) have been described in the previous
chapters, so we will talk only about protocols for the related contactless smart cards here.
The smart cards with contactless interfaces (RFID is a subset) are becoming increasingly
popular for payment and ticketing applications such as mass transit and stadiums.
The standard for contactless smart card communications is ISO/IEC 14443. It defines two
types of contactless cards (A and B) and allows for communications at distances up to
10 cm. An alternative standard for contactless smart cards is ISO/IEC 15693, which allows
communications at distances up to 50 cm.
Working of RFID Protocol

Page 22

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

2. BACnet Protocol

A data communication protocol that is used to build an automated control network,


is known as BACnet or Building Automation Control Network. This data communication
protocol is both an ISO & ANSI standard used for interoperability between cooperating
building automation devices. Bacnet Protocol includes a set of rules for governing the data
exchange on a computer network that simply covers all from what type of cable to utilize,
to form a particular command or request in a normal way.
To attain interoperability across a broad spectrum of equipment, the BACnet
specification includes three major parts. Primary, Secondary, and tertiary. So the primary
part defines a technique to represent any kind of building automation apparatus in a
normal way.
The secondary part describes messages that can be transmitted across a network
of computers to check and manage such equipment. The final part describes a set of
suitable LANs which are used for conveying BACnet communications.
Bacnet Protocol Architecture

The BACnet protocol architecture is predominately restricted to lighting controls,


HVAC & gateways. This protocol highlights lightweight and efficient communication which
is optimized for short messages, small networks, and inter-networks.

BACnet protocol architecture is a collapsed architecture that matches to 4-layers of


the OSI model. The four layers in the BACnet architecture mainly include Application,
Network, Data Link & Physical. Even though, just the Network layer & Application layer are
simply BACnet.
The above architecture is the BACnet protocol stack which includes different layers
as shown in the diagram. This protocol is a collapsed version of the OSI stack. The
transport and session layers are not used. The application layer takes on the functions of
these two layers.

Page 23

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

BACnet Physical Layer


The upper layers of BACnet do not depend on the physical layer. So the Physical
layer of BACnet makes it feasible for BACnet to be executed on different networks. The
physical layers of BACnet have been specified with ARCNET, Ethernet, IP tunnels,
BACnet/IP, RS-232, RS485, and Lonworks/LonTalk. RS232 is for point-to-point
communication. RS485 supports up to 32 nodes with a distance of 1200 m at 76Kbps.
BACnet Protocol Link Layer
BACnet protocol is implemented directly with LonTalk or IEEE802.2 link layers. So it
specifies Point to Point (PTP) data link layer for RS232 connections. It specifies MS/TP
data link layer intended for RS-485 connections. The standard simply specifies BVLL
(BACnet Virtual Link Layer) which states all the services required through the BACnet
device at this link layer.
IP BACnet Virtual Link Layer encapsulates required control data in a header of
BACnet virtual link control information. Because of IP, BVLL, and BACnet protocol devices
can directly communicate over IP networks without the requirement of any router device.
BACnet protocol utilizes BBMD (BACnet broadcast management device) concept
which executes the required broadcast for the preferred link layer. So, the BACnet
broadcast message is changed into IP-based broadcast or multicast messages.
BACnet Network Layer
This layer simply specifies the required addresses of the network for routing.
BACnet network includes a minimum of one or above segments that are connected with
bridges once they utilize similar LAN technologies. If they utilize various LAN protocols
then they are connected through routers.
Application Layer
BACnet does not separate presentation as well as application layers. So it takes
care of reliability & sequencing or segmentation mechanisms generally connected with
both the session & transport layers. BACnet includes devices like objects to exchange
service primitives which are described with ASN.1 syntax & serialized with ASN.1 BER.
BACnet Security Layer
The concept of BACnet security can be understood easily with an example say
when BACnet device-A requests a session key from the key server for establishing secure
communication through device-B, then this key is transmitted to both the device-A &
device-B through the key server which is known as ‘SKab’. BACnet protocol uses 56-bit
DES encryption.

Advantages
The advantages of the Bacnet Protocol include the following.
• BACnet protocol is particularly designed for building automation as well as control
networks.
• It doesn’t depend on present LAN or WAN technologies.
• It is an American National Standard & a European pre-standard.

Page 24

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

• It is scalable completely from small single building applications to universal


networks of devices.
• The implementers of BACnet can securely include non-standard extensions as well
as enhancements without influencing existing interoperability.
• It is adopted by the most famous fire protection companies in both the USA &
Europe.
• It is supported by different chiller manufacturers like Dunham-Bush, Carrier,
McQuay, York & Trane.
• In real building control applications, this protocol has a proven track record.

Disadvantages
The disadvantages of the Bacnet Protocol include the following.
• The main drawback of the BACnet protocol was a compliant problem. So because of
this issue, the BTL (BACnet Testing Laboratories) was introduced in the year 2000.
BTL is compliance & and independent testing organization. The main intention of this
is to test the products of BACnet to verify compliance with the standard. Once
approved; the product will get the logo of BTL.
• The problems or net-worthy attacks which are widely found in this protocol are; Lack
of spoofing & authentication, DoS attacks, immobilized network connections, and lack
of encryption & write access over devices.

Applications
The use of Bacnet Protocol includes the following.
• The BACnet is used in HVAC applications, fire control lighting control, security,
alarm & interfacing to utility companies.
• This protocol was particularly designed for building automation as well as control
applications.
• This protocol is used to provide mechanisms, especially for automation devices for
exchanging data irrespective of the specific building service they perform.
• This protocol can be used by digital controllers, computers & application-specific
otherwise unitary controllers with equivalent effect.
• BACnet protocol was initially developed to develop interoperability between building
automation devices; however, its data descriptions, as well as flexible architecture,
will make it work within a broad range of control applications.
• This is an object-oriented protocol, so used to signify network-accessible control
equipment.

Page 25

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

3. Zigbee Architecture

ZigBee is a Personal Area Network task group with low rate task group 4. It is a
technology of home networking. ZigBee is a technological standard created for
controlling and sensing the network. As we know that ZigBee is the Personal Area
network of task group 4 so it is based on IEEE 802.15.4 and is created by Zigbee Alliance.

ZigBee is a standard that addresses the need for very low-cost implementation of Low
power devices with Low data rates for short-range wireless communications.

Types of ZigBee Devices:

• Zigbee Coordinator Device: It communicates with routers. This device is used for
connecting the devices.
• Zigbee Router: It is used for passing the data between devices.
• Zigbee End Device: It is the device that is going to be controlled.

General Characteristics of Zigbee Standard:

• Low Power Consumption


• Low Data Rate (20- 250 kbps)
• Short-Range (75-100 meters)
• Network Join Time (~ 30 msec)
• Support Small and Large Networks (up to 65000 devices (Theory); 240 devices
(Practically))
• Low Cost of Products and Cheap Implementation (Open Source Protocol)
• Extremely low duty cycle.
• 3 frequency bands with 27 channels.

Operating Frequency Bands (Only one channel will be selected for use in a network):

1. Channel 0: 868 MHz (Europe)


2. Channel 1-10: 915 MHz (the US and Australia)
3. Channel 11-26: 2.4 GHz (Across the World)

Page 26

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Zigbee Network Topologies:

• Star Topology (ZigBee Smart Energy): Consists of a coordinator and several end
devices, end devices communicate only with the coordinator.
• Mesh Topology (Self Healing Process): Mesh topology consists of one coordinator,
several routers, and end devices.
• Tree Topology: In this topology, the network consists of a central node which is a
coordinator, several routers, and end devices. the function of the router is to extend
the network coverage.

Architecture of Zigbee:

Zigbee architecture is a combination of

1. Application Layer
2. Network Layer
3. Medium Access Control Layer
4. Physical Layer

• Physical layer: The lowest two layers i.e the


physical and the MAC (Medium Access Control)
Layer are defined by the IEEE 802.15.4
specifications. The Physical layer is closest to the hardware and directly controls
and communicates with the Zigbee radio. The physical layer translates the data
packets in the over-the-air bits for transmission and vice-versa during the reception.

• Medium Access Control layer (MAC layer): The layer is responsible for the
interface between the physical and network layer. The MAC layer is also
responsible for providing PAN ID and also network discovery through beacon
requests.

• Network layer: This layer acts as an interface between the MAC layer and the
application layer. It is responsible for mesh networking.

• Application layer: The application layer in the Zigbee stack is the highest protocol
layer and it consists of the application support sub-layer and Zigbee device object. It
contains manufacturer-defined applications.

Channel Access:

1. Contention Based Method (Carrier-Sense Multiple Access With Collision


Avoidance Mechanism)
2. Contention Free Method (Coordinator dedicates a specific time slot to each device
(Guaranteed Time Slot (GTS)))

Zigbee Applications:
1. Home Automation
2. Medical Data Collection
3. Industrial Control Systems
4. meter reading system
5. light control system
Page 27

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

4. 6LowPAN
6LoWPAN is an IPv6 protocol, and It’s extended from is IPv6 over Low Power Personal
Area Network. As the name itself explains the meaning of this protocol is that this protocol
works on Wireless Personal Area Network i.e., WPAN.

WPAN is a Personal Area Network (PAN) where the interconnected devices are centered
around a person’s workspace and connected through a wireless medium. You can read
more about WPAN at WPAN. 6LoWPAN allows communication using the IPv6 protocol.
IPv6 is Internet Protocol Version 6 is a network layer protocol that allows communication to
take place over the network. It is faster and more reliable and provides a large number of
addresses.

6LoWPAN initially came into existence to overcome the conventional methodologies that
were adapted to transmit information. But still, it is not so efficient as it only allows for the
smaller devices with very limited processing ability to establish communication using one
of the Internet Protocols, i.e., IPv6. It has very low cost, short-range, low memory usage,
and low bit rate.

It comprises an Edge Router and Sensor Nodes. Even the smallest of the IoT devices can
now be part of the network, and the information can be transmitted to the outside world as
well. For example, LED Streetlights.

• It is a technology that makes the individual nodes IP enabled.

• 6LoWPAN can interact with 802.15.4 devices and also other types of devices on an
IP Network. For example, Wi-Fi.

• It uses AES 128 link layer security, which AES is a block cipher having key size of
128/192/256 bits and encrypts data in blocks of 128 bits each. This is defined in
IEEE 802.15.4 and provides link authentication and encryption.

Page 28

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Basic Requirements of 6LoWPAN:

1. The device should be having sleep mode in order to support the battery saving.
2. Minimal memory requirement.
3. Routing overhead should be lowered.

Features of 6LoWPAN:

1. It is used with IEEE 802.15,.4 in the 2.4 GHz band.


2. Outdoor range: ~200 m (maximum)
3. Data rate: 200kbps (maximum)
4. Maximum number of nodes: ~100

Advantages of 6LoWPAN:

1. 6LoWPAN is a mesh network that is robust, scalable, and can heal on its own.
2. It delivers low-cost and secure communication in IoT devices.
3. It uses IPv6 protocol and so it can be directly routed to cloud platforms.
4. It offers one-to-many and many-to-one routing.
5. In the network, leaf nodes can be in sleep mode for a longer duration of time.

Disadvantages of 6LoWPAN:

1. It is comparatively less secure than Zigbee.


2. It has lesser immunity to interference than that Wi-Fi and Bluetooth.
3. Without the mesh topology, it supports a short range.

Applications of 6LoWPAN:

1. It is a wireless sensor network.


2. It is used in home-automation,
3. It is used in smart agricultural techniques, and industrial monitoring.

Security and Interoperability with 6LoWPAN:

• Security: 6LoWPAN security is ensured by the AES algorithm, which is a link layer
security, and the transport layer security mechanisms are included as well.
• Interoperability: 6LoWPAN is able to operate with other wireless devices as well
which makes it interoperable in a network.

Page 29

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

5. CoAP
Constrained Application Protocol (COAP) is a client server-based protocol. With this
protocol, the COAP packet can be shared between different client nodes which are
commanded by the COAP server. The server is responsible to share the information
depending on its logic but has not acknowledged it. This is used with the applications
which support the state transfer model.

CoAP is a session layer protocol that provides the RESTful (HTTP) interface between
HTTP client and server. It is designed by IETF Constrained RESTful Environment (CoRE)
working group. It is designed to use devices on the same constrained network between
devices and general nodes on the Internet. CoAP enables low-power sensors to use
RESTful services while meeting their low power constraints. This protocol is specially built
for IoT systems primarily based on HTTP protocols.

This network is used within the limited network or in a constrained environment. The
whole architecture of CoAP consists of CoAP client, CoAP server, REST CoAP proxy, and
REST internet.

The data is sent from CoAP clients (such as smartphones, RFID sensors, etc.) to the
CoAP server and the same message is routed to REST CoAP proxy. The REST CoAP
proxy interacts outside the CoAP environment and uploads the data over REST internet.

Page 30

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

6. RF module

An RF module (short for radio-frequency module) is a (usually) small electronic


device used to transmit and/or receive radio signals between two devices. In an embedded
system it is often desirable to communicate with another device wirelessly. This wireless
communication may be accomplished through optical communication or through radio-
frequency (RF) communication. For many applications, the medium of choice is RF since it
does not require line of sight. RF communications incorporate a transmitter and a receiver.
They are of various types and ranges. Some can transmit up to 500 feet. RF modules are
typically fabricated using RF CMOS technology.

Types of RF modules
The term RF module can be applied to many different types, shapes and sizes of
small electronic sub assembly circuit board. It can also be applied to modules across a
huge variation of functionality and capability. RF modules typically incorporate a printed
circuit board, transmit or receive circuit, antenna, and serial interface for communication to
the host processor.
Most standard, well known types are covered here:
• transmitter module
• receiver module
• transceiver module
• system on a chip module.

Transmitter module

An RF transmitter module is a small PCB sub-assembly capable of transmitting a


radio wave and modulating that wave to carry data. Transmitter modules are usually
implemented alongside a microcontroller which will provide data to the module which can
be transmitted. RF transmitters are usually subject to regulatory requirements which
dictate the maximum allowable transmitter power output, harmonics, and band edge
requirements.
Receiver modules

An RF receiver module receives the modulated RF signal, and demodulates it.


There are two types of RF receiver modules: superheterodyne receivers and
superregenerative receivers. Superregenerative modules are usually low cost and low
power designs using a series of amplifiers to extract modulated data from a carrier wave.
Superregenerative modules are generally imprecise as their frequency of operation varies
considerably with temperature and power supply voltage. Superheterodyne receivers have
a performance advantage over superregenerative; they offer increased accuracy and
stability over a large voltage and temperature range. This stability comes from a fixed
crystal design which in the past tended to mean a comparatively more expensive product.
However, advances in receiver chip design now mean that currently there is little price
difference between superheterodyne and superregenerative receiver modules.

Page 31

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Transceiver modules

An RF transceiver module incorporates both a transmitter and receiver. The circuit


is typically designed for half-duplex operation, although full-duplex modules are available,
typically at a higher cost due to the added complexity.
System on a chip (SoC) module

An SoC module is the same as a transceiver module, but it is often made with an
onboard microcontroller. The microcontroller is typically used to handle radio data
packetisation or managing a protocol such as an IEEE 802.15.4 compliant module. This
type of module is typically used for designs that require additional processing for
compliance with a protocol when the designer does not wish to incorporate this processing
into the host microcontroller.
Wireless protocols used in RF modules
RF modules, especially SoC modules, are frequently used to communicate
according to a pre-defined wireless standard, including:
• Zigbee
• Bluetooth Low Energy
• Wi-Fi
• IEEE 802.15.4
• Z-Wave

Typical applications
• Vehicle monitoring
• Remote control
• Telemetry
• Small-range wireless network
• Wireless meter reading
• Access control systems
• Wireless home security systems
• Area paging
• Industrial data acquisition system
• Radio tags reading
• RF contactless smart cards
• Wireless data terminals
• Wireless fire protection systems
• Biological signal acquisition
• Hydrological and meteorological monitoring
• Robot remote control
• Wireless data transmissions
• Digital video/audio transmission

Page 32

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

UNIT IV - CLOUD ARCHITECTURE BASICS


The Cloud types; IaaS, PaaS, SaaS.- Development environments for service development;
Amazon, Azure, Google Appcloud platform in industry

1. Infrastructure as a Service (IaaS)

Iaas is also known as Hardware as a Service (HaaS). It is one of the layers of the
cloud computing platform. It allows customers to outsource their IT infrastructures such
as servers, networking, processing, storage, virtual machines, and other resources.
Customers access these resources on the Internet using a pay-as-per use model.

In traditional hosting services, IT infrastructure was rented out for a specific period
of time, with pre-determined hardware configuration. The client paid for the configuration
and time, regardless of the actual use. With the help of the IaaS cloud computing platform
layer, clients can dynamically scale the configuration to meet changing requirements and
are billed only for the services actually used.

IaaS cloud computing platform layer eliminates the need for every organization to
maintain the IT infrastructure.

IaaS is offered in three models: public, private, and hybrid cloud. The private cloud
implies that the infrastructure resides at the customer-premise. In the case of public
cloud, it is located at the cloud computing platform vendor's data center, and the hybrid
cloud is a combination of the two in which the customer selects the best of both public
cloud or private cloud.

IaaS provider provides the following services -

1. Compute: Computing as a Service includes virtual central processing units and


virtual main memory for the Vms that is provisioned to the end- users.
2. Storage: IaaS provider provides back-end storage for storing files.
3. Network: Network as a Service (NaaS) provides networking components such as
routers, switches, and bridges for the Vms.
4. Load balancers: It provides load balancing capability at the infrastructure layer.

Page 33

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Advantages of IaaS cloud computing layer


There are the following advantages of IaaS computing layer -

1. Shared infrastructure
IaaS allows multiple users to share the same physical infrastructure.

2. Web access to the resources


Iaas allows IT users to access resources over the internet.

3. Pay-as-per-use model
IaaS providers provide services based on the pay-as-per-use basis. The users are
required to pay for what they have used.

4. Focus on the core business


IaaS providers focus on the organization's core business rather than on IT
infrastructure.

5. On-demand scalability
On-demand scalability is one of the biggest advantages of IaaS. Using IaaS, users
do not worry about to upgrade software and troubleshoot the issues related to hardware
components.

Disadvantages of IaaS cloud computing layer

1. Security
Security is one of the biggest issues in IaaS. Most of the IaaS providers are not able
to provide 100% security.

2. Maintenance & Upgrade


Although IaaS service providers maintain the software, but they do not upgrade the
software for some organizations.

3. Interoperability issues
It is difficult to migrate VM from one IaaS provider to the other, so the customers
might face problem related to vendor lock-in.

Some important point about IaaS cloud computing layer


IaaS cloud computing platform cannot replace the traditional hosting method, but it
provides more than that, and each resource which are used are predictable as per the
usage.
IaaS cloud computing platform may not eliminate the need for an in-house IT
department. It will be needed to monitor or control the IaaS setup. IT salary expenditure
might not reduce significantly, but other IT expenses can be reduced.
Breakdowns at the IaaS cloud computing platform vendor's can bring your business
to the halt stage. Assess the IaaS cloud computing platform vendor's stability and
finances. Make sure that SLAs (i.e., Service Level Agreement) provide backups for data,
hardware, network, and application failures. Image portability and third-party support is a
plus point.
The IaaS cloud computing platform vendor can get access to your sensitive data.
So, engage with credible companies or organizations. Study their security policies and
precautions.

Page 34

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

2. Platform As A Service (PaaS)

Platform-as-an-service (PaaS) is distributed computing model where an outsider supplier


appropriates equipment and programming instruments to clients over Internet. As rule,
these are required for application improvement. PaaS supplier has equipment and
programming on its own framework. Therefore, it liberates designers from introducing
inside equipment and programming to create or run another application. Press device is
utilized in basic and helpful manner. Clients, as rule, pay on for each utilization premise.
An association can step in for PAS that considers potential cost investment funds by
utilizing nearby alternatives.

Different PaaS Services :

• Advancement group support


• Application plan and improvement
• Application testing and arrangement
• Web administration mix
• Information security
• Database Integration

PaaS Types : Various sorts of PaaS are presently accessible to engineers. They are :

1. Public PaaS
2. Private PaaS
3. Hybrid PaaS
4. Communication PaaS
5. Mobile PaaS
6. Open PaaS

These are explained as following below.


1. Public PaaS – Is appropriate for use in public cloud. Public PaaS permits client to
control programming extension, while cloud supplier deals with circulation of all
other key IT segments expected to have applications, including working
frameworks, databases, workers, and capacity framework systems.
Public dice merchants offer middleware, which permits engineers to introduce,
design, and control workers and databases without need to introduce framework.
Therefore, Public Pass and Infrastructure (IaaS) run all together. PaaS with
exercises on merchant’s IaaS foundation using public cloud. Tragically, this implies
client will adhere to similar public cloud choice that they would prefer not to utilize.
Some little and medium-sized organizations have received public pass, however
huge enterprises and associations have wouldn’t acknowledge it because of their
cozy relationship with public cloud. This is principally consequence of an enormous
number of guidelines and consistence issues on organization application
advancement in public cloud.

2. Private PaaS – Plans to give dexterity of public pass while keeping up security,
consistence, advantages and ease of private security community. A private pass is
normally circulated as gadget or programming in client’s firewall, which is regularly
kept up in server farm on organization’s premises. A private PaaS can be created
on framework and works inside organization’s particular private cloud.
Private dice permit an association to all more likely serve designers, improve inside

Page 35

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

asset usage, and decrease expensive cloud entrance that numerous organizations
face. Likewise, private dice permit designers to run and deal with their
organization’s applications in consistence with severe security and protection
necessities.

3. Hybrid PaaS – Consolidates organizations with Public PaaS and Private PaaS,
with accommodation of unbounded limit offered by Public PaaS and cost-adequacy
of having inside framework in Private PaaS. Hybrid PaaS utilizes hybrid cloud.

4. Communication PaaS (CPaaS) – Cloud-based stage that permits engineers to add


ongoing communication to their application without requirement for back-end
foundation and interfaces. Regularly, ongoing communication happens in
applications fabricated explicitly for these assignments. Models are Skype,
FaceTime, WhatsApp and conventional telephones.
CPaaS gives a completely evolved system to making ongoing communication
highlights without requirement for engineer to assemble their own structure,
including standard-based application programming interfaces, programming
apparatuses, prebuilt applications, and test code.
CPaaS suppliers help clients in improvement procedure by offering help and item
documentation. A few suppliers offer programming advancement packs just as
libraries that help assemble applications on different work area and mobile stages.
Improvement groups picking to utilize CPaaS spares time for foundation, HR and
market.

5. Mobile PaaS (MPaaS) – Is an installment incorporated improvement condition for


mobile application setup. In MPaaS, coding abilities are not required. MPaaS is
circulated through an internet browser and for most part bolsters public cloud,
private cloud and on-premises stockpiling. Administration is normally rented at a
month to month cost, contingent upon quantity of gadgets and offices bolstered.

MPaaS ordinarily gives an article situated intuitive interface that permits


clients to disentangle improvement of HTML5 or local applications through direct
access to gadget’s highlights, for example, GPS, sensor, camera and amplifier. It
frequently underpins different mobile OS.

6. Open PaaS – Is a free, open-source, business-situated community oriented stage


that is alluring on all gadgets and gives a helpful web application including
schedule, contacts and mail applications. It is intended to permit clients to
immediately run new applications. One of its assets is to create innovation sent for
big business synergistic applications, particularly half and half mists.

Page 36

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

3. Software as a Service (SaaS)

SaaS is also known as "On-Demand Software". It is a software distribution model


in which services are hosted by a cloud service provider. These services are available to
end-users over the internet so, the end-users do not need to install any software on their
devices to access these services.

There are the following services provided by SaaS providers -

Business Services - SaaS Provider provides various business services to start-up the
business. The SaaS business services include ERP (Enterprise Resource Planning), CRM
(Customer Relationship Management), billing, and sales.

Document Management - SaaS document management is a software application offered


by a third party (SaaS providers) to create, manage, and track electronic documents.

Example: Slack, Samepage, Box, and Zoho Forms.

Social Networks - As we all know, social networking sites are used by the general public,
so social networking service providers use SaaS for their convenience and handle the
general public's information.

Mail Services - To handle the unpredictable number of users and load on e-mail services,
many e-mail providers offering their services using SaaS.

Advantages of SaaS cloud computing layer

1) SaaS is easy to buy

SaaS pricing is based on a monthly fee or annual fee subscription, so it allows


organizations to access business functionality at a low cost, which is less than licensed
applications.

Page 37

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

Unlike traditional software, which is sold as a licensed based with an up-front cost
(and often an optional ongoing support fee), SaaS providers are generally pricing the
applications using a subscription fee, most commonly a monthly or annually fee.

2. One to Many

SaaS services are offered as a one-to-many model means a single instance of the
application is shared by multiple users.

3. Less hardware required for SaaS

The software is hosted remotely, so organizations do not need to invest in additional


hardware.

4. Low maintenance required for SaaS

Software as a service removes the need for installation, set-up, and daily maintenance for
the organizations. The initial set-up cost for SaaS is typically less than the enterprise
software. SaaS vendors are pricing their applications based on some usage parameters,
such as a number of users using the application. So SaaS does easy to monitor and
automatic updates.

5. No special software or hardware versions required

All users will have the same version of the software and typically access it through the web
browser. SaaS reduces IT support costs by outsourcing hardware and software
maintenance and support to the IaaS provider.

6. Multidevice support

SaaS services can be accessed from any device such as desktops, laptops, tablets,
phones, and thin clients.

7. API Integration

SaaS services easily integrate with other software or services through standard APIs.

8. No client-side installation

SaaS services are accessed directly from the service provider using the internet
connection, so do not need to require any software installation.

Disadvantages of SaaS cloud computing layer

1) Security

Actually, data is stored in the cloud, so security may be an issue for some users. However,
cloud computing is not more secure than in-house deployment.

Page 38

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

2) Latency issue

Since data and applications are stored in the cloud at a variable distance from the end-
user, there is a possibility that there may be greater latency when interacting with the
application compared to local deployment. Therefore, the SaaS model is not suitable for
applications whose demand response time is in milliseconds.

3) Total Dependency on Internet

Without an internet connection, most SaaS applications are not usable.

4) Switching between SaaS vendors is difficult

Switching SaaS vendors involves the difficult and slow task of transferring the very large
data files over the internet and then converting and importing them into another SaaS also.

Popular SaaS Providers

Page 39

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

UNIT V - IOT PROJECTS ON RASPBERRY PI


Building IoT with RASPBERRY Pi- Creating the sensor project - Preparing Raspberry Pi -
Clayster libraries – Hardware Interacting with the hardware - Interfacing the hardware-
Internal representation of sensor values - Persisting data - External representation of
sensor values - Exporting sensor data

1. Building IoT with RASPBERRY Pi

The Internet of Things (IoT)

The Internet of Things (IoT) is a scenario in which objects, animals or people are provided
with single identifiers and the capability to automatically transfer and the capability to
automatically transfer data more to a network without requiring human-to-human or
human-to-computer communication.

Raspberry Pi

• The Raspberry Pi is a very cheap computer that runs Linux, but it also provides a
set of GPIO (general purpose input/output) pins that allow you to control electronic
components for physical computing and explore the Internet of Things (IoT).
• Raspberry Pi was basically introduced in 2006.
• It is particularly designed for educational use and intended for Python.
• A Raspberry Pi is of small size i.e., of a credit card sized single board computer,
which is developed in the United Kingdom(U.K) by a foundation called Raspberry
Pi.
• There have been three generations of Raspberry Pis: Pi 1, Pi 2, and Pi 3
• The first generation of Raspberry (Pi 1) was released in the year 2012, that has two
types of models namely model A and model B.
• Raspberry Pi can be plugged into a TV, computer monitor, and it uses a standard
keyboard and mouse.
• It is user friendly as can be handled by all the age groups.
• It does everything you would expect a desktop computer to do like word-processing,
browsing the internet spreadsheets, playing games to playing high definition videos.
• All models feature on a broadcom system on a chip (SOC), which includes chip
graphics processing unit GPU(a Video Core IV), an ARM compatible and CPU.
• The CPU speed ranges from 700 MHz to 1.2 GHz for the Pi 3 and on board
memory range from 256 MB to 1 GB RAM.
• An operating system is stored in the secured digital SD cards and program memory
in either the MicroSDHC or SDHC sizes.
• Most boards have one to four USB slots, composite video output, HDMI and a 3.5
mm phone jack for audio. Some models have WiFi and Bluetooth.
• Several generations of Raspberry Pis have been released.
• All models feature a Broadcom system on a chip (SoC) with an integrated ARM-
compatible central processing unit (CPU) and on-chip graphics processing unit
(GPU).

Page 40

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

• Processor speed ranges from 700 MHz to 1.4 GHz for the Pi 3 Model B+ or 1.5
GHz for the Pi 4; on-board memory ranges from 256 MB to 1 GB with up to 4 GB
available on the Pi 4 random-access memory (RAM).
• Secure Digital (SD) cards in MicroSDHC form factor (SDHC on early models) are
used to store the operating system and program memory.
• The boards have one to five USB ports. For video output, HDMI and composite
video are supported, with a standard 3.5 mm tip-ring-sleeve jack for audio output.
• Lower-level output is provided by a number of GPIO pins, which support common
protocols like I2C. The B-models have an 8P8C Ethernet port and the Pi 3 and Pi
Zero W have on-board Wi-Fi and Bluetooth.

Components and Peripherals

• Voltages: Two 5V pins and two 3V3 pins are present on the board, as well as a
number of ground pins (0V). The remaining pins are all general purpose 3V3 pins
• A GPIO pin designated as an output pin can be set to high (3V3) or low (0V). A GPIO
pin designated as an input pin can be read as high (3V3) or low (0V).
• Processor & RAM: Raspberry based on ARM11 processor. Latest version supports
700MHz processor and 512MB SDRAM. The Central processing unit is the brain of
the raspberry pi board and that is responsible for carrying out the instructions of the
computer through logical and mathematical operations.
• Ethernet: The Ethernet port of the raspberry pi is the main gateway for
communicating with additional devices. The raspberry pi Ethernet port is used to plug
your home router to access the internet.
• USB Ports: It has 2 USB ports. USB port provide current upto 100mA. For connecting
devices that draw current more than 100mA, an external USB powered hub is
required.

Page 41

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

• Ethernet Port: It has standard RJ45 Ethernet port. Connect Ethernet cable or USB
wifi adapter to provide internet connectivity.
• HDMI Output: It supports both audio and video output. Connect raspberry Pi to
monitor using HDMI cable.
• Composite video Output: Raspberry comes with a composite video output with an
RCA jack that supports both PAL and NTSC video output.
• Audio Output: It has 3.5mm audio output jack. This audio jack is used for providing
audio output to old television along with RCA jack for video.
• GPIO Pins: It has a number of general purpose input/output pins. These pins are
used to connect other electronic components. For example, you can connect it to the
temperature sensor to transmit digital data.
• Display Serial Interface (DSI): DSI interface are used to connect an LCD panel to
Raspberry PI.
• Cameral Serial Interface(CSI): CSI interface are used to connect a camera module
to Raspberry PI.
• SD Card slot: Raspberry does not have built in OS and storage. Plug in an SD card
loaded with Linux to SD card slot.
• Power Input: Raspberry has a micro USP connector for power input.
• Memory: The raspberry pi model A board is designed with 256MB of SDRAM and
model B is designed with 51MB.Raspberry pi is a small size PC compare with other
PCs. The normal PCs RAM memory is available in gigabytes. But in raspberry pi
board, the RAM memory is available more than 256MB or 512MB
• Status LEDs: Raspberry has 5 status LEDs.

Status LED Function


ACT SD card Access
PWR 3.3V power is present
FDX Full duplex LAN Connected
LNK Link/Network Activity
100 100 Mbit LAN connected

Raspberry PI Interfaces:

• It supports SPI, serial and I2C interfaces for data transfer.

• Serial : Serial Interface on Raspberry has receive(Rx) and Transmit(Tx) pins for
communication with serial peripherals.

• SPI: Serial Peripheral Interface (SPI) is a synchronous serial data protocol used for
communicating with one or more peripheral devices. In an SPI connection, there is
one master device and one or more peripheral devices. There are 5 pins Raspberry

Page 42

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

for SPI interface.


o MISO(Master In Slave Out): Master line for sending data to the peripherals.
o MOSI(Master Out Slave In): Slave Line for sending data to the master.
o SCK(Serial Clock): Clock generated by master to synchronize data transmission.
o CE0(Chip Enable 0): To enable or disable devices.
o CE1(Chip Enable 1): To enable or disable devices.

• I2C: I2C Interface pins are used to connect hardware modules. I2C interface allows
synchronous data transfer with two pins: SDA(data line) and SCL (Clock Line)

Features of Raspberry PPI

1. Where the system processing is huge. They can process high end programs for
applications like Weather Station, Cloud server, gaming console etc. With 1.2GHz
clock speed and 1 GB RAM RASPBERRY PI can perform all those advanced
functions.
2. RASPBERRY PI 3 has wireless LAN and Bluetooth facility by which you can setup
WIFI HOTSPOT for internet connectivity.
3. RASPBERRY PI had dedicated port for connecting touch LCD display which is a
feature that completely omits the need of monitor.
4. RASPBERRY PI also has dedicated camera port so one can connect camera without
any hassle to the PI board.
5. RASPBERRY PI also has PWM outputs for application use. 6. It supports HD steaming

Applications

• Hobby projects.
• Low cost PC/tablet/laptop
• IoT applications
• Media center
• Robotics
• Industrial/Home automation
• Server/cloud server
• Print server
• Security monitoring
• Web camera
• Gaming
• Wireless access point

Page 43

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

2. Creating the sensor project

Our first project will be the sensor project. Since it is the first one, we will cover it in
more detail than the following projects in this book. A majority of what we will explore will
also be reutilized in other projects as much as possible. The development of the sensor is
broken down into six steps, and the source code for each step can be downloaded
separately. You will find a simple overview of this here:

1. Firstly, you will set up the basic structure of a console application.

2. Then, you will configure the hardware and learn to sample sensor values and maintain a
useful historical record.

3. After adding HTTP server capabilities as well as useful web resources to the project,
you will publish the sensor values collected on the Internet.

4. You will then handle persistence of sampled data in the sensor so it can resume after
outages or software updates.

5. The next step will teach you how to add a security layer, requiring user authentication to
access sensitive information, on top of the application.

6. In the last step, you will learn how to overcome one of the major obstacles in the
request/response pattern used by HTTP, that is, how to send events from the server to the
client.

3. Preparing Raspberry Pi

In our examples, we will use Model B with the following:


• An SD card with the Raspbian operating system installed
• A configured network access, including Wi-Fi, if used
• User accounts, passwords, access rights, time zones, and so on, all configured
correctly
All our examples will be developed on a remote PC (for instance, a normal working
laptop) using C# (C + + + + if you like to think of it this way), as this is a modern
programming language that allows us to do what we want to do with IoT. It also allows us
to interchange code between Windows, Linux, Macintosh, Android, and iOS platforms.

Once a project is compiled, executable files are deployed to the corresponding


Raspberry Pi (or Raspberry Pi boards) and then executed. Since the code runs on .NET,
any language out of the large number of CLI-compatible languages can be used.

Page 44

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

To prepare Raspberry for the execution of the .NET code, we need to install Mono,
which contains the Common Language Runtime for .NET that will help us run the .NET
code on Raspberry. This is done by executing the following commands in a terminal
window in Raspberry Pi:

$ sudo apt-get update

$ sudo apt-get upgrade

$ sudo apt-get install mono-complete

Your device is now ready to run the .NET code.

4. Clayster libraries

To facilitate the development of IoT applications, this book provides you with the
right to use seven Clayster libraries for private and commercial applications. These are
available on GitHub with the downloadable source code for each chapter. Of these seven
libraries, two are provided with the source code so that the community can extend them as
they desire. Furthermore, the source code of all the examples shown in this book is also
available for download.

The following Clayster libraries are included:

Library Description
This provides the application with a powerful object database. Objects are
persisted and can be searched directly in the code using the object's class
Clayster.Library.Data
definition. No database coding is necessary. Data can be stored in the
SQLite database provided in Raspberry Pi.
This provides the application with an extensible event logging architecture
Clayster.Library.EventLog
that can be used to get an overview of what happens in a network of things.
This contains classes that implement common Internet protocols.
Clayster.Library.Internet Applications can use these to communicate over the Internet in a dynamic
manner.
This provides mechanisms to create localizable applications that are simple
Clayster.Library.Language
to translate and that can work in an international setting.
This provides a powerful extensible, mathematical scripting language that
Clayster.Library.Math
can help with automation, scripting, graph plotting, and others.
This provides classes that help applications become interoperable by
Clayster.Library.IoT providing data representation and parsing capabilities of data in IoT. The
source code is also included here.
This contains Hardware Abstraction Layer (HAL) for Raspberry Pi. It
provides object-oriented interfaces to interact with devices connected to the
Clayster.Library.RaspberryPi
General Purpose Input/Output (GPIO) pins available. The source code is
also included here.

Page 45

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

5. Hardware Interacting with the hardware

Hardware

Our sensor prototype will measure three things: light, temperature, and motion. To
summarize, here is a brief description of the components:

• The light sensor is a simple ZX-LDR analog sensor that we will connect to a four-
channel (of which we use only one) analog-to-digital converter (Digilent Pmod AD2),
which is connected to an I2C bus that we will connect to the standard GPIO pins for
I2C.
• The temperature sensor (Texas Instruments TMP102) connects directly to the same
I2C bus.
• The SCL and SDA pins on the I2C bus use recommended pull-up resistors to make
sure they are in a high state when nobody actively pulls them down.
• The infrared motion detector (Parallax PIR sensor) is a digital input that we connect to
GPIO 22.
• We also add four LEDs to the board. One of these is green and is connected to GPIO
23. This will show when the application is running. The second one is yellow and is
connected to GPIO 24. This will show when measurements are done. The third one is
yellow and is connected to GPIO 18. This will show when an HTTP activity is
performed. The last one is red and is connected to GPIO 25. This will show when a
communication error occurs.
• The pins that control the LEDs are first connected to 160 Ω resistors before they are
connected to the LEDs, and then to ground. All the hardware of the prototype board is
powered by the 3.3 V source provided by Raspberry Pi. A 160 Ω resistor connected in
series between the pin and ground makes sure 20 mA flows through the LED, which
makes it emit a bright light.

Interacting with hardware

We also need to create a console application project in Xamarin. Appendix A,


Console Applications, details how to set up a console application in Xamarin and how to
enable event logging and then compile, deploy, and execute the code on Raspberry Pi.

Interaction with our hardware is done using corresponding classes defined in the
Clayster.Library.RaspberryPi library, for which the source code is provided.

For instance, digital output is handled using the DigitalOutput class and digital input
with the DigitalInputclass. Devices connected to an I2C bus are handled using the I2C
class. There are also other generic classes, such as ParallelDigitalInput and
ParallelDigitalOutput, that handle a series of digital input and output at once. The
SoftwarePwm class handles a software-controlled pulse-width modulation output. The Uart
class handles communication using the UART port available on Raspberry Pi. There's also
a subnamespace called Devices where device-specific classes are available.

Page 46

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

In the end, all classes communicate with the static GPIO class, which is used to
interact with the GPIO layer in Raspberry Pi.

Each class has a constructor that initializes the corresponding hardware resource,
methods and properties to interact with the resource, and finally a Dispose method that
releases the resource.

6. Interfacing the hardware

The hardware interfaces used for our LEDs are as follows:


private static DigitalOutput executionLed = new DigitalOutput (23, true);
private static DigitalOutput measurementLed = new DigitalOutput (24, false);
private static DigitalOutput errorLed = new DigitalOutput (25, false);
private static DigitalOutput networkLed = new DigitalOutput (18, false);

We use a DigitalInput class for our motion detector:


private static DigitalInput motion = new DigitalInput (22);

With our temperature sensor on the I2C bus, which limits the serial clock frequency to a
maximum of 400 kHz, we interface as follows:

private static I2C i2cBus = new I2C (3, 2, 400000);


private static TexasInstrumentsTMP102 tmp102 = new TexasInstrumentsTMP102 (0,
i2cBus);

We interact with the light sensor using an analog-to-digital converter as follows:

private static AD799x adc = new AD799x (0, true, false, false, false, i2cBus);

7. Internal representation of sensor values

The sensor data values will be represented by the following set of variables:
private static bool motionDetected = false;
private static double temperatureC;
private static double lightPercent;
private static object synchObject = new object ();

Historical values will also be kept so that trends can be analyzed:


private static List<Record> perSecond = new List<Record> ();
private static List<Record> perMinute = new List<Record> ();
private static List<Record> perHour = new List<Record> ();
private static List<Record> perDay = new List<Record> ();
private static List<Record> perMonth = new List<Record> ();

Page 47

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

8. Persisting data

Persisting data is simple. This is done using an object database. This object
database analyzes the class definition of objects to persist and dynamically creates the
database schema to accommodate the objects you want to store. The object database is
defined in the Clayster.Library.Data library. You first need a reference to the object
database, which is as follows:

internal static ObjectDatabase db;

Then, you need to provide information on how to connect to the underlying database. This
can be done in the .config file of the application or the code itself. In our case, we will
specify a SQLite database and provide the necessary parameters in the code during the
startup:

DB.BackupConnectionString = "Data Source=sensor.db;Version=3;";


DB.BackupProviderName = "Clayster.Library.Data.Providers." +
“SQLiteServer.SQLiteServerProvider";

Finally, you will get a proxy object for the object database as follows. This object can be
used to store, update, delete, and search for objects in your database:
db = DB.GetDatabaseProxy (“TheSensor");

By doing this, the sensor does not lose data if Raspberry Pi is restarted.

9. External representation of sensor values

To facilitate the interchange of sensor data between devices, an interoperable


sensor data format based on XML is provided in the Clayster.Library.IoT library. There,
sensor data consists of a collection of nodes that report data ordered according to the
timestamp.

For each timestamp, a collection of fields is reported. There are different types of
fields available: numerical, string, date and time, timespan, Boolean, and enumeration-
valued fields. Each field has a field name, field value of the corresponding type and the
optional readout type (if the value corresponds to a momentary value, peak value, status
value, and so on), a field status, or Quality of Service value and localization information.

The Clayster.Library.IoT.SensorData namespace helps us export sensor data


information by providing an abstract interface called ISensorDataExport. The same logic
can later be used to export to different sensor data formats. The library also provides a
class namedReadoutRequest that provides information about what type of data is desired.
We can use this to tailor the data export to the desires of the requestor.

Page 48

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

10. Exporting sensor data

The export starts by calling the Start() method on the sensor data export module
and ends with a call to the End() method. Between these two, a sequence of StartNode()
and EndNode() method calls are made, one for each node to export. To simplify our
export, we then call another function to output data from an array of Record objects that
contain our data. We use the same method to export our momentary values by creating a
temporary Record object that would contain them:

private static void ExportSensorData (ISensorDataExport Output,


ReadoutRequest Request)
{
Output.Start ();
lock (synchObject)
{
Output.StartNode ("Sensor");
Export (Output, new Record[]
{
new Record (DateTime.Now, temperatureC, lightPercent, motionDetected)
},ReadoutType.MomentaryValues, Request);

Export (Output, perSecond, ReadoutType.HistoricalValuesSecond, Request);


Export (Output, perMinute, ReadoutType.HistoricalValuesMinute, Request);
Export (Output, perHour, ReadoutType.HistoricalValuesHour, Request);
Export (Output, perDay, ReadoutType.HistoricalValuesDay, Request);
Export (Output, perMonth, ReadoutType.HistoricalValuesMonth, Request);

Output.EndNode ();
}
Output.End ();
}

For each array of Record objects, we then export them as follows:

The Export method exports an enumeration of Record objects as follows. First it


checks whether the corresponding readout type is desired by the client before exporting
data of this type. The method also checks whether the data is within any time interval
requested and that the fields are of interest to the client.

If a data field passes all these tests, it is exported by calling any of the instances of
the overloaded method ExportField(), available on the sensor data export object. Fields
are exported between the StartTimestamp() andEndTimestamp() method calls, defining
the timestamp that corresponds to the fields being exported:

Page 49

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)


lOMoARcPSD|30789968

private static void Export(ISensorDataExport Output, IEnumerable<Record>


History, ReadoutType Type,ReadoutRequest Request)
{
if((Request.Types & Type) != 0)
{
foreach(Record Rec in History)
{
if(!Request.ReportTimestamp (Rec.Timestamp))
continue;
Output.StartTimestamp(Rec.Timestamp);
if (Request.ReportField("Temperature"))
Output.ExportField(“Temperature",Rec.TemperatureC, 1,"C", Type);
if(Request.ReportField("Light"))
Output.ExportField("Light",Rec.LightPercent, 1, "%", Type);
if(Request.ReportField ("Motion"))
Output.ExportField("Motion",Rec.Motion, Type);
Output.EndTimestamp();
}
}
}

We can test the method by exporting some sensor data to XML using the
SensorDataXmlExport class. It implements the ISensorDataExport interface. The result
would look something like this if you export only momentary and historic day values.

Page 50

Downloaded by SHARMILA RANI (sharmilarajme@gmail.com)

You might also like