F-IoT Unit-2
F-IoT Unit-2
F-IoT Unit-2
Presented By:
G. Kiran Kumari
Assistant Professor
Department of ECE
Anurag College of Engineering
Syllabus
UNIT – II
Machine-to-Machine Communications,
Difference between IoT and M2M,
Interoperability in IoT, Introduction to
Arduino Programming, Integration of
Sensors and Actuators with Arduino.
3
Anurag College of Engineering
Fig. M2M System Architecture
Anurag College of Engineering 4
Machine-to-Machine (M2M) cont’d
5
Anurag College of Engineering
Machine-to-Machine (M2M) cont’d
7
Anurag College of Engineering
Fig. Block Diagram of M2M Gateway
8
Anurag College of Engineering
M2M gateway cont’d
• The communication between M2M nodes and the M2M
gateway is based on the communication protocols
which are native to the M2M area network.
• M2M gateway performs protocol translations to enable
IP-connectivity for M2M area 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.
11
Anurag College of Engineering
Difference between IoT and M2M
The differences between M2M and IoT are:
1. Communication Protocols:
• M2M and IoT can differ in how the communication between
the machines or devices happens.
• M2M uses either proprietary or non-IP based
communication protocols for communication within the
M2M area networks.
• Commonly used M2M protocols include ZigBee, Bluetooth,
ModBus, M-Bus, Wireless M-Bus, Power Line
Communication (PLC), 6LoWPAN, IEEE 802.15.4, Z-Wave
etc.
• The focus of communication in M2M is usually on the
protocols below the network layer.
• The focus of communication in IoT is usually on the
protocols above the network layer such as HTTP, CoAP,
WebSockets, MQTT, XMPP, DDS, AMQP , etc.
12
Anurag College of Engineering
Difference between IoT and M2M
2. Machines in M2M Vs Things in IoT:
• The "Things" in IoT refers to physical objects that have
unique identifiers and can sense and communicate with their
external environment (and user applications) or their internal
physical states.
• The unique identifiers for things in IoT are the IP addresses
(or MAC addresses).
• Things have software components for accessing, processing
and storing sensor information or controlling actuators
connected.
• IoT systems can have heterogeneous things (eg. a home
automation IoT system can include IoT devices of various
types such as fire alarms, door alarms, lighting control
devices, etc).
• M2M systems, in contrast to IoT, typically have
homogeneous machine types within an M2M area network.
13
Anurag College of Engineering
Difference between IoT and M2M
3. Hardware Vs Software Emphasis:
14
Anurag College of Engineering
Difference between IoT and M2M
4. Data Collection & Analysis:
15
Anurag College of Engineering
Difference between IoT and M2M
5. Applications:
✓ Device interoperability
✓ Networking interoperability,
✓ Syntactic interoperability,
✓ Semantic interoperability, and
✓ Platform interoperability.
20
Anurag College of Engineering
Device interoperability
• IoT is composed of a variety of devices.
• These devices, which are called “smart objects/things”,
may consist of high-end devices or low-end devices .
• The high-end IoT devices have enough resources and
computational capabilities such as Raspberry Pi and smart
phones.
• On the other hand, the low-end IoT devices are resource-
constrained in terms of energy, processing power and
communication capabilities than typical hosts such as
RFID tags, tiny and low-cost sensors and actuators, etc.
• The devices that want to exchange information may be
using different communication technologies which
requires interoperability between the different types of
heterogeneous devices that co-exist in the IoT ecosystem 21
Anurag College of Engineering
Device interoperability
• Device interoperability refers to enabling the
integration and interoperability of heterogeneous
devices with various communication protocols
and standards supported by heterogeneous IoT
devices.
• Device interoperability is concerned with
(i) the exchange of information between
heterogeneous devices and heterogeneous
communication protocols and
(ii) the ability to integrate new devices into any
IoT platform.
Anurag College of Engineering 22
Networking interoperability
23
Anurag College of Engineering
Networking interoperability
• Network level interoperability deals with mechanisms to
enable seamless message exchange between systems
through different networks (networks of networks) for
end-to-end communication.
• To make systems interoperable, each system should be
able to exchange messages with other systems through
various types of networks.
• Due to the dynamic and heterogeneous network
environment in IoT, the network interoperability level
should handle issues such as addressing, routing,
resource optimization, security, QoS, and mobility
support.
24
Anurag College of Engineering
Syntactical interoperability
25
Anurag College of Engineering
Syntactical interoperability
26
Anurag College of Engineering
Semantic interoperability
• Semantic interoperability is defined as “enabling
different agents, services, and applications to
exchange information, data and knowledge in a
meaningful way, on and off the Web”.
• The WoT addresses the current fragmentation by
exposing things and systems data and metadata
through API. But, such efforts have been hampered
because the corresponding parties need to share
knowledge of an API and many devices do not speak
the same language and cannot exchange across
different gateways and smart hubs .
Anurag College of Engineering 27
Semantic interoperability
• To be more precise, the data generated by things about
the environment may have a defined data format (e.g.
JSON, XML or CSV), but the data models and schemas
used by different sources are usually dissimilar and not
always compatible.
• Besides, the data may be represented in diverse units of
measurements and consist of other information.
• This semantic incompatibility between data models and
information models results in IoT systems not being able
to dynamically and automatically interoperate as they
have different descriptions or understandings of resources
and operational procedures, even if IoT systems expose
their data and resources to others .
Anurag College of Engineering 28
Platform interoperability
• Platform interoperability issues in IoT arises due to the
availability of diverse operating systems (OSs), programming
languages, data structures, architectures and access mechanisms
for things and data.
• There are currently many different OS developed specifically for
IoT devices such as Contiki, RIOT, TinyOS and OpenWSN , each
with several versions, to deliver services to users. Besides, the IoT
platform providers such as Apple HomeKit, Google Brillo,
Amazon AWS IoT, and IBM Watson provide different Oss,
programming languages, and data structures.
• For example, Apple HomeKit supports its own open source
language Swift, Google Brillo uses Weave, and Amazon AWS IoT
offers SKDs for embedded C and NodeJS.
• This non-uniformity causes hindrance for application developers
to develop cross-platform and cross-domain IoT applications. 29
Anurag College of Engineering
Platform interoperability
• Developers need to obtain extensive knowledge
of the platform specific APIs and information models of
each different platform to be able to adapt their
applications from one platform to another.
• A cross-platform IoT application can access different IoT
platforms and integrate data from various platforms.
• For example, consider the following application
scenario: a user who has health problems uses an IoT
cross-platform application every day to help him with his
everyday tasks. The IoT application connects to the
user’s smart health platform of wearable sensors to
continuously monitor his health conditions (heart rate,
fall situation, and glucose level) and in an emergency,
30
locates him and sends an ambulance. Anurag College of Engineering
Platform interoperability
31
Anurag College of Engineering
Introduction to Arduino Programming
• One of the greatest advances in physical computing has
been the proliferation of microcontrollers.
• A microcontroller consists of a processor with a small
instruction set, memory, and programmable input/output
circuitry contained on a single chip.
• Microcontrollers are usually packaged with supporting
circuitry and connections on a small printed circuit board.
• Microcontrollers are used in embedded systems where small
software programs can be tailored to control and monitor
hardware devices, making them ideal for use in sensor
networks.
• PIC microcontroller, ARM microcontroller, 8051
microcontroller, AVR microcontroller, MSP microcontroller 32
Anurag College of Engineering
What is an Arduino?
• The Arduino is an open source hardware prototyping
platform supported by an open source software
environment.
• It was first introduced in 2005 and was designed with the
goal of making the hardware and software easy to use
and available to the widest audience possible.
• We do not have to be an electronics expert to use the
Arduino.
• The original target audience included artists and
hobbyists who needed a microcontroller to make their
designs and creations more interesting.
33
Anurag College of Engineering
What is an Arduino?
• Because of its ease of use and versatility, the Arduino
has quickly become the choice for a wider audience and a wider
variety of projects.
• We can use the Arduino for all manner of projects from reacting
to environmental conditions to controlling complex robotic
functions.
• The Arduino has also made learning electronics easier through
practical applications.
• Another aspect that has helped the rapid adoption of the Arduino
platform is the growing community of contributors to a wealth
of information made available through the official Arduino web
site (http://arduino.cc/en/).(“getting started” tutorial as well as a
list of helpful project ideas and a full reference guide to the C-
like language for writing the code to control the Arduino (called
34
a sketch). Anurag College of Engineering
Arduino
35
Anurag College of Engineering
Arduino
• The Arduino supports a number of analog and
digital pins that we can use to connect to various devices
and components and interact with them.
• The mainstream boards have specific pin layouts, or
headers, that allow the use of expansion boards called
shields.
• Shields lets us to add additional hardware capabilities
such as Ethernet, Bluetooth, and XBee support to our
Arduino.
• The physical layout of the Arduino and the shield allow
us to stack shields.
• Thus, we can have an Ethernet shield as well as an XBee
shield, because each uses different I/O pins.
Anurag College of Engineering
36
Arduino Models
• A number of Arduino boards are available.
• Some are configured for special applications, whereas
others are designed with different processors and
memory configurations.
• Some boards are considered official Arduino boards
because they are branded and endorsed by Arduino.cc.
• Because the Arduino is open source and, more
specifically, licensed using a Creative Commons
Attribution Share-Alike license, anyone can build
Arduino-compatible boards (often called Arduino
clones).
37
Anurag College of Engineering
Arduino Models
• The basic layout of an Arduino board consists of a USB
connection, a power connector, a reset switch, LEDs for
power and serial communication, and a standard spaced
set of headers for attaching shields.
• The official boards sport a distinctive blue-colored PCB
with white lettering.
• With the exception of one model, all the official boards
can be mounted in a chassis (they have holes in the PCB
for mounting screws). The exception is an Arduino
designed for mounting on a breadboard.
38
Anurag College of Engineering
Arduino Models
• Arduino Uno
• Arduino Leonardo
• Arduino Due
• Arduino Mega 2560
• Arduino Mini
• Arduino Micro
• Arduino Nano
39
Anurag College of Engineering
Arduino Uno
40
Anurag College of Engineering
Arduino Uno
.
Anurag College of Engineering 43
Arduino Leonardo
• It has 32KB of flash memory and 2.5KB of SRAM
• The USB connection uses a smaller USB connector. The
board is also available with and without headers.
.
Anurag College of Engineering 44
Arduino Due
• The Arduino Due is a new, larger, and faster board based
on the Atmel SAM3X8E ARM Cortex-M3 processor.
• The processor is a 32-bit processor, and the board
supports a massive 54 digital I/O ports, of which 14 can
be used for PWM output; 12 analog inputs; and 4 UART
chips (serial ports); as well as 2 digital-to-analog (DAC)
and 2 two-wire interface (TWI) pins.
• The new processor offers several advantages:
• 32-bit registers
• DMA controller (allows CPU-independent memory tasks)
• 512KB flash memory
• 96KB SRAM
45
• 84MHz clock Anurag College of Engineering
Arduino Due
• The new board has one distinct limitation:
unlike other boards that can accept up to 5V on the I/O
pins, the Due is limited to 3.3V on the I/O pins.
• The Arduino Due is intended to be used for projects that
require more processing power, more memory and more
I/O pins.
• Despite the significant capabilities of the new board it
remains open source and comparable in price to its
predecessors.
46
Anurag College of Engineering
Arduino Due
.
Anurag College of Engineering 47
Arduino Mega 2560
• The Arduino Mega 2560 is an older form of the Due.
• It is based on the ATmega2560 processor (hence the name).
• The board supports a massive 54 digital I/O ports, of which 14
can be used as PWM output; 16 analog inputs; and 4 UARTs
(hardware serial ports).
• It uses a 16MHz clock and has 256KB of flash memory.
• The Mega 2560 is essentially a larger form of the standard
Arduino (Uno, Duemilanove, etc.) and supports the standard
shields.
• Arduino Mega 256 is the board of choice for Prusa Mendel
and similar 3D printers that require the use of a controller
board named RepRap Arduino Mega Pololu Shield (RAMPS)
48
Anurag College of Engineering
Arduino Mega 2560
49
Anurag College of Engineering
Arduino Mini
• The Arduino Mini is a small form-factor board
designed for use with breadboards.
• Thus, it has all its pins arranged in male headers that plug
directly into a standard breadboard.
• It is based on the ATmega328 processor (older models use
the ATmega168) and has 14 digital I/O pins, of which 6 can
be used as PWM output, and 8 analog inputs.
• The Mini has 32KB of flash memory and uses a 16MHz
clock.
• Unlike other Arduino boards, the Mini does not have a USB
connector. To connect to and program the Mini, you must use
a USB Serial adapter or RS232-to-TTL serial adapter.
• The Mini has a limitation with regard to input voltage. We
should avoid voltages over 9V
Anurag College of Engineering
50
Arduino Mini
53
Anurag College of Engineering
Arduino Nano
• The Arduino Nano is an older form of the Arduino
Micro.
• In this case, it is based on the functionality of the
Duemilanove4 and has the ATmega328 processor (older
models use the ATmega168) and 14 digital I/O pins, of
which 6 can be used as PWM output, and 8 analog
inputs.
• Like the Micro, it has all the features needed for
connecting to and programming via a USB connection.
54
Anurag College of Engineering
Arduino Nano
58
Anurag College of Engineering
Basic Arduino Sketch Structure
59
Anurag College of Engineering
• Once the IDE launches, we see a simple
interface with a text editor area (a white background by
default), a message area beneath the editor (a black
background by default), and a simple button bar at the
top.
• The buttons are (from left to right) Compile, Compile
and Upload, New, Open, and Save.
• There is also a button to the right that opens the serial
monitor.
• We use the serial monitor to view messages from the
Arduino sent (or printed) via the Serial library.
60
Anurag College of Engineering
Arduino Sketch Structure
• A basic Arduino sketch consists of two functions called
(i) setup() and
(ii) loop().
• These two functions appear in a default new Arduino IDE
window.
• All functions must have a unique name, setup is one
example of a unique function name (setup and loop are
special functions in Arduino programming and form part of
the structure of a basic sketch).
• The function name is followed by opening and closing
parentheses () that may or may not contain something.
• All functions must have a return type.
Both setup and loop have a void return type.
• The body of a function consists of an opening and closing
brace ({ and }).
61
Anurag College of Engineering
"Hello, world!" Sketch Example
63
Anurag College of Engineering
Parts of a Sketch
• The image below shows the parts of an Arduino sketch.
• Statements are lines of code that are executed as the
program runs.
• Each statement is terminated with a semicolon.
64
Anurag College of Engineering
Integration of Sensors and Actuators
with Arduino
Program :
To illuminate LED whenever the button is pushed
65
Anurag College of Engineering
Program
To illuminate LED whenever the button is pushed
Note: At the bottom that it tells that we are programming an Arduino Uno board on a
specific serial port
Anurag College of Engineering 67
• One of the first things to be done when we start the
IDE is choose the board from the Tools ➤ Board menu.
• We see a number of boards available.
• Be sure to choose the one that matches our board.
• If we are using a clone board, check the manufacturer’s
site for the recommended setting to use.
• If we choose the wrong board, we typically get an error
during upload, but it may not be obvious that you’ve
chosen the wrong board.
68
Anurag College of Engineering
Fig. Choosing the Arduino board
Anurag College of Engineering 69
• After choosing board, the next thing need to
be done is to choose the serial port to which
the Arduino board is connected.
• To connect to the board, use the Tools ➤
Serial Port menu option.
73
Anurag College of Engineering
Hardware Connections
Assembling an Arduino:
74
Anurag College of Engineering
Fig. Diagram of an LED with a pushbutton
75
Anurag College of Engineering
• Now wire a jumper from the power rail to one
side of the pushbutton, and wire the other side of the
pushbutton to (DIGITAL) pin 2 on the Arduino (located
on the side with the USB connector).
• Next, wire the LED to ground on the breadboard and a
150-Ohm resistor. The other side of the resistor should be
wired to pin 13 on the Arduino.
• A resistor is required to pull the button low when the
button is not pressed.
• Place a 10K Ohm resistor on the side of the button with
the wire to pin 2 and ground. The longest side of the LED
is the positive side. The positive side should be the one
connected to the resistor. Resistor is used to limit the
current to the LED. Anurag College of Engineering 76
Writing the Sketch
• The sketch needed for this project uses two I/O pins on
the Arduino: one output and one input.
• The output pin will be used to illuminate the LED, and
the input pin will detect the pushbutton engagement.
• Connect positive voltage to one side of the pushbutton
and the other side to the input pin. When we detect
voltage on the input pin, we tell the Arduino processor to
send positive voltage to the output pin.
• Here, the positive side of the LED is connected to the
output pin. As in Figure, the input pin is pin 2 and the
output pin is pin 13.
Anurag College of Engineering 77
Writing the Sketch