Notes - IOT
Notes - IOT
Definition and Characteristics of IoT, Sensors, Actuators, Physical Design of IoT – IoT
Protocols, IoT communication models, IoT Communication APIs, IoT enabled Technologies –
Wireless Sensor Networks, Cloud Computing, Embedded Systems, IoT Levels and Templates,
Domain Specific IoTs – Home, City, Environment, Energy, Agriculture and Industry.
Definition of IoT:
A dynamic global network infrastructure with self-configuring capabilities based on
standard and interoperable communication protocols where physical and virtual "things" have
identities, physical attributes, and virtual personalities and use intelligent interfaces, and are
seamlessly integrated into the information network, often communicate data associated with
users and their environments.
Characteristics of IoT:
• Dynamic & Self-Adapting
• Self-Configuring
• Interoperable Communication Protocols
• Unique Identity
• Integrated into Information Network
1. Active or passive: Sensors can be categorized based on whether they produce an energy
output and typically require an external power supply (active) or whether they simply
receive energy and typically require no external power supply (passive).
2. Invasive or non-invasive: Sensors can be categorized based on whether a sensor is part
of the environment it is measuring (invasive) or external to it (non-invasive).
Contact or no-contact: Sensors can be categorized based on whether they require physical
contact with what they are measuring (contact) or not (no-contact).
5. How sensors measure: Sensors can be categorized based on the physical mechanism
used to measure sensory input (for example, thermoelectric, electrochemical,
piezoresistive, optic, electric, fluid mechanic, photoelastic).
6. What sensors measure: Sensors can be categorized based on their applications or what
physical variables they measure.
Note that this is by no means an exhaustive list, and there are many other classification
and taxonomic schemes for sensors, including those based on material, cost, design, and other
factors. The most useful classification scheme for the pragmatic application of sensors in an IoT
network, as described in this book, is to simply classify based on what physical phenomenon a
sensor is measuring.
Table : Sensor Types
Sensors come in all shapes and sizes and can measure all types of physical conditions. A
fascinating use case to highlight the power of sensors and IoT is in the area of precision
agriculture (sometimes referred to as smart farming), which uses a variety of technical advances
to improve the efficiency, sustainability, and profitability of traditional farming practices. This
includes the use of GPS and satellite aerial imagery for determining field viability; robots for
high-precision planting, harvesting, irrigation, and so on; and real-time analytics and artificial
intelligence to predict optimal crop yield, weather impacts, and soil quality.
Among the most significant impacts of precision agriculture are those dealing with sensor
measurement of a variety of soil characteristics. These include real-time measurement of soil
quality, pH levels, salinity, toxicity levels, moisture levels for irrigation planning, nutrient levels
for fertilization planning, and so on. All this detailed sensor data can be analyzed to provide
highly valuable and actionable insight to boost productivity and crop yield. Figure shows
biodegradable, passive micro sensors to measure soil and crop and conditions. These sensors,
developed at North Dakota State University (NDSU), can be planted directly in the soil and left
in the ground to biodegrade without any harm to soil quality.
Figure: Biodegradable Sensors Developed by NDSU for Smart Farming
IoT and, by extension, networked sensors have been repeatedly named among a small
number of emerging revolutionary technologies that will change the global economy and shape
the future. The staggering proliferation of sensors is the principal driver of this phenomenon. The
astounding volume of sensors is in large part due to their smaller size, their form factor, and their
decreasing cost. These factors make possible the economic and technical feasibility of having an
increased density of sensors in objects of all types. Perhaps the most significant accelerator for
sensor deployments is mobile phones. More than a billion smart phones are sold each year, and
each one has well over a dozen sensors inside it (see Figure 3-2), and that number continues to
grow each year. Imagine the exponential effect of extending sensors to practically every
technology, industry, and vertical. For example, there are smart homes with potentially hundreds
of sensors, intelligent vehicles with 100+ sensors each, connected cities with thousands upon
thousands of connected sensors, and the list goes on and on.
Actuators:
Actuators are natural complements to sensors. Figure demonstrates the symmetry and
complementary nature of these two types of devices. As discussed in the previous section,
sensors are designed to sense and measure practically any measurable variable in the physical
world. They convert their measurements (typically analog) into electric signals or digital
representations that can be consumed by an intelligent agent (a device or a human). Actuators, on
the others hand, receive some type of control signal (commonly an electric signal or digital
command) that triggers a physical effect, usually some type of motion, force, and so on.
Figure: How Sensors and Actuators Interact with the Physical World
The previous section draws a parallel between sensors and the human senses. This
parallel can be extended to include actuators, as shown in Figure. Humans use their five senses to
sense and measure their environment. The sensory organs convert this sensory information into
electrical impulses that the nervous system sends to the brain for processing. Likewise, IoT
sensors are devices that sense and measure the physical world and (typically) signal their
measurements as electric signals sent to some type of microprocessor or microcontroller for
additional processing. The human brain signals motor function and movement, and the nervous
system carries that information to the appropriate part of the muscular system.
Correspondingly, a processor can send an electric signal to an actuator that translates the
signal into some type of movement (linear, rotational, and so on) or useful work that changes or
has a measurable impact on the physical world. This interaction between sensors, actuators, and
processors and the similar functionality in biological systems is the basis for various technical
fields, including robotics and biometrics.
Much like sensors, actuators also vary greatly in function, size, design, and so on. Some
common ways that they can be classified include the following:
1. Type of motion: Actuators can be classified based on the type of motion they produce
(for example, linear, rotary, one/two/three-axes).
2. Power: Actuators can be classified based on their power output (for example, high
power, low power, micro power)
3. Binary or continuous: Actuators can be classified based on the number of stable-state
outputs.
4. Area of application: Actuators can be classified based on the specific industry or
vertical where they are used.
5. Type of energy: Actuators can be classified based on their energy type.
Categorizing actuators is quite complex, given their variety, so this is by no means an
exhaustive list of classification schemes. The most commonly used classification is based on
energy type. Table shows actuators classified by energy type and some examples for each type.
Again, this is not a complete list, but it does provide a reasonably comprehensive overview that
highlights the diversity of function and design of actuators.
1.3 Physical Design of IoT:
The "Things" in IoT usually refers to IoT devices which have unique identities and can perform
remote sensing, actuating and monitoring capabilities. IoT devices can:
Exchange data with other connected devices and applications (directly or
indirectly), or
Collect data from other devices and process the data locally or
Send the data to centralized servers or cloud-based application back-ends for
processing the data, or
Perform some tasks locally and other tasks within the IoT infrastructure, based on
temporal and space constraints
Figure : Generic block diagram of an IoT Device
An IoT device may consist of several interfaces for connections to other devices, both
wired and wireless.
• I/O interfaces for sensors
• Interfaces for Internet connectivity
• Memory and storage interfaces
• Audio/video interfaces.
An IoT Device can collect various types of data from the the onboard or attached sensors,
such as temperature e , humidity, light intensity. IoT devices can also be varied types, for
instance, wearable sensors, smart watches, LED light automobiles and industrial machines.
Almost all I would advise generate data in Some form or the other which when processed by
Data Analytics systems leads to Useful information to guide further actions locally or remotely.
Link Layer:
Link Layer protocols determine how the data is physically sent over the networks
physical layer or medium(example copper wire, electrical cable, or radio wave). The Scope of
The Link Layer is the Last Local Network connections to which host is attached. Host on the
same link exchange data packets over the link layer using the link layer protocol. Link layer
determines how the packets are coded and signaled by the hardware device over the medium to
which the host is attached.
802.3 Ethernet:
802.3 is a collections of wired Ethernet standards for the link layer. For example 802.3
10BASE5 Ethernet that uses coaxial cable as a shared medium, 802.3.i is standard for 10 BASET
Ethernet over copper twisted pair connection, Standards provide data rates from 10 Mb/s to 40
gigabits per second and the higher. The shared medium in Ethernet can be a coaxial cable ,
twisted pair wire or and Optical fiber. Shared medium carries the communication for all the
devices on the network.
802.1- WI-FI:
IEEE 802.3 is a collections of wireless Local area network.(WLAN) communication
standards, including extensive descriptions of the link layer. For example 802.11a operate in the
5 GHz band, 802.11b and 802.11g operate in the 2.4 GHz band. 802.11ac operates in the 5G
hertz band.
802.16 wiMAX:
IEEE 802.16 is a collection of wirless broadband and Standards, including extensive
descriptions for the link layer also called WiMAX wimax standard provides a data rates from
from 1.5 Mb/s to 1Gb/s the recent update provides data rates of hundred megabits per second for
mobile station.
802.15.4 LR-WPAN:
IEEE 802.1 5.4 is a collections of standard for low rate wireless personal area
network(LRWPAN).These standard form the basis of specifications for high level
communication Zigbee. LR-WPAN standards provide data rates from 40 k b/ s. These standards
provide low cost and low speed Communications for power constrained devices.
2G / 3G / 4G mobile communications:
These are the different generations of mobile communication standards including second
generation (2G including GSM and CDMA). 3rd Generation (3G including UMTS and
CDMA2000) and 4th generation 4G including LTE.
IPV4:
Internet protocol versions for open parents close (IPV4) is there most deployed internet
protocol that is used to identify the device is on a network using a hierarchy latest schemes. It
uses 32 bit addresses scheme that allows total of 232 addresses. As more and more devices got
connected to the internet the Ipv4 has succeeded by IPv6.
IPv6:
It is the newest versions of internet protocol and successor to IPv4. IPv6 uses 128 bit
address schemes that are lost total of 2 128 are 3.4*10 38 address.
6LoWPAN:
IPv6 over low power wireless personal area networks brings IP protocol to the low power
device which have limited processing capability it operate in the 2.4 GHz frequency range and
provide the data transfer rate off to 50 kb/s.
Transport layer:
The Transport layer protocol provides end-to-end message transfer capability
independent of the underlying network. The message transfer capability can be set up on
connections, either using handshake or without handshake acknowledgements. Provides
functions such as error control, segmentation, flow control and congestion control.
TCP:
Transmission control protocol is the most widely used to transport layer protocol that is
used by the web browsers along with HTTP, HTTPS application layer protocols email program
(SMTP application layer protocol) and file transfer protocol. TCP is a connection Oriented and
stateful protocol while IP protocol deals with sending packets, TCP ensures reliable
transmissions of packets in order. TCP also provide error deduction capability so that duplicate
packets can be discarded and low packets are retransmitted. The flow control capability ensures
that the rate at which the sender since the data is now too high for the receiver to process.
UDP:
Unlike TCP, which requires carrying out an initial setup procedure, UDP is a connection
less protocol. UDP is useful for time sensitive application they have very small data units to
exchange and do not want the overhead of connection setup. UDP is a transactions oriented and
stateless protocol. UDP does not provide guaranteed delivery, ordering of messages and
duplicate eliminations.
Application layer:
Application layer protocol defines how the application interfaces with the lower layer
protocols to send the data over the network. Data are typically in files, is encoded by the
application layer protocol and encapsulated in the transport layer protocol .Application layer
protocol enable process-to-process connection using ports.
Http:
Hypertext transfer protocol is the application layer protocol that forms the foundations of
world wide web http includes, ,commands such as GET, PUT,POST, DELETE, HEAD, TRACE,
OPTIONS etc. The protocol follows a request response model where are client sends request to
server using the http, commands. Http is a stateless protocol and each http request is independent
father request and http client can be a browser or an application running on the client example
and application running on an IoT device, mobile mobile applications or other software.
CoAP:
Constrained application protocol is an application layer protocol for machine to machine
application M2M meant for constrained environment with constrained devices and constrained
networks. Like http CoAP is a web transfer protocol and uses a request- response model,
however it runs on the top of the UDP instead of TC CoAP uses a client –server architecture
where client communicate with server using connectionless datagrams. It is designed to easily
interface with http like http, CoAP supports method such as GET, PUT, DELETE.
Websocket:
Websocket protocol allows full duplex communication over a single socket connection
for sending message between client and server. Websocket is based on TCP and Allows streams
of messages to be sent back and forth between the client and server while keeping the TCP
connection open. The client can be a browser, a mobile application and IoT device
MQTT:
Message Queue Telemetry Transport it is a lightweight message protocol based on public
-subscribe model MQTT uses a client server Architecture by the clients such as an IoT device
connect to the server also called the MQTT broker and publishers message to topic on the server.
The broker forward the message to the clients subscribed to topic MQTT is well suited for
constrained and environments.
XMPP:
Extensible Messaging and Presence Protocol it is a protocol for real-time communication
and streaming XML data between network entities XMPP powers wide range of applications
including messaging, presence, data syndication, gaming multiparty chat and voice / voice calls.
XMPP Allows sending small chunks of XML data from one network entity to another in real
time. XMPP supports both client to server and server –client communication path.
DDS:
Data distribution service is the date centric middleware standard for device to-device
machine to machine communication DDS uses a publish subscribe model where publisher
example device that generate data create topics to which subscribers per can subscribe publisher
is an object responsible for data distributions and the subscriber responsible for receiving
published data. DDS provide quality of service (QoS) control and configurable reliability
AMQP:
Advanced Message Queuing Protocol. It is an open application layer protocol for
business messaging. AMQP support point to point and publish - subscribe model routing and
queuing. AMQP broker receive message from publishers example devices or applications that
generate data and about them over connections to consumers publishers publish the message to
exchange which then distribute message copies to queues.
TCP connections:
For REST Service each http request involves setting up a new TCP connection.
Websocket on the other hand involves a single TCP connection over which the client and server
communicate in a full duplex mode.
Headache Overhead:
REST service operate over http, and each request is independent of others . Thus each
request carries http header which is an overhead. Due to the overhead of http headers, REST is
not suitable for real time applications left hand does not involve overhead of headers. After the
initial handshake the client and server exchange messages with minimal frame information.
Scalability:
Scalability is easier in this case of the REST services of request are independent and no
state information needs to be maintained by the server. Thus both horizontal out and vertical
scaling solutions are possible for REST services. For webSockets horizontal scaling can be
cumbersome due to stateful nature of the communication. Since the server maintains the state of
our connection, vertical scaling is easier for Websocket than horizontal scaling.
Analysis component:
The analysis component is responsible for analyzing the IoT data and generate results in
the form which are easy for the user to understand. Analysis of IoT data can be performed either
locally or in the cloud. Analyzed results are stored in the local or cloud database.
Application: IoT applications provide an interface that the user can use to control and monitor
various aspects of the IoT system. Applications also allow user to view the system status and
view the processed data.
IoT level 1:
Level One IoT system has a single node / device that performs sensing and/or actuation,
stores data, reforms analysis and the host to the application. Level 1 IoT systems are suitable for
modeling low cost and low complexity solutions where the data involving is not big and the
analysis requirements are not computationally intensive.
Let us now consider done example of Level 1 IoT system for home automation. This
system consists of the single node that allows controlling the lights and appliances in your home
remotely. The device used in this system interface with their lights and appliances using
electronic relay switches.
The status information of each light or appliance is maintained in a local database. REST
service deployed locally Allow retrieving and updating the state of the each light or appliances in
the status database.
The controller service continuously monitors the state of each light or appliance and
triggers the relay switches accordingly. The application which is deployed locally has a user
interface for controlling the lights or appliances. Since the device is connected to the internet, the
application can be accessed remotely as well.
IoT level 2:
Level 2 IoT system has a single node that performs sensing and/or actuation and local
analysis. Data is stored in the cloud and application is usually cloud based systems are suitable
for solutions where the data in world is big, however the primary analysis requirement is not
computationally intensive and can be done local itself.
Construct an example of Level 2 IoT system for smart irrigation. The system consists of
the single node that monitor the soil moisture level and control segregation system. The device
used in this system collect soil moisture data from sensor the controller service continuously
monitor the moisture level. If the monster level drops below a threshold t , the irrigation system
is turned on.
For controlling the irrigation system actuators such as solenoid valve can be used.. Rest
Web Services is used for storing and retrieving data which is stored in the cloud database. A
cloud based application is used for visualizing the moisture level over a period of time, which
can help in making decisions about irrigation schedules.
IoT Level 3:
Level 3 system has a single node . Data is stored and analyzed in the cloud application
is cloud-based. Level 3 IoT system suitable for solutions where the data involved is big and
analysis requirements computationally intensive.
Let us considered example of Level 3 IoT system tracking package handling. The system
consists of a single node that monitors the vibration level for package being shipped. The device
in the system uses accelerometer and gyroscope sensor for monitoring vibration levels. The
controller service send sensor data to the cloud in real time using a website service. The data is
stored in the cloud and also visualized using a cloud based application.
The analysis component in the cloud can Trigger alert the vibration level become greater
than threshold. The benefit of using websocket service instead of the REST service this example
the sensor data can be sent in real-time to the cloud. Cloud based application can subscribe to the
sensor data feeds for you in the real-time data.
IoT level 4:
A level 4 IoT system has multiple notes that perform local analysis. Data is stored in the
cloud and application is cloud based, level 4 contains local and cloud based observer notes which
can subscribe to and receive information collected in the cloud from IoT devices.
Observer node can process information and use it for various applications, however
observer notes do not perform any control function. level 4 IoT systems are suitable for solutions
where multiple nodes are required the data involved is big and the analysis requirements are
computationally intensive.
Let us consider an example of level four IoT system for noise monitoring. The system
consists of multiple notes placed in different locations for monitoring noise level in an area. In
this example with sound sensor nodes are independent of each other each node runs in one
controller service that sends the data to the cloud. The data is stored in a cloud database the
analysis of the data collected from a number of notes is done in the cloud.
IoT Level 5:
IoT system has multiple end nodes and one coordinator notes and notes that perform
sensing and / or actuation. Coordinator node collects data from the entry and send to the cloud.
Data is stored and analyzed in the cloud and applications is cloud based. Level 5 IoT system are
suitable for forest fire detection.
The system consists of multiple nodes placed in different locations for monitoring
temperature, humidity and carbon dioxide levels in a forest. The endnotes in this example are
equipped with various sensors such as temperature humidity and to CO2.
The coordinator node collects the data from the end nodes and act as a Gateway that
provides internet connectivity to the IoT system. The controller service on the coordinator device
sends the collected data to the cloud .The data is stored in the cloud database. The analysis of the
data is done in the computing cloud to aggregate the data and make prediction.
IoT Level 6:
IoT Level 6 system has multiple Independent and nodes that perform sensing and / or
actuations and send data to the cloud. Data is stored in the cloud and applications is cloud based.
The analytics component analyze the data and store the results in the cloud database. The results
are visualized with the cloud based application. The centralized controller is aware of the status
of all the end notes and send control commands to the notes.
Let us consider an example of the level 6 IoT system for weather monitoring. The system
consists of multiple nodes placed in different location for monitoring temperature, humidity and
pressure in an area. The end nodes are equipped with various sensors such as
temperature ,pressure and humidity. The end nodes send the data to the cloud in real time using a
websocket service .The data is stored in a cloud database. The analysis of the data is done in the
cloud to aggregate the data and make predictions. A cloud based applications is used for
visualizing the data.
1.8 Domain-specific IoT
Internet of things applications span wide range of Dubai including homes, cities
environment, energy systems, retail, logistics, industry, agriculture and health.
1. Home Automation:
(i) Smart lighting :
Smart lighting for homes helps in saving energy by adapting the lighting to the ambient
condition and switching on/off or dimming the lights when needed. Key enabling technologies
for smart lighting include solid-state lighting such as LED light and IP enabled the lights.
For solid state lighting solution both spectral and temporal characteristics can be
configured to adapt illumination to various needs. Smart lighting solutions for Home achieve
energy saving by sensing the human movements and their environments and controlling the
lights accordingly.
Wireless enabled and internet connected lights can be controlled remotely from IoT
applications such as a mobile or web application. Smart lights with sensor for occupancy,
Temperature Lux level etc can be configured to adapt the lighting based on the ambient
conditions sensed, in order to provide a good ambience. In controllable LED lighting system is
presented that is embedded with ambient intelligence gathered from a distributed smart wireless
sensor network to optimize and control the lighting system to be more efficient and user oriented,
A solid state lighting model is implemented on your wireless sensor network that provide
services for sensing illumination changes and dynamically adjusting luminary brightness
according to user preferences.
(ii) Smart Appliances:
Modern homes have a number of appliances such as TVs, refrigerator, music system,
washer / dryer etc. Managing and controlling these appliances can be cumbersome with the each
appliance having its own controls or remote controls. Smart appliance make the management
easier and also provide status information to the user remotely.
Examples smart watches /dryers that can be controlled remotely and notify when the
washing / driving cycle is complete smart thermostat Allow controlling the temperature remotely
and can learn the user preferences smart refrigerator can keep track of the item stored and send
update to the user when an item is low on stock.
Smart TV Allows user to search and stream videos and movies from the internet on a
local storage drive, search TV channel schedule and fetch news weather updates and other
content from the internet.
Open remote is an open source automation platform for homes buildings. Open remote is
platform agnostic and works with standard hardware. With OpenRemote, user can control
various appliances using mobile or web publications.
OpenRemote comprises of three components - a controller that manages scheduling and
runtime integrations between device, a designer that allows you to create both configuration for
the controller and create user interface design and control panel that allow you to interact with
the devices and control them.
2. Smart Cities:
(i) Smart Parking
Finding a parking space during rush hours in crowded cities can be time consuming and
frustrating. Further for the more drivers blindly searching for parking spaces create additional
traffic conditions for Star smart parking make the search for parking space easier and convenient
for drivers.
Smart parking for powered by IoT system that detect the number of empty parking slots
and send the information over the internet to smart parking application back ends. These
applications can be accessed by the drivers from smartphones, tablets and in car navigation
system.
In smart parking sensors are used for each parking slot, to detect whether the slot is
empty or occupied. This information is aggregated by your local controller and then send over
the internet to the database. Design and implementation of a prototype smart parking system
based on wireless sensor Network Technology with just like a remote parking
monitoring ,automated guidance, and departing reservations mechanism .
(v) Surveillance
Surveillance of infrastructure, public transport and even in cities is required to ensure
safety and security. City wide surveillance infrastructure comprising of large number of
distributed and internet connected video surveillance cameras can be created. The video feeds
from surveillance cameras can be aggregated in cloud based storage solutions.
Cloud-based video analytics applications can be deployed to search for patterns for
specific events from the video feed.
Emergency Response IoT Systems can be used for monitoring the critical infrastructure
in cities such as building, gas and water pipelines, public transport and power substation systems.
IoT systems for fire directions, gas and water leakage directions can help in generating alerts and
minimizing their effects on the critical infrastructure.
IoT systems for critical infrastructure monitoring enable aggregations and sharing of
information is collected from large number of sensors. Cloud based architecture multimodel
information such as sensor data, audio, video feeds can be analyzed in near realtime to detect
adverse event.
Response to alerts generated by such systems can be in the form of alerts sent to the
public, re-routing of traffic, evacuation of the affected areas. Traffic management system for
emergency services is describe the system adapt by dynamically adjusting traffic lights, changing
related driving policies, recommending behavior change to drivers and applying essential
security controls.
3. Environment:
(i) Weather Monitoring:
IoT- based weather monitoring system can collect data from a number of sensor attached
such as temperature, humidity, pressure etc. and send the data to cloud based application and
storage back-ends. The data collected in the cloud can then be analyzed and visualized by cloud
based application.
Weather alerts can be sent to the subscribed users from such applications AirPi weather
and air quality monitoring kit capable of recording and uploading information about temperature,
humidity, air pressure light levels, UV levels, carbon monoxide Nitrogen dioxide and smoke
level to the internet.
(ii) Air Pollution Monitoring:
IoT based air pollution monitoring system can monitor emission of harmful gases ( CO2,
CO. NO, NO2) by factories and automobiles using gases and dermatological sensors the
collected data can be analyzed to make informed decisions on pollutions control approaches.
In real time air quality monitoring system is presented that comprises of several
distributed monitoring stations that communicate via wireless with a backend server using
machine to machine communication. In addition sums of GPRS modem and GPS module.
(ii) Prognostics:
Energy systems (Smart grids, power plants ,wind turbine forms) have a large number of
critical components that must function correctly so that the system can perform their operations
correctly.
For example a wind turbine has a number of critical components example bearing,
turning gears, for instance that must be monitored carefully as wear and tear in such critical
components or sudden change in operating conditions of the missions can result in failures. In
system such as Power Grids, real time information using specialist electrical sensor is called
phasor measurement unit (PMU) substations.
The information received from PMU must be monitored in real time for estimating the
state of a system and for predicting failures. Energy system have thousands of sensors that gather
real time maintenance data continuously for condition monitoring and failure prediction
purposes. IoT based prognostic real-time health management systems can predict performance of
machine or energy Systems by analyzing the extent of deviations of the system from its normal
operating profiles.
Analyzing massive amounts of maintenance data collected from sensors in energy
systems and equipment can provide protections for the impending failures (potentially in real
time) so that their reliability and availability can be improved. Prognostic health Management
systems have been developed for different energy systems open PDC set of applications for
processing of streaming time series data collected from phasor measurement units PMU in real
time.
5. Agriculture:
(i) Smart Irrigation:
Smart irrigation systems can improve crop yield while saving water. smart irrigation
system using IoT devices with soil moisture sensors to determine the amount of moisture in the
soil and realize the flow of water through the irrigation pipe only when the moisture level go
below a predefined threshold. Smart irrigation systems also collect Moisture level measurements
on a server or in the cloud where they collected data can be analyzed to plant watering schedule.
6. Industry:
(i) Machine Diagnosis and Prognosis:
Machine prognosis refers to predicting the performance of a machine by analyzing the
data and the current operating conditions and how much deviations exist from the normal
operating conditions. Machine diagnosis refer to determining the causes of a machine
fault.
IoT plays a major role in both the prognosis s and Diagnostics of industrial machines.
Industrial machines have a large number of components that must function correctly for the
machine to perform its operations. Sensors in machine can monitor the operating conditions such
as temperatures and vibrations levels.
The sensor data measurements are done on time scale of few milliseconds to few
seconds, which leads to generations of the massive amount of the data.
Case-based reasoning (CBR) is a commonly used method to find solutions for new
problem based on past experience. This past experience is organized and represented as case in a
case base. CBR is an effective technique for problem solving in the field in which it is hard to
establish a quantitative mathematical model, such as machine Diagnostics and prognosis.
Since foe each machine, data from a very large number of sensors is collected using
search high-dimensional data for creation of a case library reduce the case retrieval efficiency.
Data reduction and feature extraction methods are used to find the representatives set of ability
as the of features.
(ii) Indoor Air Quality Monitoring:
Monitoring indoor air quality in factories is important for health and safety of the
workers. Harmful and toxic gas such as carbon monoxide, nitrogen monoxide and Nitrogen
dioxide etc can cause serious health problems .IoT based gas monitoring system can help in
monitoring the indoor air quality using various gas sensors. The indoor air quality can vary for
different locations. Wireless sensor networks based IoT devices can identify the other hazardous
zones, so that a corrective measure can be taken to ensure proper ventilation.
UNIT II IOT PROTOCOLS 9
Protocol Standardization for IoT – Efforts – M2M and WSN Protocols – SCADA and RFID
Protocols – Issues with IoT Standardization – Unified Data Standards – Protocols –
IEEE802.15.4 – BACNet Protocol– Modbus – KNX – Zigbee– Network layer – APS layer –
Security
IoT Stakeholders:
Service Provider,
Developers,
Investor
Investor and
User
Many standardization efforts have been trying to define unified data representation,
protocol for IoT. Before IoT, Internet was actually an Internet of documents or of multimedia
documents. Two pillars of Internet including HTML/HTTP turned the Internet into WWW. We
need to turn the IoT into the WoT. What will it take to make this to happen?
Do we need a new HTML/HTTP-like standard for MTC and WoT? If there is no need to
reinvent the wheel, what extensions do we need to build on top of HTML/HTTP or HTML5?
Browser is intended for humans, so do we need new browser for machines to make sense
of ocean of machine-generated data? If not, what extensions do we need to make to the existing
browsers?
Today, most new protocols are built on top of XML. For OS there must be XML-based
data format standards or a metadata standard to represent the machine-generated data (MGD). Is
it possible to define such a metadata standard that covers everything?
There are many different levels of protocols but the ones that most directly relate to
business and social issues are the ones closest to the top so-called application protocols such as
HTML/HTTP for the web. Web has always been visual medium, but restricted until recently,
HTML developers were limited to CSS & JavaScript in order to produce animations or they
would have to rely on a plug-in like Flash.
MAC provides data and management services to upper layers. 802.15.4 MAC is of very
low complexity, making it very suitable for its intended low end applications, albeit at the cost of
a smaller feature set than 802.15.1 (e.g., 802.15.4 does not support synchronous voice links).
Frame control field indicates the type of MAC frame being transmitted, specifies the
format of the address field, and controls the acknowledgment. Multiple address types: 64 bit
physical address and short 8 bit network assigned address are provided. Address field size may
vary from 0 to 20 bytes.
Payload field is variable with condition size of mac frame <= 127 bytes. FCS is used for
integrity check using 16 bit CRC. This standard provides 2 PHY options with frequency band as
fundamental difference.
2.4 GHz band has worldwide availability and provides a transmission rate of 250 kb/s.
The 868/915 MHz PHY specifies operation in the 868 MHz band in Europe and 915 MHz ISM
band in the United States and offer data rates 20 kb/s and 40 kb/s respectively. Different
transmission rates can be exploited to achieve a variety of different goals.
Figure:
2.7 Modbus:
MODBUS is an application layer messaging protocol, positioned at level 7 of the OSI
model, that provides client/server communication between devices connected on different types
of buses or networks.
The industry’s serial de facto standard since 1979, MODBUS continues to enable
millions of automation devices to communicate. Today, support for the simple and elegant
structure of MODBUS continues to grow. The Internet community can access MODBUS at a
reserved system port 502 on the TCP/IP stack.
MODBUS is a request/reply protocol and offers services specified by function codes.
MODBUS function codes are elements of MODBUS request/reply PDUs. The objective of this
document is to describe the function codes used within the framework of MODBUS transactions.
MODBUS is an application layer messaging protocol for client/server communication
between devices connected on different types of buses or networks.
Working:
The MODBUS protocol defines a simple protocol data unit (PDU) independent of the
underlying communication layers. The mapping of MODBUS protocol on specific buses or
network can introduce some additional fields on the application data unit (ADU).
Figure 3: General MODBUS frame
The MODBUS application data unit is built by the client that initiates a MODBUS
transaction. The function indicates to the server what kind of action to perform. The MODBUS
application protocol establishes the format of a request initiated by a client.
The function code field of a MODBUS data unit is coded in one byte. Valid codes are in
the range of 1 ... 255 decimal (the range 128 – 255 is reserved and used for exception responses).
When a message is sent from a Client to a Server device the function code field tells the server
what kind of action to perform. Function code "0" is not valid. Sub-function codes are added to
some function codes to define multiple actions. The data field of messages sent from a client to
server devices contains additional information that the server uses to take the action defined by
the function code.
This can include items like discrete and register addresses, the quantity of items to be
handled, and the count of actual data bytes in the field. The data field may be nonexistent (of
zero length) in certain kinds of requests, in this case the server does not require any additional
information. The function code alone specifies the action.
If no error occurs related to the MODBUS function requested in a properly received
MODBUS ADU the data field of a response from a server to a client contains the data requested.
If an error related to the MODBUS function requested occurs, the field contains an exception
code that the server application can use to determine the next action to be taken.
For example a client can read the ON / OFF states of a group of discrete outputs or inputs
or it can read/write the data contents of a group of registers. When the server responds to the
client, it uses the function code field to indicate either a normal (error-free) response or that some
kind of error occurred (called an exception response). For a normal response, the server simply
echoes to the request the original function code.
For an exception response, the server returns a code that is equivalent to the original
function code from the request PDU with its most significant bit set to logic 1.
2.8 KNX:
Intelligent bus systems make buildings more cost-effective to operate, safer, more
flexible, more energy-efficient and above all more comfortable and convenient. The KNX
standard occupies a large share of the market for building automation systems. The KNX
building automation system was originally known as the European Installation Bus (EIB), and
was developed and marketed by the EIB Association (EIBA).
In 1999, EIBA, Batibus Club International (BCI, France) and the European Home
Systems Association (EHSA, Netherlands) amalgamated, the name KNX was adopted, and the
Brussels-based KNX Association was set up. The technology used in modern KNX devices is
compatible with that of the old EIB system, so all devices bearing either the KNX or the EIB
logo are mutually compatible.
The KNX system is a bus system for building control. This means that all devices in a
KNX system use the same transmission method and are able to exchange data via a common bus
network. This has the following consequences:
· Access to the bus network needs to be clearly regulated (bus access method)
· Most of the data transmitted are not payloads (e. g. light on / light off signals), but
address information (i. e. where have the data come from? Where are they going to?)
Another important feature of the KNX bus system is its decentralised structure: there is
no need for a central control unit, because the “intelligence” of the system is spread across all of
its devices. Centralised units are possible, however, for realising very specialised applications.
Every device has its own microprocessor.
A major advantage of KNX’s decentralized structure is that, if one device fails, the others
continue to function. Only those applications dependent on the failed device will be interrupted.
Generally in a KNX system, devices fall into three categories: system devices (power supply,
programming interface, etc.), sensors, and actuators. Sensors are devices that detect events in the
building (e.g. someone pressing a button, someone moving, a temperature falling above or below
a set value, etc.), convert these into telegrams (data packets), and send them along the bus
network. Devices that receive telegrams and convert the commands embedded in them into
actions are known as actuators. Sensors issue commands, while actuators receive them.
Thanks to their decentralised structure, KNX bus systems can be modified and added to
exactly as required. The smallest possible KNX application is a system linking two bus devices:
a sensor and an actuator. This basic system can later be upgraded with as many devices as
necessary to perform the desired control tasks. Theoretically a KNX system can consist of more
than 50,000 devices. When extending a KNX system it is necessary to adhere to a specific
topology.
Communication media:
Various communication media (and hence transmission methods) can be used for the exchange
of data between devices in a KNX system:
1. KNX Twisted Pair (KNX TP)
communication via a twisted pair data cable (bus cable)
2. KNX Powerline (KNX PL)
uses the existing 230 V mains network
3. KNX Radio Frequency (KNX RF)
communication via radio signal
4. KNX IP
communication via Ethernet
Protocol:
The KNX system uses two Ethernet communication methods – tunneling and routing –
both of which use the UDP protocol. Tunneling is used to access the bus from a local network or
the internet for purposes of e. g. programming the KNX installation, while routing is used for
exchanging telegrams over an Ethernet network, e. g. to couple two KNX TP systems via
Ethernet.
The KNX protocols for these two communication methods are called KNXnet/IP routing
and KNXnet/IP tunneling. IP communication in KNX can be explained using the OSI reference
model (Fig. 15). Communication takes place via the application layer (which generates the
KNXnet/IP telegram), the transport layer (UDP), the network layer (IP), and Ethernet – the
physical layer. Like with the TP protocol, additional information for the respective layer (the
header) is always added to the KNXnet/IP information.
Telegram structure
The KNXnet/IP telegram contains some further information in addition to that in the KNX TP
telegram (Fig. 16):
Header Length: The header length is always the same. This information is still sent, however,
because the header length may change in a later version of the protocol. The purpose of the
header is to identify the start of the telegram.
Protocol Version: This indicates what version of the KNXnet/IP protocol applies.
KNXnet/IP Service Type Identifier: The KNXnet/IP Service Type Identifier indicates the action
that is to be carried out.
Total Length: This field indicates the total length of the KNXnet/IP telegram.
KNXnet/IP-Body: This field contains the payload.
2.9 Zigbee:
ZigBee and IEEE 802.15.4 are standards-based protocols that provide the network
infrastructure required for wireless sensor network applications. 802.15.4 defines the physical
and MAC layers, and ZigBee defines the network and application layers.
For sensor network applications, key design requirements revolve around long battery
life, low cost, small footprint, and mesh networking to support communication between large
numbers of devices in an interoperable and multi-application environment.
There are numerous applications that are ideal for the redundant, self-configuring and
self-healing capabilities of ZigBee wireless mesh networks. Key ones include
• Energy Management and Efficiency—To provide greater information and control of energy
usage, provide customers with better service and more choice, better manage resources, and
help to reduce environmental impact.
• Home Automation—To provide more flexible management of lighting, heating and cooling,
security, and home entertainment systems from anywhere in the home.
• Building Automation—To integrate and centralize management of lighting, heating, cooling
and security.
• Industrial Automation—To extend existing manufacturing and process control systems
reliability.
The interoperable nature of ZigBee means that these applications can work together,
providing even greater benefits.
ZigBee is the only standards-based technology that addresses the unique needs of most
remote monitoring and control sensory network applications.
Application Objects:
Software at an endpoint that controls the ZigBee device. A single ZigBee node supports
up to 240 application objects. Each application object supports endpoints numbered between 1
and 240 (with endpoint 0 reserved for the ZigBee Device Object (ZDO)).
Coordinator:
This device starts and controls the network. The coordinator stores information about the
network, which includes acting as the Trust Center and being the repository for security keys.
Router:
These devices extend network area coverage, dynamically route around obstacles, and
provide
backup routes in case of network congestion or device failure. They can connect to the
coordinator and other routers, and also support child devices.
End Devices:
These devices can transmit or receive a message, but cannot perform any routing
operations. They must be connected to either the coordinator or a router, and do not support child
devices.
Benefits:
1. This topology is highly reliable and robust. Should any individual router become
inaccessible, alternative routes can be discovered and used.
2. The use of intermediary devices in relaying data means that the range of the network can
be significantly increased, making mesh networks highly scalable.
3. Weak signals and dead zones can be eliminated by simply adding more routers to the
network.
2.10 Network layer, APS layer:
Network layer:
Network layer is also known as transmission layer. It acts like a bridge between
perception layer and application layer. It carries and transmits the information collected from the
physical objects through sensors. The medium for the transmission can be wireless or wire based.
It also takes the responsibility for connecting the smart things, network devices and networks to
each other. Therefore, it is highly sensitive to attacks from the side of attackers. It has prominent
security issues regarding integrity and authentication of information that is being transported in
the network.
Main-in-The-Middle (MiTM) Attack: MiTM attack is an attack where the attacker secretly
intercepts and alters the communication between sender and receiver who believe they are
directly communicating with each other. Since an attacker controls the communication, therefore
he or she can change messages according to their needs. It causes a serious threat to online
security because they give the attacker the facility to capture and manipulate information in real
time.
Storage Attack: The information of users is stored on storage devices or the cloud. Both storage
devices and cloud can be attacked by the attacker and user’s information may be changed toin
correct details. The replication of information associated with the access of other information by
different types of people provides more chances for attacks.
Exploit Attack: An exploit is any immoral or illegal attack in a form of software, chunks of data
ora sequence of commands. It takes advantage of security vulnerabilities in an application,
system or hardware. It usually comes with the aim of gaining control of the system and steals
information stored on a network
Application Layer:
Application layer defines all applications that use the IoT technology or in which IoT has
deployed. The applications of IoT can be smart homes, smart cities, smart health, animal
tracking, etc. It has the responsibility to provide the services to the applications. The services
may be varying for each application because services depend on the information that is collected
by sensors.
There are many issues in the application layer in which security is the key issue. In
particular, when IoT is used in order to make a smart home, it introduces many threats and
vulnerabilities from the inside and outside. To implement strong security in an IoT based smart
home, one of the main issues is that the devices used in smart homes have weak computational
power and a low amount of storage such as ZigBee. Common security threats and problem of
application layer are:
Sensors
Cross Site Scripting: It is an injection attack. It enables an attacker to insert a client-side script,
such as java script in a trusted site viewed other users. By doing so, an attacker can completely
change the contents of the application according to his needs and use original information in an
illegal way.
Malicious Code Attack: It is a code in any part of software intended to cause undesired effects
and damage to the system. It is a type of threat that may not be blocked or controlled by the
useof anti-virus tools. It can either activate itself or be like a program requiring a user’s attention
to perform an action.
The ability of dealing with Mass Data: Due to a large number of devices and a massive amount
of data transmission between users, it has no ability to deal with data processing according to the
requirements. As a result, it leads to network disturbance and data loss.
UNIT III IOT PHYSICAL DEVICES AND ENDPOINTS 9
Introduction to Arduino and Raspberry Pi- Installation, Interfaces (serial, SPI, I2C),
Programming –Python program with Raspberry PI with focus on interfacing external gadgets,
controlling output, and reading input from pins.
In case we use Arduino Nano, we will need an A to Mini-B cable instead as shown in the
following image.
Here, we have selected Arduino Uno board according to our tutorial, but you must select
the name matching the board that you are using.
Raspberry Pi
Raspberry Pi (/paɪ/) is a series of small single-board computers developed in the United
Kingdom by the Raspberry Pi Foundation in association with Broadcom. Early on, the Raspberry
Pi project leaned towards the promotion of teaching basic computer science in schools and in
developing countries. Later, the original model became far more popular than anticipated,selling
outside its target market for uses such as robotics.
It is now widely used in many areas, such as for weather monitoring, because of its low
cost, modularity, and open design. After the release of the second board type, the Raspberry Pi
Foundation set up a new entity, named Raspberry Pi Trading, and installed Eben Upton as CEO,
with the responsibility of developing technology.
The Foundation was rededicated as an educational charity for promoting the teaching of
basic computer science in schools and developing countries. The Raspberry Pi is one of the best-
selling British computers. The Raspberry Pi hardware has evolved through several versions that
feature variations in the type of the central processing unit, amount of memory capacity,
networking support, and peripheral-device support.
This block diagram describes Model B and B+; Model A, A+, and the Pi Zero are similar,
but lack the Ethernet and USB hub components. The Ethernet adapter is internally connected to
an additional USB port. In Model A, A+, and the Pi Zero, the USB port is connected directly to
the system on a chip (SoC). On the Pi 1 Model B+ and later models the USB/Ethernet chip
contains a five-port USB hub, of which four ports are available, while the Pi 1 Model B only
provides two.
On the Pi Zero, the USB port is also connected directly to the SoC, but it uses a micro
USB (OTG) port. Unlike all other Pi models, the 40 pin GPIO connector is omitted on the Pi
Zero, with solderable through-holes only in the pin locations. The Pi Zero WH remedies this.
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 MiB to 1 GiB random-access memory (RAM), with up to 8
GiB available on the Pi 4. 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 I²C. The B-models
have an 8P8C Ethernet port and the Pi 3, Pi 4 and Pi Zero W have on-board Wi-Fi 802.11n and
Bluetooth.
Raspberry Pi is a mono-board computing platform that's as tiny as a credit card. Initially
it was developed for computer science education with later on progress to wider functions. Since
the inception of Raspberry, the company sold out more than 8 million items. Raspberry Pi 3 is
the latest version and it is the first 64-bit computing board that also comes with built-in Wi-Fi
and Bluetooth functions.
According to Raspberry Pi Foundation CEO Eben Upton, "it's been a year in the
making". The Pi3 version is replaced with a quad-core 64-bit 1.2 GHz ARM Cortex A53 chip,
1GB of RAM, VideoCore IV graphics, Bluetooth 4.1 and 802.11n Wi-Fi. The developers claim
the new architecture delivers an average 50% performance improvement over the Pi 2. Another
peculiarity of Raspberry Pi is the GPIO (General Purpose Input-Output), which is a low-level
interface of self-operated control by input-output ports.
Raspberry has it as a 40-pin connector. Raspberry Pi uses Linux as its default operating
system (OS). It’s also fully Android compatible. Using the system on Windows OS is enabled
through any virtualization system like XenDesktop. If you want to develop an application for
Raspberry Pi on your computer, it is necessary to download a specific toolset comprised of
ARM-compiler and some libraries complied down to ARM-target platform like glibc.
You will get a warning message that the SD card will be overwritten (which is fine) and
then as the distribution is installed onto the SD card, you will see a progress screen accompanied
by helpful information about the distribution.
Once the file copying is complete, you will get the message Image applied successfully.
When you hit return, the Raspberry Pi will reboot and then raspi_config will automatically run so
that you can configure the new installation.
For NOOBS to install correctly onto an SD crd, the card must be formatted as FAT. Most
SD cards are supplied already formatted in FAT. If you are reusing an old card and need to
format it as FAT, then use your operating system’s tool for formatting removeable media.
Alternatively, the Raspberry Pi foundation recommends the SD Association’s formatting
tool, which is available for Mac and Windows.
Parallel Communication:
• In parallel communication, all the bits of data are transmitted simultaneously on separate
communication lines.
• Used for shorter distance.
• In order to transmit n bit, n wires or lines are used.
• More costly.
• Faster than serial transmission.
• Data can be transmitted in less time.
Example: printers and hard disk
Serial Communication:
• In serial communication the data bits are transmitted serially one by one i.e. bit by bit on single
communication line
• It requires only one communication line rather than n lines to transmit data from sender to
receiver.
• Thus all the bits of data are transmitted on single lines in serial fashion.
• Less costly.
• Long distance transmission.
Example: Telephone.
Synchronous:
• Transfers a block of data (characters) at a time.
• Requires clock signal
Example:
• SPI (serial peripheral interface),
• I2C (inter integrated circuit).
Working:
Communicate with 2 ways:
Selecting each device with a Chip Select line. A separate Chip Select line is required for
each device. This is the most common way RPi’s currently use SPI.
Daisy chaining where each device is connected to the other through its data out to the
data in line of the next.
There is no limit to the number of SPI device that can be connected. However, there are
practical limits due to the number of hardware select lines available on the main device with the
chip select method or the complexity of passing data through devices in the daisy-chaining
method.
In point-to-point communication, the SPI interface does not require addressing operations
and is full-duplex communication, which is simple and efficient.
SPI Protocol
The SPI communicates via 4 ports which are:
• MOSI – Master Data Output, Slave Data Input
• MISO – master data input, slave data output
• SCLK – clock signal, generated by the master device, up to fPCLK/2, slave mode
frequency up to fCPU/2
• NSS – Slave enabled signal, controlled by the master device, some ICs will be
labelled as CS (Chip select)
In a multi-slave system, each slave requires a separate enable signal, which is slightly
more complicated on hardware than the I2C system.
The SPI interface is actually two simple shift registers in the internal hardware. The
transmitted data is 8 bits. It is transmitted bit by bit under the slave enable signal and shift pulse
generated by the master device. The high bit is in the front and the low bit is in the back.
The SPI interface is synchronous serial data transmission between the CPU and the
peripheral low-speed device. Under the shift pulse of the master device, the data is transmitted
bit by bit.
The high bit is in the front and the low bit is in the back. It is full-duplex communication,
and the data transmission speed is overall faster than the I2C bus and can reach speeds of a few
Mbps.
Advantages of using SPI
The protocol is simple as there is no complicated slave addressing system like I2C.
It is the fastest protocol compared to UART and I2C.
No start and stop bits unlike UART which means data can be transmitted continuously
without interruption
Separate MISO and MOSI lines which means data can be transmitted and received at the
same time
Disadvantages of using SPI
More Pin ports are occupied, the practical limit to a number of devices.
There is no flow control specified, and no acknowledgement mechanism confirms whether data
is received unlike I2C
Uses four lines – MOSI, MISO, NCLK, NSS
No form of error check unlike in UART (using parity bit)
Only 1 master
I2C Interface
Stands for Inter-integrated-circuit (I2C). It is a serial communications protocol similarly
to UART. However, it is not used for PC-device communication but instead with modules and
sensors. It is a simple, bidirectional two-wire synchronous serial bus and requires only two wires
to transmit information between devices connected to the bus.
They are useful for projects that require many different parts (eg. sensors, pin, expansions
and drivers) working together as they can connect up to 128 devices to the mainboard while
maintaining a clear communication pathway!
This is because I2C uses an address system and a shared bus = many different devices
can be connected using the same wires and all data are transmitted on a single wire and have a
low pin count. However, the tradeoff for this simplified wiring is that it is slower than SPI.
Speed of I2C is also dependent by data speed, wire quality and external noise. The I2C
protocol is also used as a two-wire interface to connect low-speed devices like microcontrollers,
EEPROMs, A/D and D/A converters, I/O interfaces and other similar peripherals in embedded
systems.
Working:
It has 2 Lines which are SCL (serial clock line) and SDA (serial data line acceptance
port) CL is the clock line for synchronizing transmission. SDA is the data line through which bits
of data are sent or received.
The master device initiates the bus transfer of data and generates a clock to open the
transferred device and any addressed device is considered a slave device. The relationship
between master and slave devices, transmitting and receiving on the bus is not constant. It
depends on the direction of data transfer at the time.
If the master wants to send data to the slave, the master must first address the slave before
sending any data. The master will then terminate the data transfer. If the master wants to receive
data from the slave, the master must again address the slave first.
The host then receives the data sent by the slave and finally, the receiver terminates the
receiving process. The host is also responsible for generating the timing clock and terminating
the data transfer.
It is also necessary to connect the power supply through a pull-up resistor. When the bus
is idle, both lines operate on a high power level. The capacitance in the line will affect the bus
transmission speed. As the current power on the bus is small, when the capacitance is too large, it
may cause transmission errors. Thus, its load capacity must be 400pF, so the allowable length of
the bus and the number of connected devices can be estimated.
I2C Protocol
Data Transmission Method
The master sends the transmitting signal to every connected slave by switching the SDA
line from a high voltage level to a low voltage level and SCL line from high to low after
switching the SDA line.
The master sends each slave the 7 or 10-bit address of the slave and a read/write bit to the
slave it wants to communicate with.
The slave will then compare the address with its own. If the address matches, the slave
returns an ACK bit which switches the SDA line low for one bit. If the address does not match
its address, the slave leaves the SDA line high.
The master will then send or receive the data frame. After each data frame has been
transferred, the receiving device returns another ACK bit to the sender to acknowledge
successful transmission.
To stop the data transmission, the master sends a stop signal to the slave by switching
SCL high before switching SDA high
Clock Synchronisation
All masters generate their own clocks on the SCL line to transmit messages on the I2C
bus. Data is only valid during the high period of the clock. Clock synchronization is performed
by connecting the I2C interface to the SCL line where the switch goes from high to low. Once
the device’s clock goes low, it keeps the SCL line in this state until it reaches the high level of
the clock.
If another clock is still in a low period, the low-to-high switch does not change the state
of the SCL line. The SCL line is always held low by the device with the longest low period. At
this time, the device with a short and low period will enter a high and waiting state.
When all relevant devices have completed their low period, the clock line goes high.
After that, there is no difference in the state of the device clock and the SCL line, and all devices
begin to count their high period. The device that first completes the high period will pull the SCL
line low again.
The low period of the synchronous SCL clock is determined by the device with the
longest low clock period, while the high period is determined by the device with the shortest
high clock period.
Transmission Modes
Quick Mode:
Fast mode devices can receive and transmit at 400kbit/s. They have to be able to
synchronize with a 400kbit/s transmission and extend the low period of the SCL signal to slow
down the transmission.
Fast mode devices are backwards compatible and can communicate with standard mode
devices from 0 to 100 kbit/s I2C bus systems. However, as standard mode devices are not
upward compatible, they cannot operate in a fast I2C bus system. The fast mode I2C bus
specification has the following characteristics compared to the standard mode:
1. The maximum bit rate is increased to 400 kbit/s
2. Adjusted the timing of the serial data (SDA) and serial clock (SCL) signals.
3. Has the function of suppressing glitch and the SDA and SCL inputs have Schmitt
triggers.
4. The output buffer has a slope control function for the falling edges of the SDA and SCL
signals. Once the power supply of the fast mode device is turned off, the I/O pins of SDA
and SCL must be left idle and cannot block the bus.
5. The external pull-up device connected to the bus must be tuned to accommodate the
shortest maximum allowable rise time of the fast mode I2C bus. For buses with a
maximum load of 200pF, the pull-up device of each bus can be a resistor. For a bus with
a load between 200pF and 400pF, the pull-up device can be a current source (maximum
3mA) or a switched resistor circuit.
High-Speed Mode:
Hs mode devices can transmit information at bit rates up to 3.4 Mbit/s and remain fully
backwards compatible with fast mode or standard mode (F/S mode) devices that can
communicate bi-directionally in a speed mixed bus system.
The Hs mode transmission has the same serial bus principle and data format as the F/S
mode system except for arbitration and clock synchronization which is not performed.
The I2C bus specification in high-speed mode is as follows:
1. In high speed (Hs) mode, the master device has an open-drain output buffer for
the high-speed (SDAH) signal and an open-drain pull-down and current source
pull-up circuit at the high-speed serial clock (SCLH) output. This shortens the rise
time of the SCLH signal and at any time, only one host current source is active;
2. In the Hs mode of a multi-master system, arbitration and clock synchronization
are not performed in order to speed up the bit processing capability. The
arbitration process normally ends after the host code is transmitted in the F/S
mode.
3. The Hs mode master device generates a high and low serial clock signal with a
ratio of 1:2 which removes the timing requirements for setup and hold time.
4. The Hs mode device can have a built-in bridge. During Hs mode transmission, the
SDAH and SCLH lines of the Hs mode device are separated from the SDA and
SCL lines which reduces the capacitive loading of the SDAH and SCLH lines and
make rise and fall faster.
5. The difference between Hs mode slave devices and F/S slave devices is the speed
at which they operate.
6. The Hs mode device can suppress glitches, and the SDAH and SCLH outputs also
have a Schmitt trigger;
7. The output buffer of the Hs mode device has a slope control function for the
falling edges of the SDAH and SCLH signals.
The common Raspberry Pi distributions come with the IDLE Python development tool in both
the Python and Python 3 versions. IDLE and IDLE 3 appear identical; the only difference is the
version of Python that they use, so open IDLE 3.
The window that opens is labeled Python Shell. This is an interactive area where you can
type Python and see the results immediately. So try typing the following into the shell next to the
>>> prompt:
>>> 2 + 2
4
>>>
Python has evaluated the expression 2 + 2 and given us the answer of 4.
The Python Shell is fine for trying things out, but if you want to write programs, then you
need to use an editor. To open a new file to edit using IDLE, select New Window from the File
menu.
You can now enter your program into the editor window. Just to try things, paste the
following text into the editor, save the file as count.py, and then select Run Module from the Run
menu. You can see the results of the program running in the Python console:
for i in range(1, 10):
print(i)
Python is unusual for a programming language in that indentation is a fundamental part
of the language. Whereas many C-based languages use { and } to delimit a block of code, Python
uses the indentation level. So, in the preceding example, Python knows that print is to be invoked
repeatedly as part of the for loop because it is indented out four spaces.
Displaying Output:
>>> x = 10
>>> print(x)
10
>>>
Use the print command or print function to display output in the console.
Python also has an input function, but this validates the input and attempts to convert it
into a Python value of the appropriate type, whereas raw_input does the same thing as input in
and just returns a string.
Arithmetic:
The most common operators for arithmetic are +, -, *, and /, which are, respectively, add,
subtract, multiply, and divide. You can also group parts of the expression together with
parentheses, as shown in the following example, which, given a temperature in degrees Celsius,
converts it to degrees Fahrenheit:
Installing RPi.GPIO
A GPIO general-purpose input/output connector pin can be used as either a digital input
or a digital output, and both operate at 3.3V. Unlike the Arduino, the Raspberry Pi does not have
any analog inputs. For that you must use an external analog-to-digital converter (ADC) or
connect the Pi to an interface board (like the Gertboard) or to an Arduino or an aLaMode board.
Download and install the RPi.GPIO Python library. From a Terminal window on your Pi,
type the following commands to fetch and install the RPi.GPIO library.
$ sudo apt-get install python-dev
$ sudo apt-get install python-rpi.gpio
Run the Python program, and you will be able to change the brightness by entering a number
between 0 and 100:
pi@raspberrypi ~ $ sudo python led_brightness.py
Enter Brightness (0 to 100):0
Enter Brightness (0 to 100):20
Enter Brightness (0 to 100):10
Enter Brightness (0 to 100):5
Enter Brightness (0 to 100):1
Enter Brightness (0 to 100):90
You can exit the program by pressing Ctrl-C.
def discharge():
GPIO.setup(a_pin, GPIO.IN)
GPIO.setup(b_pin, GPIO.OUT)
GPIO.output(b_pin, False)
time.sleep(0.005)
def charge_time():
GPIO.setup(b_pin, GPIO.IN)
GPIO.setup(a_pin, GPIO.OUT)
count = 0
GPIO.output(a_pin, True)
while not GPIO.input(b_pin):
count = count + 1
return count
def analog_read():
discharge()
return charge_time()
while True:
print(analog_read())
time.sleep(1)
The reading will vary between about 10 and about 170 as you rotate the knob of the
trimpot.