Internet of Things (IOT)
Skill Based Subject 1
B.Sc AI & ML
III Semester
YUVARAJ S
Asst. Professor and Head of IT/CS
Dr. R.A.N.M ARTS AND SCIENCE COLLEGE
Rangampalayam, Erode - 638009
Affiliated to Bharathiar University
Department of
Computer Science / Information Technology
Computer Applications / Artificial Intelligence and Machine Learning
Internet of Things (IoT)
Internet of Things is a system of interrelated computing devices or objects which have the ability to transfer the data over a network without requiring any human to human or human to computer interaction uniquely addressable, based on standard communication protocol.
It is a giant network of connected things, capturing the data about the way they are used and the environment around them. When we speak about the “Things” in IoT, these are objects not precisely identifiable.
The sensors are used in the devices and objects and these feed the data to various IoT platforms. Further, IoT platforms are used to gather the pinpointed information, detect patterns.
Thus, with the above process the IoT helps the organizations and institutions in reducing the cost through improved processes efficiency, asset utilization and productivity.
Different Names of IoT
• Internet of Everything
• Smarter Planet
• Machine to Machine (M2M)
• The Fog
• Tsensors (Trillion Sensors)
• The Industrial Internet
• Industry 4.0
• Internet of Things (IoT)
Reasons of IoT
IOT Enablers
M2M Communication – Key Elements
The Arduino UNO has 14 digital I/O pins and 6 Analog inputs. The digital I/O pins are 5V logic level and you can also use the Analog pins as digital I/O too. Arduino UNO supports 6 channel 10 bit ADC inputs through A0-A5, which can be sampled and analyzed using UNO. Uno has 4 LEDs onboard.
What is the Arduino hardware?
In a nutshell, an Arduino is an open hardware development board that can be used by tinkerers, hobbyists, and makers to design and build devices that interact with the real world.
Arduino programs are written in the Arduino Integrated Development Environment (IDE). Arduino IDE is a special software running on your system that allows you to write sketches (synonym for program in Arduino language) for different Arduino boards. The Arduino programming language is based on a very simple hardware programming language called processing, which is similar to the C language. After the sketch is written in the Arduino IDE, it should be uploaded on the Arduino board for execution.
The first step in programming the Arduino board is downloading and installing the Arduino IDE. The open source Arduino IDE runs on Windows, Mac OS X, and Linux. Download the Arduino software (depending on your OS) from the official website and follow the instructions to install.
Basic of Arduino Programming
The Raspberry Pi is a tiny computer about the size of a deck of cards. It uses what's called a system on a chip, which integrates the CPU and GPU in a single integrated circuit, with the RAM, USB ports, and other components soldered onto the board for an all-in-one package.
What is Raspberry Pi
What is a Raspberry Pi used for?
It's capable of doing everything you'd expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games.
�
The Raspberry Pi has CPU, RAM and GPU in one component called System on Chip (SoC). It uses an ARM1176JZF-S 700 MHz CPU which is single core and also has a co-processor for floating point calculations. The working memory in Raspberry pi is 512 MB SDRAM.
The Raspberry Pi comes with a high-speed 64-bit quad-core processor with clock speed up to 1GHz, dual-display support at resolutions up to 4K via a pair of micro-HDMI ports, hardware video decode at up to 4Kp60, up to 4GB of RAM, dual-band 2.4/5.0 GHz wireless LAN.
The Raspberry Pi 3
Programming with Raspberry Pi
The Raspberry Pi is an amazing single board computer (SBC) capable of running Linux and a whole host of applications.
Most commonly, the Pi is used as a standalone computer, which requires a monitor, keyboard, and mouse (listed below). To save on costs, the Pi can also be used as a headless computer (without a monitor, keyboard, and mouse). This setup has a slightly more difficult learning curve, as you will need to use the command-line interface (CLI) from another computer.
Install the OS
You have a few options when it comes to interacting with the Raspberry Pi. The first and most common is to use it like you would a full desktop computer (just smaller). This involves connecting a keyboard, mouse, and monitor. With this setup, you are likely best served by installing Raspbian with Desktop, which gives you a full graphical user interface (GUI) to work with. This is the best option if you want an experience similar to working with other operating systems (OS), such as Windows, macOS, or other popular Linux flavors, like Ubuntu.
The other option is to create a headless setup, which means you can skip the monitor, keyboard, and mouse. While this is the cheaper way to go, it means you'll need to be open to performing all your actions in the command line interface. For this, you will want either Raspbian with Desktop or Raspbian Lite operating systems.
Option 1: Full Desktop Setup
The Raspberry Pi 3 Starter Kit Hookup Guide offers a great walkthrough to setting up your Raspberry Pi with NOOBS (Raspberry Pi's easy-to-use graphical OS installer).
Option 2: Headless Pi
If you want to skip the keyboard, mouse, and monitor, you can install Raspbian Lite. This will allow you to get a terminal into your Pi using SSH or Serial on another computer. The Headless Raspberry Pi Setup walks you through setting up your Raspberry Pi without a graphical interface.
If you have the Raspberry Pi Starter Kit, you can attach the Pi Wedge to the Pi over the provided ribbon cable, and connect the FTDI Breakout board to the Pi Wedge. From here, connect a USB cable between your computer and the FTDI Breakout board. This will allow you to open a Serial terminal to your Raspberry Pi
Configure Your Pi
Regardless of whether you are using the full desktop or a headless setup, you will need to perform some basic configuration steps on your new Raspberry Pi installation. These steps can be easily performs from a terminal (a text input/output environment).
Full Desktop: You should be automatically logged into the X windows manager (otherwise known as the desktop). To open a terminal, simply click on the Terminal icon on the top left of the desktop. You should be immediately presented with a command prompt in a terminal window.
Headless: With a headless setup, everything you do will be through a terminal. When you connect to your Pi through Serial or SSH, you will be presented with a login prompt on the terminal. Enter the default credentials:
Username: pi
Password: raspberry
You will be presented with a command prompt.
The simplest way to create Python programs is to write your code in a text editor (e.g. nano, vim, emacs, Midnight Commander, Leafpad, etc.), save it, and then run it from the terminal with the command python <FILE>.py
Some users prefer to use an integrated development environment (IDE) when developing code. IDEs offer a number of benefits including syntax highlighting, code completion, one-click running, debugging hints, etc. However, most IDEs require a graphical interface to use, which means you will need to be on the full desktop version of Raspbian.
IDLE is the default Python editor that has been available on Raspbian for many generations. The good news is that it has a built-in interpreter, which allows you to run commands one at a time to test code. The bad news is that it doesn't show line numbers, and it only works with Python.
Open IDLE by selecting the Raspberry Pi logo in the top-left, and click Programming > Python 3 (IDLE). You should be presented with the Python interactive interpreter.
�
To write a program, go to File > New File. Enter in your code.
Click File > Save As... to save your code to a Python file (don't forget the .py suffix!). Click Run > Run Module to run your program.
The system consists of three modules namely WINGZ (Wireless IP Network Gateway for Zigbee), Ubimote (Wireless ZigBee mote with generic sensor interface) and Ubi-Sense (Generic Sensor board) for application case study. The Gateway Related hardware and software systems enable anywhere connectivity of networked sensors.
Ubimote
Bluetooth Low Energy is a wireless, low-power personal area network that operates in the 2.4 GHz ISM band. Its goal is to connect devices over a relatively short range. BLE was created with IoT applications in mind, which has particular implications for its design.
BLE mote
Wing Gateway is a high performance reverse proxy and load balance module for Wing FTP Server, it avoids opening unnecessary inbound ports and prevents sensitive data from being stored in the DMZ, Wing Gateway can provide reverse proxy function for all the WingFTP supported protocols - FTP/FTPS/SFTP/HTTP/HTTPS, clients .
WINGZ Gateway
An IoT platform is an application or service that provides built-in tools and capabilities to connect every “thing” in an IoT ecosystem. By providing functions including device lifecycle management, device communication, data analytics, integration, and application enablement.
IoT platform
The 4 Types of IoT Platforms
IoT Connectivity Platforms. An IoT Connectivity Platform is used to manage and monitor the communication protocols that connect devices across WiFi, bluetooth, and mobile internet.
IoT Device Management Platforms.
IoT Application Enablement Platforms.
IoT Analytics Platforms.
Most embedded IoT devices are programmed in the C language, whereas the C++ language is generally the preferred choice for more complex Linux implementations. Python is perfect for data-intensive applications.
Sensors:
– They are mainly input components
– They sense and collect surrounding information – Basically three types:
• Passive, omni directional (e.g. mic)
• Passive, narrow-beam sensor (e.g. PIR)
• Active sensors (e.g. sonar, radar, etc.)
Actuators:
– They are mainly output components – They alter the surrounding.
– Some examples:
• Adding lighting, heat, sound, etc.
• Controlling motors to move objects
• Displaying messages
• and others…
The benefit and value of IoT comes from enabling the components to communicate; this ability to communicate is what moves data from endpoint devices through the IoT pipeline to central servers.
This communication happens via IoT protocols, which ensure that data sent from endpoint devices, such as sensors, is received and understood by the next and subsequent steps in the connected environment, whether the next step for that data is to another endpoint device or a gateway or an application.
IOT Protocols
Not every IoT communication protocol is right for every deployment or device. Consider the power and security requirements before choosing one protocol over another.
There were 11.7 billion IoT connections in 2020 versus 10 billion non-IoT connections -- e.g., smartphones and computers -- according to market research firm IoT Analytics. And researchers there estimated the number of IoT connections will swell to 30.9 billion by 2025.
The availability and expansion of IoT protocols, including 5G and low-power WANs, drives and supports much of that growth.
Although protocols as a collective group are essential to making IoT work, protocols aren't all created equal. Not all protocols work, or work well, in every circumstance, some protocols work well for IoT use in buildings, some are well suited for IoT deployments spread among buildings and others work well for national or global IoT use cases.
IoT Data Link Communication Protocol
The IoT Data Link communication protocol provides service to the Network Layer. There are various protocols and standard technologies specified by the different organization for data link protocols.
Bluetooth
Bluetooth is a short-range wireless communication network over a radio frequency. Bluetooth is mostly integrated into smartphones and mobile devices. The Bluetooth communication network works within 2.4 ISM band frequencies with data rate up to 3Mbps.
There are three categories of Bluetooth technology:
Bluetooth Classic
Bluetooth Low Energy
Bluetooth SmartReady
The features of Bluetooth 5.0 version is introduced as Bluetooth 5 which have been developed entirely for the Internet of Things.
Properties of Bluetooth Network
Standard: Bluetooth 4.2
Frequency: 2.4GHz
Range: 50-150m
Data transfer rates: 3Mbps
Advantages of Bluetooth Network
It is wireless.
It is cheap.
It is easy to install.
It is free to use if the device is installed with it.
Disadvantages of Bluetooth Network
It is a short-range communication network.
It connects only two devices at a time.
Bluetooth Low Energy
Bluetooth low energy (BLE) is a short-range communication network protocol with PHY (physical layer) and MAC (Medium Access Control) layer. It is designed for low-power devices which uses less data. BLE always remain in sleep mode except when the connection between devices is initiated and data transmission occurs, due to this it conserves power of the device. Bluetooth low energy follows the master/slave architecture and offers two types of frames that are adverting and data frames. Slave node sent the advertising frame to discover one or more dedicated advertisement channels. Master nodes sense this advertisement channels to find slaves and connect them.
Z-Wave
Z-Wave is a wireless communication protocol with the frequency of 900MHz. The ranges of Z-Wave lies between 30 meters to 100 meters with the data transfer rate of 100kbps so that it is suitable for small messages in IoT applications for home automation. This communication protocol operates on mesh network architecture with one and several secondary controllers.
�
Properties of Z-Wave protocol
Standard: Z-Wave Alliance ZAD12837 / ITU-T G.9959
Frequency: 908.42GHz
Range: 30-100m
Data transfer rate: 100kbps
Advantages of Z-Wave protocol
Low power consumption
Remote or local control
Simple installation
Interoperability
Application of Z-Wave protocol
Smart product and IoT based application
Energy saving
Home security
ZigBee Smart Energy
ZigBee is a low power, low data rate wireless personal area network communication protocol. It is mostly used in home automation and industrial settings. Since ZigBee is a low power communication protocol, the IoT power devices used with ZigBee technology. The ZigBee communication protocol is based on the IEEE 802.15.4 standard operating at the 2.4GHz frequency. The ZigBee protocol supports star, cluster or wireless mesh technology topology.
ZigBee uses the following devices in its network:
Zigbee Coordinator
Zigbee End Device
Zigbee Router
Properties of ZigBee protocol
Standard: ZigBee 3.0 based on IEEE802.15.4
Frequency: 2.4GHz
Range: 10-100m
Data transfer rate: 250kbps
Advantages of ZigBee protocol
Wireless
Mesh networking
Direct communication
Low power consumption
Disadvantages of ZigBee protocol
Costly
Works with low speed within a small distance
Application of ZigBee protocol
Commercial and residential control
Personal and healthcare
Home networking
Industrial control and management
Consumer electronics
LoRaWAN
LoRaWAN refers to Long Rage Wide Area Network which is a wide area network protocol. It is an optimized low-power consumption protocol design to support large-scale public networks with millions of low-power devices. A single operator operates the LoRaWAN. The LoRaWAN network is a bi-directional communication for IoT application with low cost, mobility, and security.
Properties of LoRaWAN protocol
Standard: LoRaWAN
Frequency: Various
Range: 2-5km (urban environment), 15km (suburban environment)
Data Rates: 0.3-50 kbps.
IoT Network Layer Protocols
The network layer is divided into two sublayers: routing layer which handles the transfer of packets from source to destination, and an encapsulation layer that forms the packets.
RPL Protocol
RPL stands for Routing Protocol for Low-Power and Lossy Network. It is a distance-vector protocol that supports a varity of Data Link Protocols. RPL builds a Destination Oriented Directed Acyclic Graph (DODAG) which has only one route from each leaf node to the root. All the traffic in this DODAG is routed through the root. Initially, each node sends a DODAG Information Object (DIO) announcing them self as a root. This information travels in the network, and complete DODAG is gradually built. When a new node wants to join the network, it sends a DODAG Information Solicitation (DIS) request and root responds back with a DAO Acknowledgment (DAO-ACK) confirming the join.
CORPL Protocol
CORPL protocol is the extension of the RPL protocol, which is termed as cognitive RPL. This network protocol is designed for cognitive networks and uses DODAG topology. CORPL protocol makes two new modifications in the RPL protocol. It uses opportunistic forwarding to forward a packet between the nodes. Each node of CORPL protocol keeps the information of forwarding set rather than parents only maintaining it. Each node updates its changes to its neighbor using DIO messages. On the basis of this updated message, each node frequently updates its neighbor for constant forwarder set.
CARP Protocol
CARP (Channel-Aware Routing Protocol) is a distributed routing protocol. It is designed for underwater communication. It has lightweight packets so that it can be used for Internet of Things (IoT). It performs two different functionalities: network initialization and data forwarding. CARP protocol does not support previously collected data. Hence, it is not beneficial for those IoT or other application where data is changed frequently. The upgradation of CARP is done in E-CARP which overcomes the limitation of CARP. The E-CARP allows the sink node to save previously received sensory data.
6LoWPAN
The 6LoWPAN protocol refers to IPv6 Low Power Personal Area Network which uses a lightweight IP-based communication to travel over low data rate networks. It has limited processing ability to transfer information wirelessly using an internet protocol. So, it is mainly used for home and building automation. The 6LoWPAN protocol operates only within the 2.4 GHz frequency range with 250 kbps transfer rate. It has a maximum length of 128-bit header packets.
6LowPAN Security Measure
Security is a major issue for 6LowPAN communication Protocol. There are several attacks issues at the security level of 6LoWPAN which aim is to direct destruction of the network. Since it is the combination of two systems, so, there is a possibility of attack from two sides that targets all the layer of the 6LoWPAN stack (Physical layer, Data link layer, Adaptation layer, Network layer, Transport layer, Application layer).
Standard: RFC6282
Frequency: Used over a variety of other networking media including Bluetooth Smart (2.4GHz) or ZigBee or low-power RF (sub-1GHz)
Range: NA
Data Rates: NA
Properties of 6LowPAN protocol
Network Layer Encapsulation Protocols
IoT System Model The routing layer and encapsulation layer forms the network layer (Figure). The routing layer manages packet transfer from source to destination and the packet is generated by the encapsulation layer. Routing for Low Power and Lossy Networks (RPL), Cognitive RPL (CORPL), Channel Aware Routing Protocol (CARP) are some of the protocols used at the routing layer. The protocols used in the encapsulation layer include: 6LoWPAN, 6TiSCH, 6Lo, IPv6 over G.9959 and IPv6 over Bluetooth Low Energy
Encapsulation is the computer-networking process of concatenating layer-specific headers or trailers with a service data unit (i.e. a payload) for transmitting information over computer networks.[2][3][4] Deencapsulation (or de-encapsulation) is the reverse computer-networking process for receiving information; it removes from the protocol data unit (PDU) a previously concatenated header or tailer that an underlying communications layer transmitted
The result of encapsulation is that each lower-layer provides a service to the layer or layers above it, while at the same time each layer communicates with its corresponding layer on the receiving node. These are known as adjacent-layer interaction and same-layer interaction, respectively.
IoT Session Layer Protocols
The session layer protocols review standards and protocols for message passing. Different standardization organizations introduce the IoT session layer protocols. There are different types of session layer protocol available with different functionality and range. MQTT and CoAP provide these needs through small message sizes, message management, and lightweight message overhead.�
MQTT (Message Queue Telemetry Transport)
MQTT (Message Queue Telemetry Transport) is a messaging protocol which was introduced by IBM in 1999. It was initially built for monitoring sensor node and faraway tracking in IoT. Its suits are small, cheap, low-memory and low-power devices. MQTT provides embedded connectivity between applications and middleware in one side and another side it connects networks and communicators.
MQTT protocol is based on publish/subscribe architecture. The publish/subscribe architecture consists of three major components: publishers, subscribers, and a broker. According to IoT point of view, publishers are lightweight sensor devices that send their data to connected broker and goes back to sleep whenever possible. Subscribers are applications, which are interested in a certain topic or sensory data, so they are connected to brokers to be informed whenever new data are received. The broker receives the sensory data and filters them in different topics and sends them to subscribers according to interest in the topics.
SMQTT (Secure Message Queue Telemetry Transport)
SMQTT (Secure Message Queue Telemetry Transport) is an extension of MQTT protocol which uses encryption based on lightweight attribute encryption. The main advantage of this encryption is that it has a broadcast encryption feature. In this features, one message is encrypted and delivered to multiple other nodes. The process of message transfer and receiving consists of four major stages:
Setup: In this phase, the publishers and subscribers register themselves to the broker and get a secret master key.
Encryption: When the data is published to broker, it is encrypted by broker.
Publish: The broker publishes the encrypted message to the subscribers.
Decryption: Finally the received message is decrypted by subscribers with the same master key.
SMQTT is proposed only to enhance MQTT security feature.
CoAP
CoAP (Constrained Application Protocol) is a session layer protocol that provides the RESTful (HTTP) interface between HTTP client and server. It is designed by IETF Constrained RESTful Environment (CoRE) working group. It is designed to use devices on the same constrained network between devices and general nodes on the Internet. CoAP enables low-power sensors to use RESTful services while meeting their low power constraints. This protocol is specially built for IoT systems primarily based on HTTP protocols.
This network is used within the limited network or in a constrained environment. The whole architecture of CoAP consists of CoAP client, CoAP server, REST CoAP proxy, and REST internet.
The data is sent from CoAP clients (such as smartphones, RFID sensors, etc.) to the CoAP server and the same message is routed to REST CoAP proxy. The REST CoAP proxy interacts outside the CoAP environment and uploads the data over REST internet.
DDS
DDS (Data Distribution Service) is a middleware (sometimes called machine-to-machine (M2M)) communication protocol. It is implemented by the Object Management Group (OMG) standard for the real-time system with high speed and high-performance, scalable, dependable, and interoperable data exchange. This communication protocol is based on a publish-subscribe pattern for sending and receiving data, events, and commands among the nodes.
The DDS protocol has two main layers:�
Data-Centric Publish-Subscribe (DCPS): This layer delivers the information to subscribers.
Data-Local Reconstruction Layer (DLRL): This layer provides an interface to DCPS functionalities, permitting the sharing of distributed data amongst IoT enabled objects.
�
IOT Security Protocols
IoT protocols are modes of communication that protect and ensure optimum security to the data being exchanged between connected devices. The IoT devices are typically connected to the Internet via an Internet Protocol network. However, devices such as Bluetooth and RFID allow IoT devices to connect locally.
Top 5 IoT Security Protocols
MQTT
MQTT is one of the most common security protocols used in internet of things security. It was invented by Dr Andy Stanford-Clark and Arlen Nipper in 1999. MQTT stands for Message Queuing Telemetry Transport and is a client-server communicating messaging transport protocol. The MQTT runs over TCP/IP or over other conventions that provide requested, lossless, two-way associations.
How does MQTT secure internet of things applications?
Security in MQTT is divided into multiple layers: network, transport, and application levels. Each layer prevents a specific type of attack. As MQTT is a lightweight protocol, it specifies only a few security mechanisms. MQTT implementations commonly use other security standards like SSL/TLS for transport encryption, VPN at network level for a physically secure network, and use of username/password. A client identifier to authenticate devices on the application level is passed with data packets.
CoAP
CoAP (Constraint Application Protocol) is a web transfer protocol designed for constrained devices (like microcontrollers) and the constrained network called low power or lossy networks. It is also one of the most popular protocols to secure internet of things applications.
How does CoAP secure internet of things applications?
CoAP uses UDP (User Datagram Model) to transport information and therefore relies on UDP security aspects to protect the information. CoAP uses Datagram TLS over UDP.
CoAP has been designed to have a simple and user-friendly interface with HTTP for integration with the Web and supports functions such as multicast support and low overhead issues, thus contributing to security in the internet of things.
DTLS
The DTLS (Datagram transport layer security) is an internet of things security protocol designed to protect data communication between data-gram-based applications. It is based on TLS (transport layer security) protocol and provides the same level of security.
DTLS is used in applications such as live video feeds, video streaming, gaming, VoIP, and instant messaging where loss of data is comparatively less important than latency.
6LoWPAN
6LoWPAN (IPv6 over Low Power Wireless Personal Area Networks) is a protocol for low-power networks like IoT systems and wireless sensor networks.
6LoWPAN plays a key role in domains like smart home automation, industrial monitoring, smart grids, general automation, etc.
ZigBee
ZigBee is believed to be a state-of-the-art protocol to provide security for internet of things devices and applications. It provides efficient machine-to-machine communication from 10–100 meters away in low-powered embedded devices like radio systems. It is a cost effective open-source wireless technology.
ZigBee supports two security models:
The Centralized Security Network
This provides higher security and is also more complicated as it uses a third device called Trust Centers that are applications that run on the device trusted by other devices within the ZigBee network. The Trust Centre forms a centralized network and configures and authenticates each device to join the network by giving it a unique TCLK (TC Link Key). The TC also determines the network key. To join the network, each device must be configured with the link key which is used to encrypt the network when passing it from the TC to a newly joined entity.
The Distributed Security Network
In DSN, there is no Central Node or Trust Center; this makes it simpler but less secure than the CSN. Every router can start distributed networks on their own. When a node joins to the network, it only receives the network key.
The Service Discovery Protocol
The Service Discovery Protocol (SDP) allows a device to retrieve information on services offered by a neighbouring device. (A service is any feature that another device can use.) A basic data connection must be set up before Service Discovery can be used.
Service discovery functions by using a common network protocol, which enables agents to use each other's services. Protocols used include Dynamic Host Configuration Protocol, DNS Service Discovery and Service Location Protocol.
How does service discovery work?
Service discovery functions by using a common network protocol, which enables agents to use each other's services. Protocols used include Dynamic Host Configuration Protocol, DNS Service Discovery and Service Location Protocol.
The database which contains service instances and network locations is called the service registry. The service registry is made up of server clusters containing databases of available service instances, which should be continually kept up to date.
Client-side vs. server-side discovery
Service discovery uses two different discovery options pertaining to either the data center initiating discovery, or the service actively identifying itself to the data center. These options are known as client-side or server-side.
In client-side discovery, the client service is responsible for determining network locations of service instances. The client accomplishes this by querying a service registry. This service discovery option benefits from being straightforward.
1. MDNS (multicast Domain Name System)- MDNS (multicast Domain Name System) resolves host names to IP addresses. Within small networks without a local name server.
2. Physical web- The Physical Web lets you see a list of URLs that are being broadcast by things in your area that have a Bluetooth Low Energy (BLE) beacon.
3. HyperCat- HyperCat is a JSON-based hypermedia catalogue format for exposing collections of URIs that is open and lightweight.
4. UPnP (Universal Plug and Play)- A set of networking protocols, now governed by the Open Connectivity Foundation, allows networked devices to identify each other's presence on the network and develop functional network services for data exchange, communications, and entertainment.
IOT Infrastructure Protocols
IoT infrastructure refers to the hardware and software systems that support the functioning of IoT devices and networks.
1. IPv6 - IPv6 is an Internet Layer protocol that provides end-to-end datagram transmission across multiple IP networks.
2. 6LoWPAN - 6LoWPAN is an abbreviation for IPv6 over Low Power Wireless Personal Area Networks. It is an IPv6 adaption layer for IEEE802.15.4 links. This protocol operates only at 2.4 GHz with a transfer rate of 250 kbps.
3. UDP (User Datagram Protocol) - A simple OSI transport layer protocol based on Internet Protocol for client/server network applications (IP). UDP, the primary alternative to TCP, is one of the oldest network protocols in use, having been introduced in 1980. UDP is frequently used in applications that are specifically designed for real-time performance.
4. QUIC- QUIC (Quick UDP Internet Connections, pronounced quick) supports a set of multiplexed UDP connections between two endpoints and was designed to provide security comparable to TLS/SSL, as well as reduced connection and transport latency, and bandwidth estimation in each direction to avoid congestion
5. uIP - The uIP is an open-source TCP/IP stack that may be used with microcontrollers as small as 8 and 16 bits. It was created by Adam Dunkels of the Swedish Institute of Computer Science's "Networked Embedded Systems" group, published under a BSD-style license, and further developed by a large community of developers.
6. Datagram Transport Layer Security (DTLS) - For datagram protocols, the DTLS protocol enables communications privacy. The protocol lets client/server applications interact in a secure manner that protects against eavesdropping, manipulation, and message forgery. The DTLS protocol is based on the Transport Layer Security (TLS) standard and offers the same level of security.
7. NanoIP- NanoIP (nano Internet Protocol) is a concept developed to offer Internet-like networking capabilities to embedded and sensor devices without the overhead of TCP/IP. NanoIP was created with the goal of having low overhead, wireless networking, and local addressing.
8. Content-Centric Networking (CCN) - It works on the principle that a communication network should allow users to focus on the data, rather than having to reference a specific, physical location from where the data is to be retrieved. CCN enables content caching to reduce congestion and improve delivery speed, a simpler configuration of network devices, and security built into the network at the data level.
Java is a popular choice for developing software for Internet of Things (IoT) due to its platform independence and security features.
IOT PROGRAMMING
In IoT development, Java is often used to develop software for gateways and other intermediate devices, as well as to create applications that collect and process data from IoT devices. Java is also used to develop applications that control and monitor IoT devices, as well as to implement security protocols for IoT networks.
C language is a popular choice for developing software for Internet of Things (IoT) devices due to its low-level nature and efficient use of system resources.
In IoT development, C is often used to program microcontrollers and other low-level hardware components, as well as to write firmware for IoT devices. It is also used to develop software for gateways and other intermediate devices that act as intermediaries between IoT devices and the cloud or other higher-level systems.
Python is a high-level programming language that is widely used for Internet of Things (IoT) development due to its ease of use and rich libraries.
In IoT development, Python is often used to develop software for gateways and other intermediate devices, as well as to create applications that communicate with and control IoT devices. Python is also used to develop applications that collect and process data from IoT devices and perform data analysis and visualization.
JavaScript is a high-level, dynamic programming language that is widely used for Internet of Things (IoT) development, particularly for web-based IoT applications.
In IoT development, JavaScript is often used to develop web-based applications that control and monitor IoT devices, as well as to create user interfaces for IoT systems. JavaScript is also used to develop server-side applications that collect and process data from IoT devices and perform data analysis and visualization.
PHPoC (PHP on Chip) is a platform for building Internet of Things (IoT) applications using the PHP programming language.
In IoT development, PHPoC is often used to develop software for intermediate devices, such as gateways, that communicate with and control IoT devices. PHPoC is also used to develop applications that collect and process data from IoT devices, perform data analysis and visualization, and implement security protocols for IoT networks.
Arduino Programming
Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online.
Serial Communication
Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART), and some have several.
On Uno, Nano, Mini, and Mega, pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board.
You can use the Arduino environment’s built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin ().
Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the board). Don’t connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.
To use these extra serial ports to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega’s USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device’s RX pin, the RX to your device’s TX pin, and the ground of your Mega to your device’s ground.
�
Implementing serial communications involves hardware and software. The hardware provides the electrical signaling between Arduino and the device it is talking to. The software uses the hardware to send bytes or bits that the connected hardware understands. The Arduino serial libraries insulate you from most of the hardware complexity, but it is helpful for you to understand the basics, especially if you need to troubleshoot any difficulties with serial communications in your projects.
�
A standard Arduino has a single hardware serial port, but serial communication is also possible using software libraries to emulate additional ports (communication channels) to provide connectivity to more than one device. Software serial requires a lot of help from the Arduino controller to send and receive data, so it’s not as fast or efficient as hardware serial.
The Arduino Mega has four hardware serial ports that can communicate with up to four different serial devices. Only one of these has a USB adapter built in (you could wire a USB-TTL adapter to any of the other serial ports). Table 4-1 shows the port names and pins used for all of the Mega serial ports.
Port name | Transmit pin | Receive pin |
Serial | 1 (also USB) | 0 (also USB) |
Serial1 | 18 | 19 |
Serial2 | 16 | 17 |
Serial3 | 14 | 15 |
Getting Input From Sensors
Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board.
There are two ways to obtain sensor information:
1. Queried sampling to immediately read all enabled digital and analog input pins.
2. Automatic sampling to transmit the sensor data periodically or whenever a digital pin changes.
The analog input pins can be used as digital pins, referred to as A0, A1, etc. The exception is the Arduino Nano, Pro Mini, and Mini's A6 and A7 pins, which can only be used as analog inputs.
Sensors are devices that convert a physical quantity, such as light intensity or temperature, into an electrical quantity. A thermocouple, for example, outputs a voltage proportional to its temperature. There are many different types of sensors:
Light sensor
Motion sensor, Temperature sensor, Magnetic fields sensor, Gravity sensor
Humidity sensor, Moisture sensor, Vibration sensor, Pressure sensor, Electrical fields sensor, Sound sensor, Position sensor
These sensors are used in thousands of different applications, including manufacturing, machinery, aerospace, automobiles, medicine, and robotics.
Visual, Physical and Audio Outputs
A sound sensor is defined as a module that detects sound waves through its intensity and converting it to electrical signals.
Sound detection sensor works similarly to our Ears, having diaphragm which converts vibration into signals. However, what’s different as that a sound sensor consists of an in-built capacitive microphone, peak detector and an amplifier (LM386, LM393, etc.) that’s highly sensitive to sound.
With these components, it allows for the sensor to work:
-Sound waves propagate through air molecules
-Such sound waves cause the diaphragm in the microphone to vibrate, resulting in capacitance change
-Capacitance change is then amplified and digitalized for processing of sound intensity
Apart from building various electronic projects with Arduino (covered in the later section) and more, sound sensors are used in many other day to day applications including:
-Consumer electronics such as phones, computers, music systems
-Security and Monitoring systems such as burglar alarms, door alarm, etc.
-Home automation such as lighting your house by detecting whistle/clap instead of physically turning the light switch
-Ambient sound recognition and sound level recognition
Flame IR Sensors
This sensor is used to detect the spectral radiation of burning and water is produced as the result of burning and can be detected within the range of IR spectrum. Any organic substances burning can also be detected with the help of flame IR sensors. The flame is detected for two infrared frequencies and charge coupled device is used to analyze the fire. These sensors are also called visual flame detectors. The presence of heat is detected from the flame and an alarm is triggered.
Photoresistor Sensor
A light-sensitive sensor that helps in determining the presence of light in the device is called a photoresistor sensor. It also measures the light intensity and is called a light dependent resistor. The sensitivity of the resistors varies depending on the wavelength of the light being detected on the device. The principle of photoconductivity is used in the sensor and the resistance of the sensor decreases with increasing light intensity in the device. Analog input is fed into the Arduino board and results are fetched from the sensors.
Soil Moisture Sensor
Dielectric permittivity is measured with the help of capacitance in the medium. When we consider the soil, it has water content and dielectric permittivity is measured in the soil so that a voltage is created which is proportional to the permittivity of the water and this detects whether water is present in the soil. Hence, moisture in the soil can be verified. This sensor has to be inserted into the soil and the water content is reported in percentage level in the sensor.
Speed Sensor
It is the sensor used to measure the speed of the vehicle based on the wheel rotation of the vehicle. The speed of the drive wheels is detected and this information is sent to the engine control unit and the speed is managed so that the vehicle is running efficiently. Magnetic rotation speed is measured in the device and voltage is produced where this is applicable in the automotive and aeronautical engineering sectors. Both rotational and actual speed of the vehicle is measured with the help of speed sensors.
Remotely Controlling External Devices
The Arduino can interact with almost any device that uses some form of remote control, including TVs, audio equipment, cameras, garage doors, appliances, and toys. Most remote controls work by sending digital data from a transmitter to a receiver using infrared light (IR) or wireless radio technology. Different protocols (signal patterns) are used to translate key presses into a digital signal, and the recipes in this chapter show you how to use commonly found remote controls and protocols.
An IR remote works by turning an LED on and off in patterns to produce unique codes. The codes are typically 12 to 32 bits (pieces of data). Each key on the remote is associated with a specific code that is transmitted when the key is pressed. If the key is held down, the remote usually sends the same code repeatedly, although some remotes (e.g., NEC) send a special repeat code when a key is held down. For Philips RC-5 or RC-6 remotes, a bit in the code is toggled each time a key is pressed; the receiver uses this toggle bit to determine when a key is pressed a second time. You can read more about the technologies used in IR remote controls at http://www.sbprojects.com/knowledge/ir/ir.htm.
�
Arduino boards contain multiple peripherals for communicating with other devices including UART, SPI, I2C, USB, and even bit-banged custom protocols on GPIO pins. However, wired communication can be a pain, especially in scenarios where there is a fair bit of distance between the transmitter and receiver. In this article, we will learn how to use the very famous 433MHz modules with an Arduino so we can get two Arduino’s to wirelessly communicate.
THE FAMOUS 433MHz TRANSMITTER / RECEIVER MODULES
When two devices talk wirelessly, they often use electromagnetic waves known as radio waves. The data sent is transmitted on a specific frequency so that only receivers tuned to the correct frequency can receive it. This tuning prevents devices from detecting all radio waves and is one of the core principles of radio design. The same happens when you tune your car radio to different stations. Despite radio frequencies being an infinite series in theory, the reality of radio frequencies is that there are a finite number of different frequencies which can exist before interference occurs.
Therefore, to prevent interference and misuse most radio frequencies require a license to broadcast. Radio stations, for example, own a radio broadcast library for a specific frequency such as FM 107MHz. However, there are some radio frequencies which are open to public use, the most common example being the 2.4GHz spectrum which is used by Wi-Fi networks. One other frequency that is very common is the 433MHz spectrum, used by many simple radio applications, like wireless thermostat control and front door alarms.
Basics of Python Programming in IOT
Python is a scalable language that can be used for both small-scale and large-scale IoT applications, even for software development. This language has a modular architecture that makes it easy to break down a complex application into smaller, more manageable pieces.
�
Python is the perfect language for data-intensive applications. For example, if there is a lot of data processing work, Python is the best to use. It is the best choice for IoT development which includes data application, data science, and analytics capabilities to the edge.
Why use Python in the Internet of Things?
For many developers, Python is considered as the language of preference in the market. It is simple to learn, has clean syntax, and has a large online community supporting it. Python becomes a great choice when it comes to IoT. We can either use it for the backend side of development or the software development of devices. Moreover, Python is available to work on Linux devices, and we can make use of MicroPython for microcontrollers.
Python is the coding language that we can use to reduce the volume of data that we need to deal with, accessible in the cloud. Python recognizes the needs regardless of whether we create the IoT project from scratch or interact with actuators, sensors, and accessories.
Some of the many benefits of working with Python for IoT devices are a large number of libraries for all types of platforms and the speed it offers at which we can develop the code.
�
What are the best solutions for IoT in Python?
Some of the best solutions for IoT in the Python programming language are as follows:
-Python on Raspberry Pi
-Python on PyBoard
�
Python Package for IOT
A python package is a collection of modules. Modules that are related to each other are mainly put in the same package. When a module from an external package is required in a program, that package can be imported and its modules can be put to use. Any Python file, whose name is the module's name with the .
�
Any Python file, whose name is the module’s name with the .py extension, is a module.
A package is a directory of Python modules that contains an additional ___init__.py
file, which distinguishes a package from a directory that is supposed to contain multiple Python scripts. Packages can be nested to multiple depths if each corresponding directory contains its own __init__.py file.
When you import a module or a package, the object created by Python is always of type module
What is a Python Package?
Python modules may contain several classes, functions, variables, etc. whereas Python packages contain several modules. In simpler terms, Package in Python is a folder that contains various modules as files.
Creating Package
Let’s create a package in Python named mypckg that will contain two modules mod1 and mod2. To create this module follow the below steps:
-Create a folder named mypckg.
-Inside this folder create an empty Python file i.e. __init__.py
-Then create two modules mod1 and mod2 in this folder.
Mod1.py
def gfg():
print("Welcome to GFG")
Mod2.py
def sum(a, b):
return a+b
Understanding __init__.py
__init__.py helps the Python interpreter recognize the folder as a package. It also specifies the resources to be imported from the modules. If the __init__.py is empty this means that all the functions of the modules will be imported. We can also specify the functions from each module to be made available.
For example, we can also create the __init__.py file for the above module as:
__init__.py
Domain Specific IOT
A domain-specific embedded system is designed to perform tasks within a particular domain or field, such as automotive, healthcare, or industrial automation. These systems are typically designed to meet the specific requirements of a particular industry or application.
Home Automation
A smart home system can be something that makes our life quite easy. Starting from energy management where the power controls system in the AC appliances where we use the thermostat, all this is managed to cut down the power consumption that's taking place. A door management system, security management system, water management system are the part of this as well. Still, these are vital things that stand out in the smart home system. The limitation of IoT in smart home application stops where our imagination stops. Anything that we wish to automate or want to make our life easier can be a part of smart home, a smartphone system as well.
Smart City
A smart home usually is going to be a base of a smart city. The smart city is an evolution of a smart home. Here, it is not just the sensors of a single home that is connected, here its correlation or a network or a connection between various organizations, various domains as well as multiple segments of that city as a whole. In the smart city, the life of every single dependent becomes more comfortable and in tune really help to develop that city to greater extends as such. Now, the key factor for a smart city is government support as well, and if the governments are willing to take this step, then we hope we would see a smart city completely build on the Internet of Things.
Smart Environment
IoT-based weather monitoring systems use different sensors to gather data. That data is sent to the cloud-based storage. The collected can be analyzed and visualized with applications. Weather alerts can be subscribed by users from such applications.
IoT-based air pollution monitoring systems can monitor harmful gas emissions by factories and vehicles using gaseous and meteorological sensors. The collected data can be analyzed to take decisions on pollution control approaches.
IoT-based noise pollution monitoring systems use a number of noise pollution monitoring systems that are deployed at different places in the city. The data on noise levels from the stations is collected on servers or in the cloud. The collected data can be analyzed to generate noise maps.
IoT-based forest fire detection systems use number of nodes deployed at various locations in the forest. Each monitoring node collects data about ambient conditions. This data will be collected and analyzed for the presence of fire and corresponding people will be alerted.
IoT-based flood monitor systems use number of sensor nodes to monitor the water level. Data from the sensors is aggregated on the server or in the cloud. Monitoring applications raise alerts in case of rapid increase in water level or when rapid flow rate is detected.
IoT Energy Domain
The Internet of Things plays a vital role in the field of energy management and regulation. The term used for that is Smart Energy System. IoT applications monitor a wide variety of energy control function to residential and commercial use.
Residential Energy
As technology is increasing day by day, it also raises the cost of energy. Consumers search the way through which they can reduce and control the energy cost. IoT provides a mature way to analyze and optimize the use of the device as well as the entire system of a home. It may be changing the device setting, simply switching on/off or dimming lights to optimize energy use.
Commercial Energy
Wastage of energy widely impacts any business enterprises in their cost of production. IoT provides a specific way for monitoring and maintaining a low cost and high level of care. IoT system provides a strong means of managing the consumption cost of energy and optimize the output of enterprises. It discovers energy issues in the same way as functional issues in a complex business network and provides solutions.
Logistics
Route Generation and Scheduling
While delivering packages to various locations, different sensors can be fixed in those routes and they can be monitored remotely through an application. By looking at the data sent by the sensors, the delivery company can automatically know which routes are less congested and schedule the delivery of packages in such routes.
Fleet Tracking
A delivery company will have several delivery personnel working with them. Different people will use different vehicles for delivering the packages. Sensors can be fixed to those vehicles and their location can be tracked to know how long will it take to deliver the package.
Shipment Monitoring
The packages can be fixed with RFID tags or other form of remote tracking sensors to send data periodically to a server via Internet. The delivery company can use that data to track where the package is and update the user about the remaining time that will be needed to deliver the package.
Remote Vehicle Diagnostics
A vehicle rental company can fix sensors into the vehicles before giving them for rent to the customers. The company can check the data sent by the sensors to know the current location of the vehicle and easily track them.