0% found this document useful (0 votes)
7 views

Chapter 2(Iot)

Chapter 2 discusses the hardware components of IoT devices, including 'things' that connect to the internet, data acquisition and processing modules, and communication modules. It provides an in-depth look at microcontrollers and microprocessors, communication technologies, sensors, actuators, and I/O interfaces essential for IoT functionality. The chapter also highlights the importance of selecting appropriate hardware based on application requirements and introduces popular platforms like Arduino and Raspberry Pi.

Uploaded by

7001.akashroy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Chapter 2(Iot)

Chapter 2 discusses the hardware components of IoT devices, including 'things' that connect to the internet, data acquisition and processing modules, and communication modules. It provides an in-depth look at microcontrollers and microprocessors, communication technologies, sensors, actuators, and I/O interfaces essential for IoT functionality. The chapter also highlights the importance of selecting appropriate hardware based on application requirements and introduces popular platforms like Arduino and Raspberry Pi.

Uploaded by

7001.akashroy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

CHAPTER 2

IoT Hardware Devices

1. “Things”: Things in IoT are any devices that are capable of connecting to the internet. They can transmit,
retrieve and store huge amounts of data that they collect from the surrounding. They include home
appliances such as geysers, microwaves, thermostats and refrigerators
2. Data Acquisition module: As the term suggests, this module is responsible for acquiring data from the
physical surroundings or environment. These could include changes in the temperature, movement,
humidity and pressure.
3. Data processing module: This module includes computers that process the data acquired from the
previous module. They analyze the data, store data for future references and other purposes.
4. Communication module: This is the final building block and this module is responsible for
communication with third party vendors. This could include device to device, device to server or device to
user.

Elements of IoT: In-Depth Look at Hardware Components


1. Computing (The Intelligent Core)

The computing component is the decision-making center of the IoT device. It receives data from sensors, processes it
according to programmed logic, and sends instructions to actuators or communication modules.

 Microcontrollers (MCUs): The Embedded Specialists


o Architecture: Typically based on simpler processor architectures (e.g., ARM Cortex-M, AVR). They
often integrate the CPU, memory (RAM, ROM/Flash), and various peripherals (timers, ADCs, DACs,
communication interfaces) onto a single chip.
o Resource Constraints: Generally have limited processing power, memory, and power consumption
compared to microprocessors. This makes them highly energy-efficient and suitable for battery-
operated devices.
o Real-Time Operation: Designed for deterministic and real-time execution of tasks, crucial for
responding promptly to sensor inputs and controlling actuators.
o Interrupt Handling: Efficiently handle interrupts from peripherals and external events, allowing for timely
responses.
o Wake-up and Sleep Modes: Often feature sophisticated power management capabilities with various
sleep modes to minimize energy usage when idle.
o Examples (Beyond Arduino): ESP32 (with integrated Wi-Fi and Bluetooth), STM32 family (wide range
of performance and peripherals), PIC microcontrollers.
 Microprocessors (MPUs): The Versatile Powerhouses
o Architecture: Feature more complex processor architectures (e.g., ARM Cortex-A, Intel Atom) with
higher clock speeds and more advanced features like memory management units (MMUs).
o Resource Abundance: Offer significantly more processing power and memory, enabling them to run
full-fledged operating systems and complex software.
o General-Purpose Computing: Designed for a broader range of computing tasks, not solely focused on
real-time control.
o External Peripherals: Typically require external memory chips and peripheral controllers, making the
overall system more complex than a microcontroller-based one.
o Power Consumption: Generally higher power consumption compared to microcontrollers.
o Examples (Beyond Raspberry Pi): Intel NUC, BeagleBone Black, various ARM-based single-board
computers.

2. Communication (The Data Pipeline)

Reliable and efficient communication is vital for IoT devices to interact within a network and with the cloud.

 Wireless Technologies (Expanding on the Basics):


o Wi-Fi (IEEE 802.11 a/b/g/n/ac/ax): Offers different frequency bands (2.4 GHz, 5 GHz), data rates, and
standards. Newer standards like Wi-Fi 6 (802.11ax) provide higher speeds and better efficiency for
dense environments. Security protocols (e.g., WPA3) are crucial for protecting data.
o Bluetooth (IEEE 802.15.1): Classic Bluetooth offers higher bandwidth but higher power consumption.
Bluetooth Low Energy (BLE or Bluetooth Smart) is designed for low power applications with lower data
rates, ideal for wearables and sensors. Mesh networking capabilities in BLE allow for larger networks.
o Cellular (2G/3G/4G LTE/5G): Different generations offer varying data speeds and latency. Narrowband
IoT (NB-IoT) and LTE-M are cellular technologies specifically optimized for low-power, low-bandwidth
IoT applications. SIM cards and data plans are necessary.
o LoRa/LoRaWAN: Operates in unlicensed sub-GHz radio frequency bands, enabling long-range
communication (several kilometers) with very low power consumption. LoRaWAN is the communication
protocol and system architecture built on top of the LoRa physical layer.
o Zigbee (IEEE 802.15.4): Operates in the 2.4 GHz or sub-GHz bands, creating self-healing mesh
networks. Well-suited for smart home devices due to its reliability and low power consumption.
o NFC (ISO/IEC 14443): Very short-range (a few centimeters) communication, often used for contactless
payments, data exchange, and device pairing.
o Other Emerging Technologies: Sigfox (another LPWAN technology), Z-Wave (another smart home
protocol).
 Wired Technologies (For Specific Applications):
o Ethernet (IEEE 802.3): Provides reliable, high-bandwidth wired network connectivity. Suitable for
stationary IoT devices where a wired connection is feasible. Power over Ethernet (PoE) can simplify
power delivery.
o Serial Communication (RS-232, RS-485): Used for direct communication between devices, often in
industrial settings. RS-485 allows for longer distances and multi-drop networks.
o CAN Bus (Controller Area Network): A robust serial communication protocol widely used in automotive
and industrial automation for real-time control and data exchange between microcontrollers.

3. Sensing (The Eyes and Ears of IoT)

The accuracy, sensitivity, and reliability of sensors are critical for the quality of data collected by IoT devices.

 Expanding Sensor Categories:


o Environmental Sensors: Measure physical conditions like temperature, humidity, pressure, light
intensity (lux), air quality (CO, CO2, particulate matter), noise levels.
o Motion and Position Sensors: Detect movement (PIR, microwave, ultrasonic), acceleration
(accelerometers), angular velocity (gyroscopes), magnetic field (magnetometers/compasses), linear
and angular position (encoders).
o Biometric Sensors: Measure biological data like heart rate (photoplethysmography - PPG), blood
oxygen saturation (SpO2), body temperature, galvanic skin response (GSR).
o Image and Video Sensors: Capture still images or video streams (CMOS, CCD sensors). Resolution,
frame rate, and low-light performance are important parameters.
o Level and Flow Sensors: Measure the level of liquids or solids, and the rate of flow of fluids or gases.
o Chemical Sensors: Detect specific chemical substances in the environment.
o Force and Strain Sensors: Measure applied force or deformation.
o Acoustic Sensors (Microphones): Capture sound.
 Sensor Characteristics:
o Range: The span of values the sensor can accurately measure.
o Resolution: The smallest change in the measured variable that the sensor can detect.
o Accuracy: How close the sensor's reading is to the true value.
o Precision: The repeatability of the sensor's measurements.
o Sensitivity: The change in the sensor's output for a given change in the measured variable.
o Response Time: How quickly the sensor reacts to a change in the measured variable.
o Calibration: The process of ensuring the sensor's output is accurate.
o Power Consumption: Important for battery-powered devices.
o Interface: How the sensor communicates data (analog voltage, digital I2C, SPI, etc.).

4. Actuation (Bringing Digital Commands to the Physical World)

Actuators enable IoT devices to interact with their surroundings and perform physical actions.

 Expanding Actuator Types:


o Electrical Motors:
 DC Motors: Simple to control speed and direction.
 Servo Motors: Provide precise angular position control.
 Stepper Motors: Offer precise incremental movement.
o Electromagnetic Actuators:
 Relays: Electrically controlled switches for high-power circuits. Solid-state relays offer faster
switching and longer lifespan.
 Solenoids: Linear actuators used for valves, latches, and push/pull mechanisms.
o Fluid Power Actuators:
 Pneumatic Actuators: Use compressed air to generate motion (cylinders, rotary actuators).
 Hydraulic Actuators: Use pressurized liquids for high-force applications.
o Thermal Actuators: Generate motion or force through thermal expansion.
o Piezoelectric Actuators: Use the piezoelectric effect to produce small, precise movements.
o Speakers and Sound Generators: Produce auditory output.
o Display Units (as output): LCD, LED screens provide visual feedback.
o Robotic Arms and Grippers: Complex actuators used in industrial automation.
 Actuator Control:
o Digital Control (On/Off): Simple control using digital output pins (e.g., turning a relay on or off).
o Analog Control (Variable Output): Using analog output (e.g., PWM to control motor speed or LED
brightness) or Digital-to-Analog Converters (DACs).
o Feedback Control: Using sensors to monitor the actuator's state (e.g., position feedback in a servo
motor) to achieve precise control.

5. I/O Interfaces (The Connection Points in Detail)

The I/O interfaces are the pathways through which the computing component interacts with the rest of the hardware.

 Digital I/O (GPIO - General Purpose Input/Output):


o Input Mode: Reads the digital state (high or low voltage) from sensors or other digital devices. Often
includes pull-up or pull-down resistors to define the input state when not actively driven.
o Output Mode: Sets the digital state (high or low voltage) to control actuators or other digital devices.
Can typically source or sink a limited amount of current.
 Analog Input (ADC - Analog-to-Digital Converter):
o Converts a continuous analog voltage level from a sensor into a discrete digital value that the
microcontroller or microprocessor can understand.
o Resolution (in bits): Determines the number of discrete levels the analog signal can be divided into
(e.g., a 10-bit ADC provides 210=1024 levels). Higher resolution provides more precise readings.
o Sampling Rate: How often the ADC takes a reading.
 Analog Output (DAC - Digital-to-Analog Converter & PWM - Pulse Width Modulation):
o DAC: Converts a digital value into a continuous analog voltage level. Less common on basic
microcontrollers.
o PWM: A technique used to generate an effective analog voltage by rapidly switching a digital output on
and off with varying duty cycles (the percentage of time the signal is high). Widely used for controlling
motor speed, LED brightness, and generating pseudo-analog signals.
 Serial Communication Interfaces (Detailed):
o UART (Universal Asynchronous Receiver/Transmitter):
 Asynchronous communication using two wires (transmit - TX, receive - RX) and a common
ground.
 Data is transmitted in packets with start and stop bits, and optionally parity bits for error
checking.
 Baud rate determines the data transmission speed.
o SPI (Serial Peripheral Interface):
 Synchronous communication using four wires (Master Out Slave In - MOSI, Master In Slave Out
- MISO, Serial Clock - SCLK, Slave Select - SS).
 Master-slave architecture where the master device controls the communication.
 High-speed data transfer.
o I2C (Inter-Integrated Circuit):
 Synchronous communication using two wires (Serial Data - SDA, Serial Clock - SCL) and pull-
up resistors.
 Supports multiple master and slave devices with addressing.
 Moderate data rates, commonly used for connecting sensors and low-speed peripherals.
 Other Interfaces:
o USB (Universal Serial Bus): Used for connecting to computers, power supplies, and various
peripherals. Different USB standards (USB 2.0, USB 3.0) offer varying data transfer speeds.
o Ethernet: Provides a standard wired network interface using protocols like TCP/IP.
o Camera Interfaces (e.g., CSI): High-speed interfaces specifically designed for connecting camera
modules.
o Display Interfaces (e.g., HDMI, SPI, I2C): For connecting various types of displays.

This more detailed explanation should provide a stronger foundation for understanding the hardware building blocks of
IoT systems. Remember that the specific components chosen for an IoT device are driven by the requirements of its
intended application.

Types of IoT hardware


It is easier to develop an IoT application these days due to the ease in the availability of boards, Integrated
circuits, prototype kits and platforms. These hardware components are low cost and reliable, they offer
flexibility and the choice to design custom sensors with specific applications. At the same time you can also
specify the networking area, data management and other functionalities you want your IoT application to
have.
The two most common System on a chip(SoS) Integrated Circuits these days are Micro Controllers
and Single-board computers. SoCs place microprocessors, storage, networking and data processing on
a single unit in the chip and thus they are largely in use in the market to manufacture IoT devices. There is
a wide range of hardware components to choose from and based on your requirements you can pick the
one that matches your proptype perfectly.
a. Microcontrollers
Microcontrollers are a type of SoC that provides data processing and storage units. They contain a
processor for processing , ROMs and ROMS for storage.
IoT hardware is tightly constrained. There is a lot to fit in a tiny amount of space unlike a desktop or a
laptop. When you start building an IoT system, you must pick a microcontroller that fits your desired
purpose. You might have to look at its datasheet to understand the properties and specifications.
Microcontrollers are the centre of the IoT system. They have properties such as Datapath Bandwidth.
Datapath Bandwidth specifies the number of bits in the registers. The more bits the more accurate the
results are.
Microcontrollers connect to all the components of the system and thus they must have
adequate input/output pins. Microcontrollers must have performance depending on what system you are
developing. IoT systems are real time applications which require timers. Digital to Analog converters
and Low-power modes.
Microcontrollers use a communication protocol to communicate with one another. The most common ones
used are UART, I2C, SPI etc. The protocols are helpful when you are building bigger systems that require
constant communication with other devices.
We mainly use microcontrollers for low power requirement, simple tasks.
The common and popular microcontrollers available are Arduino Uno, Particle Electron and Espressif
Systems ESP8266-01.
b. Single-Board Computer(SBC)
SBCs are single board computers that contain all the processing and computing properties of a computer
on a single board. SBCs have memory units to store code and data, input and output units and
microprocessors for computing. It also includes an in-built RAM. Cellphones, video game consoles,
appliances use SBCs.
They are a preferred choice in Iot industrial applications as they improve the functionality of a regular
computer, they are easily available and reduce the cost of transportation. SBCs deliver high performance
and are extremely reliable Iot hardware devices.
Based on the kind of project you are making, you choose a SBC that fits into all your needs for that specific
project. SBCs are ready made and available in the market at cheap prices as compared to desktops and
computers.
The types of SBCs commonly available in the market are Raspberry Pis, Beagleboard and Qualcomm
DragonBoard 410c.

Computing in IoT: Arduino and Raspberry Pi in Detail


Both Arduino and Raspberry Pi are powerful platforms for building IoT projects, but they cater to different needs and
offer distinct capabilities. Choosing the right one depends heavily on the complexity and requirements of your
application.

Arduino: The Efficient Microcontroller Platform

Arduino is centered around microcontroller boards. These boards are designed to be easy to use for a wide range of
projects, especially those involving direct interaction with electronics.

 Core Component: Microcontroller (MCU)


o At the heart of an Arduino board is a microcontroller chip. This single integrated circuit contains a
processor core, memory (both for program storage - Flash/ROM - and for temporary data - SRAM), and
various peripherals like analog-to-digital converters (ADCs), digital input/output (I/O) pins, and
communication interfaces (like UART, SPI, I2C).
o Examples of MCUs used in Arduino: The ATmega328P (found in the popular Arduino Uno),
ATmega2560 (in the Arduino Mega), ESP8266 and ESP32 (which also integrate Wi-Fi and/or
Bluetooth).
 Key Characteristics:
o Real-time Control: Arduinos excel at tasks that require precise timing and immediate responses to
events. They are often used for controlling physical processes in real-time.
o Simplicity and Ease of Use: The Arduino IDE (Integrated Development Environment) is user-friendly,
and the programming language (based on C/C++) is relatively accessible, especially for beginners. A
large community provides extensive libraries and tutorials.
o Direct Hardware Interaction: Arduino boards provide numerous digital and analog I/O pins that can be
directly connected to sensors, actuators, and other electronic components.
o Low Power Consumption: Generally, Arduino boards consume less power than Raspberry Pis, making
them suitable for battery-powered applications.
o Single-Tasking Nature: Typically, an Arduino runs a single program (often called a "sketch") repeatedly.
While you can achieve a form of multi-tasking through careful programming and timing, it's not a true
multi-processing environment.
 Programming:
o Primarily programmed using the Arduino programming language, which is a simplified version of
C/C++. The Arduino IDE provides a straightforward environment for writing, compiling, and uploading
code to the board.
o Libraries are available for a vast array of sensors, actuators, and communication protocols, simplifying
development.
 Typical IoT Use Cases:
o Sensor Data Logging: Collecting environmental data (temperature, humidity, light levels) and storing or
transmitting it.
o Basic Automation: Controlling lights, fans, or simple robotic movements based on sensor inputs or
timers.
o Wearable Devices: Due to their small size and low power consumption, they can be part of simple
wearable sensors.
o Environmental Monitoring Stations: Deploying in remote locations to gather data over extended
periods.
o Prototyping Simple Connected Devices: Quickly creating proof-of-concept IoT devices.

Raspberry Pi: The Versatile Single-Board Computer

The Raspberry Pi is a more powerful and versatile platform. It's essentially a small, single-board computer capable of
running a full operating system.

 Core Component: Microprocessor (MPU) and System-on-a-Chip (SoC)


o Raspberry Pi boards are built around a more powerful microprocessor (often ARM-based) integrated
into a System-on-a-Chip (SoC). The SoC also includes the graphics processing unit (GPU), memory
controllers, and various peripherals.
o Examples of SoCs used in Raspberry Pi: Broadcom BCM2711 (in Raspberry Pi 4), BCM2837B0 (in
Raspberry Pi 3B+).
 Key Characteristics:
o Higher Processing Power: Significantly more processing power than Arduino, with multi-core
processors capable of handling more complex computations and running multiple applications
simultaneously.
o Full Operating System: Can run a full-fledged operating system, most commonly a Linux distribution
(like Raspberry Pi OS, Ubuntu, etc.). This provides a familiar software environment and access to a
wide range of tools and programming languages.
o Networking Capabilities: Typically comes with built-in Ethernet and Wi-Fi (on many models), making
network connectivity straightforward.
o Peripheral Connectivity: Offers USB ports for connecting peripherals (keyboards, mice, cameras),
HDMI for display output, and GPIO pins for hardware interaction (though often with more limited direct
analog input capabilities compared to Arduino).
o Higher Power Consumption: Generally requires more power than Arduino and often needs an external
power supply.
o Multi-Tasking Environment: The operating system allows for running multiple programs and processes
concurrently.
 Programming:
o Supports a wide range of programming languages, including Python (very popular for Raspberry Pi due
to its ease of use and extensive libraries), Java, C/C++, Node.js, and more.
o The Linux environment provides access to a vast ecosystem of software and development tools.
 Typical IoT Use Cases:
o Home Automation Hubs: Acting as a central controller for various smart home devices, processing data
and executing rules.
o Smart Surveillance Systems: Processing video feeds for object detection, facial recognition, or remote
monitoring.
o Industrial IoT Gateways: Aggregating data from multiple sensors and devices, performing edge
computing, and communicating with the cloud.
o Media Servers: Streaming media content based on sensor triggers or remote commands.
o Advanced Analytics at the Edge: Performing local data analysis and machine learning inference on
sensor data.
o Complex Sensor Data Processing: Handling data streams from multiple sensors and performing more
sophisticated analysis.

Side-by-Side Comparison:

Feature Arduino Raspberry Pi


Core Microcontroller (MCU) Microprocessor (MPU) / System-on-a-Chip (SoC)
Processing Power Lower Higher (Multi-core)
Operating System Typically No OS (runs a single program) Full Operating System (Linux-based)
Programming Primarily C/C++ (Arduino language) Python, Java, C/C++, Node.js, etc.
Networking Often requires external modules Built-in Ethernet and/or Wi-Fi on many models
Peripheral I/O Abundant digital and analog I/O pins More limited direct analog input, relies on USB
Power
Lower Higher
Consumption
Simpler to get started with basic
Complexity More complex due to OS and broader capabilities
electronics
Cost Generally lower for basic boards Generally higher
Simple sensing, real-time control, low Complex processing, networking, multimedia, edge
Use Cases
power AI

 Raspberry Pi
Raspberry Pi is a small single-board computer (SBC). It is a credit card-sized computer that can be plugged
into a monitor. It acts as a minicomputer by connecting the keyboard, mouse, and display. Raspberry Pi has
an ARM processor and 512MB of RAM. The architecture of Raspberry Pi is discussed in this article.
The following diagram shows the architecture of Raspberry Pi:
Raspberry Pi mainly consists of the following blocks:
 Processor: Raspberry Pi uses Broadcom BCM2835 system on chip which is an ARM processor
and Video core Graphics Processing Unit (GPU). It is the heart of the Raspberry Pi which controls
the operations of all the connected devices and handles all the required computations.
 HDMI: High Definition Multimedia Interface is used for transmitting video or digital audio data to a
computer monitor or to digital TV. This HDMI port helps Raspberry Pi to connect its signals to any
digital device such as a monitor digital TV or display through an HDMI cable.
 GPIO ports: General Purpose Input Output ports are available on Raspberry Pi which allows the
user to interface various I/P devices.
 Audio output: An audio connector is available for connecting audio output devices such as
headphones and speakers.
 USB ports: This is a common port available for various peripherals such as a mouse, keyboard, or
any other I/P device. With the help of a USB port, the system can be expanded by connecting more
peripherals.
 SD card: The SD card slot is available on Raspberry Pi. An SD card with an operating system
installed is required for booting the device.
 Ethernet: The ethernet connector allows access to the wired network, it is available only on the
model B of Raspberry Pi.
 Power supply: A micro USB power connector is available onto which a 5V power supply can be
connected.
 Camera module: Camera Serial Interface (CSI) connects the Broadcom processor to the Pi
camera.
 Display: Display Serial Interface (DSI) is used for connecting LCD to Raspberry Pi using 15 15-pin
ribbon cables. DSI provides a high-resolution display interface that is specifically used for sending
video data.
What is Arduino?

Arduino is an open-source, cross-platform, very simple hardware and software environment intended for
interactive projects. It could be an electronic board having a microcontroller—a computer in one chip—
besides a development environment within which one writes, compiles, and ultimately downloads code onto
the microcontroller. The Arduino boards were designed to make simple engagements with an electronic
system easy for both supporters and audiences: beginners, enthusiasts, and learners.
Advantages of Arduino
 User Friendly: Arduino IDE is so user-friendly that even a complete beginner finds it very easy to
learn.
 Above all: Open-source, Arduino has an enormous community providing a huge number of
tutorials, libraries, and other resources.
 variety of shields: There exist a variety of shields that can give extended capabilities to an Arduino
for wireless, motor control, and even Internet connectivity.
 Economical: Arduino boards are much cheaper in price than most other microcontrollers or
development boards.
 Platform Independent: The Arduino Software runs on Windows, Mac OS X and Linux.
Disadvantages of Arduino
 Limited Computational Power: The processing and memory resources of the Arduino boards are
actually quite limited, so they cannot be used for higher operations, such as an operating system
workable through intensive computation.
 Absence of Multitasking: Arduino boards are fundamentally designed for single-task execution,
signifying their inability to manage several tasks concurrently.
 Connectivity is limited: While shields can absolutely extend the connective selection, the basic
model of an Arduino does have its features lacking, such as Wi-Fi and Ethernet.

 Difference between Arduino and Raspberry Pi


S
No. Arduino Raspberry Pi

In the year 2005, the classrooms of the


In the year 2012, Eben Upton first introduced
1. Interactive Design Institute in Ivrea,
the Raspberry Pi device in February.
Italy, first introduced the Arduino board.

Control unit of the Arduino is from the The control unit of Raspberry Pi is from the
2.
At mega family. ARM family.

While Raspberry Pi is based on a


3. Arduino is based on a microcontroller.
microprocessor.

While Raspberry Pi computes data and produces


It is designed to control the electrical
valuable outputs, and controls components in a
4. components connected to the circuit
system based on the outcome of its
board in a system.
computation.

Arduino boards have a simple hardware While Raspberry Pi boards have a complex
5.
and software structure. architecture of hardware and software.

6. CPU architecture: 8 bit. CPU architecture: 64 bit.

7. It uses very little RAM, 2 kB. While Raspberry Pi requires more RAM, 1 GB.

While Raspberry Pi clocks a processing speed


8. It clocks a processing speed of 16 MHz.
of 1.4 GHz.

9. It is cheaper in cost. While Raspberry Pi is expensive.

While Raspberry Pi has a lower I/O current


10. It has a higher I/O current drive strength.
drive strength.

11. It consumes about 200 MW of power. While it consumes about 700 MW of power.

12. Its logic level is 5V. Its logic level is 3V.


S
No. Arduino Raspberry Pi

13. It does not have internet support. It has inbuilt Ethernet port and WiFi support.

14. It has higher current drive strength. It has lower current drive strength.

Some of the applications of Arduino are Some of the applications of Raspberry Pi are
15. traffic light countdown timer , Weighing Stop motion cameras , Robot Controllers ,
machines , etc. Game Servers.

Operating systems are required in


16. Operating System is required in Raspberry Pi.
Arduino.

17. Two tiny cores Arduino with 32 MHz Single core and 700 MHz

1. Communication Protocols in IoT


In IoT (Internet of Things), communication refers to the exchange of data between devices, sensors,
gateways, and cloud platforms.IoT devices use different communication protocols depending on range,
power consumption, and data rate requirements.
A. Wireless Communication

Protocol Range Power Data Rate Use Case

Bluetooth (BLE) Short (~10-100m) Low Moderate Wearables, smart home devices

Wi-Fi Medium (~50-100m) High High Smart cameras, home automation

Zigbee Medium (~10-100m) Low Low Industrial IoT, smart lighting

Introduction to I/O Interfaces in IoT


I/O (Input/Output) Interfaces are essential components in IoT systems that enable communication
between sensors (input) and actuators (output). They allow IoT devices to interact with the physical world
by collecting data and performing actions.
Key Functions of I/O Interfaces
 Input Interfaces: Read data from sensors (e.g., temperature, motion, light).
 Output Interfaces: Control actuators (e.g., motors, LEDs, relays).
 Signal Conversion: Convert analog signals to digital (ADC) and vice versa (DAC).
 Communication: Enable data exchange between devices (I2C, SPI, UART).

2. Types of I/O Interfaces in IoT


A. Input Interfaces (Sensors → Microcontroller)
(1) Analog Input (ADC - Analog-to-Digital Converter)
 Used for variable signals (e.g., temperature, light, pressure).

 Example:
o LM35 Temperature Sensor → Analog pin on Arduino.
o LDR (Light Dependent Resistor) → Measures light intensity.
(2) Digital Input (GPIO - General Purpose Input/Output)
 Reads binary signals (HIGH/LOW, 1/0).
 Example:
o PIR Motion Sensor → Detects movement (Digital Pin).
o Push Button → Simple ON/OFF input.
(3) Communication Protocols for Sensors

Protocol Description Example Use Case

Two-wire, multi-device OLED Display, BMP180


I2C (Inter-Integrated Circuit)
communication (SDA, SCL). (Pressure Sensor)

High-speed, full-duplex (MOSI, SD Card Module, RFID


SPI (Serial Peripheral Interface)
MISO, SCK, SS). Reader

UART (Universal Asynchronous Simple serial communication (TX, GPS Module, Bluetooth
Receiver-Transmitter) RX). Module

B. Output Interfaces (Microcontroller → Actuators)


(1) Digital Output (GPIO)
 Switches devices ON/OFF (e.g., relays, LEDs, buzzers).

 Example:
o LED Control → digitalWrite(PIN, HIGH) in Arduino.
o Relay Module → Controls high-voltage appliances.
(2) PWM (Pulse Width Modulation)
 Controls speed, brightness, or power by varying pulse width.

 Example:
o DC Motor Speed Control → analogWrite(PIN, dutyCycle).
o LED Dimming → Adjust brightness.
(3) DAC (Digital-to-Analog Converter)
 Converts digital signals to analog (e.g., audio output).

 Example:
Audio Output → Used in IoT-based music players.
IoT Data Communication Protocols

WebSocket
Linked to the HTTP protocol, the WebSocket technology
establishes a TCP connection between a browser and a
server, and then both of them exchange information until the
connection is closed. Figure 3 shows a high-level
comparison between HTTP and WebSocket.
Although this protocol can be seen as an improvement of
the HTTP connection, the WebSocket is still very
overloaded and heavy for IoT applications.

HTTP (Hypertext Transfer Protocol) is a fundamental protocol of the Internet, enabling the
transfer of data between a client and a server. It is the foundation of data communication for
the World Wide Web.
HTTP provides a standard between a web browser and a web server to establish
communication. It is a set of rules for transferring data from one computer to another. Data
such as text, images, and other multimedia files are shared on the World Wide Web.
Whenever a web user opens their web browser, the user indirectly uses HTTP. It is an
application protocol that is used for distributed, collaborative, hypermedia information systems.
Constrained Application Protocol (CoAP)

CoAP is a web transfer protocol to be used with limited networks with low bandwidth and low availability. It
follows a client/server architecture and is built similarly to HTTP, supporting the REST model: servers make
resources available with an URL, and clients can make requests of types GET, POST, PUT and DELETE.
The CoAP communication links are 1:1 and UDP-based, so the delivery is not guaranteed. CoAP is made
to work in highly congested networks, where nodes do not have a lot of intelligence and are not always
working.
Data Distribution Service (DDS)

Similar to MQTT, DDS follows a publish-subscribe methodology,


with the main difference being that there are no brokers. It means
that all publishers (i.e., temperature sensors) and subscribers (i.e.,
mobile phones) are all connected to the same network. This network
is known as Global Data Space (GDS) and it interconnects each
node with all the other ones to avoid bottlenecks. An example of the
DDS GDS can be seen in Figure 2.

MQTT (Message Queuing Telemetry Transport) is an OASIS standard messaging protocol for the
Internet of Things (IoT). It is designed with an extremely lightweight publish/subscribe messaging model,
making it ideal for connecting IoT devices with a small code footprint and minimal network bandwidth and
exchanging data in real-time between connected devices and cloud services.
MQTT can not only be used as a gateway to access communication on the device side, but also as a
Device-Cloud Communication Protocol. Most gateway protocols such as ZigBee and LoRa can be
converted into MQTT Protocol to connect to the Cloud.

A use case of MQTT is in a smart factory where there are temperature sensors installed along
with the production plant. The installed sensors will connect to the MQTT broker and will publish
the data within sensor topics, as follows:
Afterward, the MQTT clients, which can be of several types and quantities, will subscribe to the
same topic in order to read the temperature data. An example of an MQTT architecture can be
seen in Figure 1.


 Lightweight and Reliable: MQTT messages are compact, enabling stable transmission on
severely constrained hardware devices and networks with low bandwidth and high latency.
 Publish/Subscribe Model: Based on the publish/subscribe model, its advantage lies in decoupling
publishers and subscribers - they don't need to establish a direct connection or be online
simultaneously.
 Designed for IoT: Provides comprehensive IoT application features such as keep alive
mechanism, will message, QoS, topic, and security management.
 More Complete Ecosystem: It covers client and SDK platforms in all languages, and has mature
Broker server software, supporting a vast number of topics, millions of device connections, and rich
enterprise integration capabilities.

Key Concepts:

 Publish/Subscribe (Pub/Sub): Unlike the request/response model, MQTT uses a pub/sub architecture. Devices
(clients) don't communicate directly with each other. Instead, they interact with a central broker.
o Publishers: Devices that send out data or messages on specific topics.
o Subscribers: Devices that express interest in (subscribe to) specific topics and receive messages
published to those topics.
o Broker: The intermediary server that receives messages from publishers and routes them to interested
subscribers.

Topics: Messages are published to and subscribed from hierarchical strings called topics (e.g., home/temperature,
sensor/humidity/room1). The broker uses these topics to filter and route messages.

 Quality of Service (QoS): MQTT defines three levels of QoS for message delivery:
o QoS 0 (At most once): Messages are delivered with no guarantee of delivery. Best effort, fire and
forget.
o QoS 1 (At least once): Messages are guaranteed to be delivered at least once, but may be delivered
multiple times. Requires acknowledgment.
o QoS 2 (Exactly once): Messages are guaranteed to be delivered exactly once. This is the most reliable
but also the most overhead-intensive level.
 Lightweight: MQTT has a small message overhead, making it efficient for low-bandwidth networks.
 Stateful Connections: Clients maintain persistent connections with the broker, reducing connection overhead
for frequent communication.
 Last Will and Testament (LWT): A client can register an LWT message with the broker. If the client
disconnects unexpectedly, the broker will publish this LWT message on a specified topic, alerting other
subscribers to the client's offline status.
 Retained Messages: Publishers can mark messages as "retained." The broker stores the last retained message
for a topic and delivers it to new subscribers when they subscribe to that topic.

 Typical Use Cases:

 Smart Homes: Sending sensor readings (temperature, light), controlling actuators (lights, locks).
 Industrial IoT (IIoT): Monitoring machine status, collecting telemetry data from industrial equipment.
 Agriculture: Tracking environmental conditions in fields, controlling irrigation systems.
 Logistics and Transportation: Tracking vehicle locations, monitoring cargo conditions.
 Messaging and Notifications: Lightweight messaging between devices or to user interfaces.

 Advantages:

 Lightweight and efficient: Low bandwidth and resource consumption.


 Scalable: The broker handles message routing, allowing for a large number of devices.
 Decoupled communication: Publishers and subscribers don't need to know each other's details.
 Reliable delivery (with QoS > 0).
 Support for intermittent connections.
 Disadvantages:

 Requires a central broker, which can be a single point of failure if not properly managed.
 Not ideal for request/response interactions where an immediate response is needed.

6. CoAP
CoAP: The RESTful Protocol for Constrained Environments

CoAP is a specialized web transfer protocol designed for constrained nodes and constrained networks, often referred
to as the "HTTP of the IoT." It aims to bring the familiar REST (Representational State Transfer) architecture of the
web to resource-limited devices.

IoT devices have limited resources like CPU, RAM, Flash, and network bandwidth. Direct data exchange
using TCP and HTTP is unrealistic. CoAP protocol emerged to solve this problem and enable these devices
to connect to the network smoothly.
CoAP incorporates HTTP design ideas and develops practical functions specific to resource-limited
devices.

 Key Concepts:
o RESTful Architecture: CoAP follows the REST principles, using concepts like resources identified by
URIs (Uniform Resource Identifiers) and standard methods (GET, POST, PUT, DELETE) to interact
with these resources.
o Request/Response Model: Unlike MQTT's pub/sub, CoAP operates on a request/response model
between clients and servers.
o Lightweight: CoAP minimizes overhead by using a compact binary message format (based on UDP by
default).
o Stateless Protocol: Like HTTP, CoAP is generally stateless, meaning each request from a client to a
server contains all the information needed to understand the request.
o Methods: CoAP defines methods analogous to HTTP:
 GET: Retrieve a representation of a resource.
 POST: Request the server to accept the entity enclosed in the request as a new subordinate of
the resource identified by the Request-URI.
 PUT: Request 1 the server to update or create the resource identified by the Request-URI with
the enclosed entity.
 DELETE: Request the server to delete the resource identified by the Request-URI.
o Responses: Servers respond to requests with status codes similar to HTTP (e.g., 2.00 OK, 4.04 Not
Found).
o Observations: CoAP supports a mechanism for clients to "observe" resources on a server. The server
will then send notifications (similar to pub/sub) to the client whenever the state of the observed resource
changes.
o
Security: CoAP can be secured using DTLS (Datagram Transport Layer Security) when running over
UDP.
o Proxying and Bridging: CoAP can be easily bridged to HTTP, allowing constrained devices to interact
with the wider web.
 Typical Use Cases:
o Smart Lighting: Controlling light intensity and color using GET, PUT.
o Smart Sensors: Retrieving sensor readings using GET, observing changes.
o Actuator Control: Triggering actions using POST or PUT.
o Building Automation: Managing HVAC systems, security devices.
o Resource Discovery: Finding available resources on constrained devices.
 Advantages:
o RESTful architecture: Familiar to web developers, promotes interoperability.
o Lightweight and efficient: Designed for constrained environments.
o Request/response model: Suitable for interactions where an immediate response is needed.
o Support for resource discovery and observation.
o Can be secured with DTLS.
o Easy bridging to HTTP.
 Disadvantages:
o Stateless nature might add overhead for applications requiring session management.
o Reliance on UDP (by default) can mean less reliable delivery without implementing application-level
mechanisms or using TCP as a transport.

Key Differences Summarized:

Feature MQTT CoAP


Communication Model Publish/Subscribe (Broker-centric) Request/Response (Client-Server)
Architecture Messaging-oriented middleware RESTful (Resource-oriented)
Transport Layer Typically TCP (can use WebSockets) Typically UDP (can use TCP, DTLS for security)
Message Format Binary, lightweight Binary, compact
State Stateful connections to the broker Generally stateless (except for observations)
Discovery Typically requires external mechanisms Built-in resource discovery
Reliability Achieved through QoS levels Rely on UDP reliability or application logic
Use Cases Telemetry, messaging, control Resource management, control, sensing

Introduction of ZigBee
ZigBee is a Personal Area Network task group with low rate task group 4. It is a technology of home
networking. ZigBee is a technological standard created for controlling and sensing the network. As we know
that ZigBee is the Personal Area Network of task group 4 so it is based on IEEE 802.15.4 and is created by
Zigbee Alliance.
ZigBee is an open, global, packet-based protocol designed to provide an easy-to-use architecture for
secure, reliable, low power wireless networks. Flow or process control equipment can be place anywhere
and still communicate with the rest of the system. It can also be moved, since the network doesn’t care
about the physical location of a sensor, pump or valve.

ZigBee is a standard that addresses the need for very low-cost implementation of Low power devices with
Low data rates for short-range wireless communications.
IEEE 802.15.4 supports star and peer-to-peer topologies. The ZigBee specification supports star and two
kinds of peer-to-peer topologies, mesh and cluster tree. ZigBee-compliant devices are sometimes specified
as supporting point-to-point and point-to-multipoint topologies
Types of ZigBee Devices:
 Zigbee Coordinator Device: It communicates with routers. This device is used for connecting the
devices.
 Zigbee Router: It is used for passing the data between devices.
 Zigbee End Device: It is the device that is going to be controlled.

General Characteristics of Zigbee


Standard:
 Low Power Consumption
 Low Data Rate (20- 250 kbps)
 Short-Range (75-100 meters)
 Network Join Time (~ 30 msec)
 Support Small and Large Networks
(up to 65000 devices (Theory); 240
devices (Practically))

 Low Cost of Products and Cheap


Implementation (Open Source Protocol)
 Extremely low-duty cycle.

ZigBee: The Low-Power Wireless Mesh Network Protocol


ZigBee is a low-power, low-data-rate wireless network protocol based on the IEEE 802.15.4 standard. It's designed
for short-range communication and is often used in applications requiring secure and reliable wireless networking with
minimal power consumption, making it ideal for battery-operated devices.

 Key Concepts:
o Mesh Networking: One of ZigBee's defining features is its ability to form mesh networks. In a mesh
network, devices can communicate directly with each other or through intermediary devices. This
provides several advantages:
 Extended Range: Devices that are out of range of a central coordinator can still communicate by
hopping through other devices in the network.
 Redundancy and Reliability: If one communication path fails, data can be routed through
alternative paths, making the network more resilient.
 Self-Healing: The network can automatically reconfigure itself if a device fails or a connection is
lost.
o Low Power Consumption: ZigBee is designed to minimize power usage, allowing devices to operate for
extended periods on batteries. This is achieved through efficient protocols and low duty cycles.
o Low Data Rate: ZigBee is optimized for transmitting small amounts of data intermittently, which is
typical for many sensor and control applications.
o Personal Area Network (PAN): ZigBee networks are often referred to as Personal Area Networks
(PANs).
o Network Topologies: ZigBee supports different network topologies:
 Star: All devices communicate directly with a central coordinator.
 Tree: A hierarchical network structure with a coordinator and routers.
 Mesh: Allows for peer-to-peer communication and multiple paths between devices.
o Coordinator, Router, and End Device: ZigBee networks typically have three types of nodes:
 Coordinator: Manages the network, initiates its formation, and stores information about the
network. There is typically only one coordinator per network.
 Router: Extends the network range and can route data between other devices. Routers are
always mains-powered.
 End Device: Typically battery-powered devices that communicate with a router or the
coordinator. They can sleep for extended periods to conserve power.
o Security: ZigBee incorporates strong security features, including AES-128 encryption, to protect
communication within the network.
 Typical Use Cases:
o Smart Homes: Controlling lighting, thermostats, door locks, and other home automation devices. Its
mesh capabilities make it ideal for covering larger homes.
o Industrial Automation: Monitoring sensors, controlling machinery, and asset tracking in industrial
environments.
o Smart Buildings: Managing lighting, HVAC, and security systems in commercial buildings.
o Healthcare: Monitoring patient vital signs and tracking medical equipment.
o Agriculture: Deploying wireless sensor networks for environmental monitoring and control.
 Advantages:
o Low power consumption: Enables long battery life for devices.
o Robust and reliable: Mesh networking provides redundancy and self-healing capabilities.
o Secure communication: Uses AES-128 encryption.
o Scalable: Can support a large number of devices in a network.
o Relatively low cost: ZigBee modules are generally cost-effective.
o Standardized protocol: Ensures interoperability between devices from different manufacturers (to a
certain extent, depending on profiles).
 Disadvantages:
o Low data rate: Not suitable for applications requiring high bandwidth (e.g., video streaming).
o Shorter range compared to some other technologies (like Wi-Fi), although the mesh topology helps
extend the effective range.
o Complexity: Setting up and managing a large mesh network can be more complex than simpler point-
to-point or star networks.
o Interoperability challenges: While a standard exists, different "profiles" (like ZigBee Home Automation,
ZigBee Light Link, ZigBee 3.0) can sometimes lead to interoperability issues between devices adhering
to different profiles. ZigBee 3.0 aims to unify these profiles.

Architecture of Zigbee:

Zigbee architecture is a combination of 6 layers.


1. Application Layer
2. Application Interface Layer
3. Security Layer
4. Network Layer
5. Medium Access Control Layer
6. Physical Layer

 Physical layer: The lowest two layers i.e the physical and the MAC (Medium Access Control) Layer
are defined by the IEEE 802.15.4 specifications. The Physical layer is closest to the hardware and
directly controls and communicates with the Zigbee radio. The physical layer translates the data
packets in the over-the-air bits for transmission and vice-versa during the reception.
 Medium Access Control layer (MAC layer): The layer is responsible for the interface between the
physical and network layer. The MAC layer is also responsible for providing PAN ID and also
network discovery through beacon requests.
 Network layer: This layer acts as an interface between the MAC layer and the application layer. It is
responsible for mesh networking.
 Application layer: The application layer in the Zigbee stack is the highest protocol layer and it
consists of the application support sub-layer and Zigbee device object. It contains manufacturer-
defined applications.
.

Differences between TCP and UDP


Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) both are protocols of the
Transport Layer Protocols. TCP is a connection-oriented protocol whereas UDP is a part of the Internet
Protocol suite, referred to as the UDP/IP suite

TCP (Transmission Control Protocol): Reliable and


Connection-Oriented
TCP is a connection-oriented, reliable, ordered, and error-checked protocol. Think of it like sending a registered
letter – you establish a connection, the data is guaranteed to arrive in the correct order, and you receive confirmation of
delivery.

 Key Characteristics:
o Connection-Oriented: Before any data is exchanged, a connection is established between the sender
and the receiver through a process called a "three-way handshake." This ensures that both sides are
ready to communicate.
o Reliable Delivery: TCP guarantees that all data sent will arrive at the destination correctly and in the
same order it was sent. It achieves this through:
 Sequence Numbers: Each segment of data is assigned a sequence number, allowing the
receiver to reassemble the data in the correct order.
 Acknowledgments (ACKs): The receiver sends acknowledgments back to the sender to confirm
that it has received data segments.
 Retransmission: If the sender doesn't receive an acknowledgment within a certain timeout
period, it retransmits the lost data segment.
 Error Detection: TCP uses checksums to detect errors in the data during transmission.
Corrupted packets are discarded and retransmitted.
o Ordered Delivery: Due to sequence numbers, even if packets arrive out of order, TCP ensures that the
application at the receiving end receives the data in the correct sequence.
o Flow Control: TCP manages the rate of data transmission to prevent the sender from overwhelming the
receiver. It uses mechanisms like sliding windows to control the amount of data sent before an
acknowledgment is required.
o Congestion Control: TCP also implements mechanisms to detect and respond to network congestion,
reducing the transmission rate to avoid further overloading the network.
o Higher Overhead: Due to the mechanisms for reliability, ordering, and flow control, TCP has a higher
overhead compared to UDP. Each TCP segment includes header information for sequence numbers,
acknowledgments, etc.

TCP (Transmission Control Protocol) is one of the main protocols of the Internet protocol suite. It lies between the
Application and Network Layers which are used in providing reliable delivery services. It is a connection-oriented
protocol for communications that helps in the exchange of messages between different
devices over a network. The Internet Protocol (IP), which
establishes the technique for sending data packets
between computers, works with TCP.

Applications of TCP
 World Wide Web (WWW) : When you browse websites, TCP ensures reliable data transfer
between your browser and web servers.
 Email : TCP is used for sending and receiving emails. Protocols like SMTP (Simple Mail Transfer
Protocol) handle email delivery across servers.
 File Transfer Protocol (FTP) : FTP relies on TCP to transfer large files securely. Whether you’re
uploading or downloading files, TCP ensures data integrity.
 Secure Shell (SSH) : SSH sessions, commonly used for remote administration, rely on TCP for
encrypted communication between client and server.
 Streaming Media : Services like Netflix, YouTube, and Spotify use TCP to stream videos and
music. It ensures smooth playback by managing data segments and retransmissions.
• Web Browsing/HTTP Communication: When an IoT device needs to interact with web
services or APIs using HTTP/HTTPS.
• Secure Data Transfer: Applications requiring guaranteed delivery and integrity of data, such
as firmware updates or critical control commands.
• File Transfer: Sending larger files or datasets from IoT devices to servers.
• Remote Access and Control: Establishing reliable connections for remote management of IoT
devices.
• Email Protocols (SMTP, POP3, IMAP): If an IoT device needs to send or receive emails.

Advantages of TCP

o Reliable data delivery: Guarantees that data will arrive correctly and in order.
o Ordered data delivery: Ensures the receiving application processes data in the intended sequence.
o Flow and congestion control: Helps to manage network resources and prevent data loss.
o Well-established and widely supported.online video chas

 It is reliable for maintaining a connection between Sender and Receiver.


 It is responsible for sending data in a particular sequence.
 Its operations are not dependent on Operating System .
 It allows and supports many routing protocols.
 It can reduce the speed of data based on the speed of the receiver.
Disadvantages of TCP

o Higher overhead: More data needs to be transmitted for control information.


o Increased latency: The connection establishment, acknowledgments, and retransmissions can
introduce delays, making it less suitable for real-time applications where immediate data delivery is
critical

 It is slower than UDP and it takes more bandwidth.


 Slower upon starting of transfer of a file.
 Not suitable for LAN and PAN Networks.
 It does not have a multicast or broadcast category.
 It does not load the whole page if a single data of the page is missing.
UDP (User Datagram Protocol): Fast and Connectionless
UDP, on the other hand, is a connectionless, unreliable, and unordered protocol. Think of it like sending a postcard
– you just send it out without establishing a connection or guaranteeing its arrival.

User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of the Internet Protocol suite,
referred to as the UDP/IP suite. Unlike TCP, it is an unreliable and connectionless protocol. So, there is no
need to establish a connection before data transfer. The UDP helps to establish low-latency and loss-
tolerating connections establish over the network. The UDP enables process-to-process communication.

 Key Characteristics:
o Connectionless: No connection is established before data transmission begins. The sender simply
sends packets (called datagrams) to the receiver without any prior handshake.
o Unreliable Delivery: UDP provides no guarantee that data will reach the destination. Packets may be
lost, duplicated, or arrive out of order. There are no acknowledgments or retransmissions at the UDP
level.
o Unordered Delivery: If multiple UDP packets are sent, they may arrive at the destination in a different
order than they were sent.
o Minimal Overhead: UDP has a very small header, resulting in minimal overhead and efficient use of
bandwidth.
o Faster Transmission: The lack of connection establishment, acknowledgments, and retransmissions
makes UDP faster than TCP.
 Typical Use Cases in IoT:
o Real-time Data Streaming: Applications where timely delivery is more important than guaranteed
delivery, such as streaming sensor data (e.g., environmental readings, telemetry) where occasional
packet loss is acceptable.
o Online Gaming: Where low latency is crucial, and occasional dropped packets are less detrimental than
delays caused by retransmissions.
o Voice over IP (VoIP) and Video Conferencing: Similar to online gaming, real-time delivery is key.
o DNS (Domain Name System): The initial lookups for website IP addresses often use UDP due to its
speed.
o Simple Network Management Protocol (SNMP): Used for managing network devices.
o Broadcasting and Multicasting: Sending data to multiple recipients simultaneously.

 Real-Time Multimedia Streaming : UDP is ideal for streaming audio and video content. Its low-
latency nature ensures smooth playback, even if occasional data loss occurs.
 Online Gaming : Many online games rely on UDP for fast communication between players.
 DNS (Domain Name System) Queries : When your device looks up domain names (like converting
“www.example.com” to an IP address), UDP handles these requests efficiently .
 Network Monitoring : Tools that monitor network performance often use UDP for lightweight, rapid
data exchange.
 Multicasting : UDP supports packet switching, making it suitable for multicasting scenarios where
data needs to be sent to multiple recipients simultaneously.
 Routing Update Protocols : Some routing protocols, like RIP (Routing Information Protocol), utilize
UDP for exchanging routing information among routers.
Advantages of UDP

 It does not require any connection for sending or receiving data.


 Broadcast and Multicast are available in UDP.
 UDP can operate on a large range of networks.
 UDP has live and real-time data.
 UDP can deliver data if all the components of the data are not complete.
 Advantages:
• Lower overhead: More efficient use of bandwidth.
• Faster transmission: Lower latency due to the absence of connection establishment and
reliability mechanisms.
• Suitable for real-time applications.
• Good for broadcasting and multicasting.
 Disadvantages:
• Unreliable delivery: No guarantee that data will arrive.
• Unordered delivery: Receiving application needs to handle potential out-of-order packets.
• No flow or congestion control: The sender can overwhelm the receiver or the network.
• Error detection is basic (checksum only).

Choosing Between TCP and UDP for IoT:

The choice between TCP and UDP in an IoT application depends on the specific requirements:

 Use TCP when:


o Reliability is paramount: You cannot afford to lose data (e.g., firmware updates, critical commands).
o Order of data is important: The sequence of data matters for the application logic.
o The application involves request/response interactions where a reliable connection is needed (e.g.,
HTTP APIs).
 Use UDP when:
o Speed and low latency are critical: Real-time data or control is involved.
o Occasional data loss is acceptable: The application can tolerate some missing data points (e.g.,
streaming sensor readings).
o Broadcasting or multicasting data to multiple devices is required.

Overhead needs to be minimized.

 We can not have any way to acknowledge the successful transfer of data.
 UDP cannot have the mechanism to track the sequence of data.
 UDP is connectionless, and due to this, it is unreliable to transfer data.
 In case of a Collision, UDP packets are dropped by Routers in comparison to TCP.
 UDP can drop packets in case of detection of errors.
Where TCP is Used?
 Sending Emails
 Transferring Files
 Web Browsing
Where UDP is Used?
 Gaming
 Video Streaming
==============================
Differences between TCP and UDP

Basis Transmission Control Protocol (TCP) User Datagram Protocol (UDP)

UDP is the Datagram-oriented


TCP is a connection-oriented protocol. protocol. This is because there is
Connection orientation means that the no overhead for opening a
communicating devices should establish a connection, maintaining a
Type of Service
connection before transmitting data and connection, or terminating a
should close the connection after transmitting connection. UDP is efficient for
the data. broadcast and multicast types of
network transmission.

The delivery of data to the


TCP is reliable as it guarantees the delivery
Reliability destination cannot be guaranteed
of data to the destination router.
in UDP.

TCP provides extensive error-


UDP has only the basic error-
Error checking checking mechanisms. It is because it
checking mechanism
mechanism provides flow control and acknowledgment of
using checksums.
data.

Acknowledgment An acknowledgment segment is present. No acknowledgment segment.

Sequence Sequencing of data is a feature of There is no sequencing of data in


Transmission Control Protocol (TCP). this UDP. If the order is required, it

Basis Transmission Control Protocol (TCP) User Datagram Protocol (UDP)

means that packets arrive in order at the has to be managed by the


receiver. application layer.

UDP is faster, simpler, and more


Speed TCP is comparatively slower than UDP.
efficient than TCP.

There is no retransmission of lost


Retransmission of lost packets is possible in
Retransmission packets in the User Datagram
TCP, but not in UDP.
Protocol (UDP).

TCP has a (20-60) bytes variable length UDP has an 8 bytes fixed-length
Header Length
header. header.
Weight TCP is heavy-weight. UDP is lightweight.

Handshaking Uses handshakes such as SYN, ACK, SYN- It’s a connectionless protocol i.e.
Techniques ACK No handshake

Broadcasting TCP doesn’t support Broadcasting. UDP supports Broadcasting.

TCP is used by HTTP, UDP is used by DNS , DHCP ,


Protocols
HTTPs , FTP , SMTP and Telnet . TFTP, SNMP , RIP , and VoIP .

UDP connection is a message


Stream Type The TCP connection is a byte stream.
stream.

Overhead Low but higher than UDP. Very low.

This protocol is used in situations


This protocol is primarily utilized in situations where quick communication is
when a safe and trustworthy communication necessary but where
Applications
procedure is necessary, such as in email, on dependability is not a concern,
the web surfing, and in military services. such as VoIP, game streaming,
video, and music streaming, etc.
What is Bluetooth?
Bluetooth is used for short-range wireless voice and data communication. It is a Wireless Personal Area
Network (WPAN) technology and is used for data communications over smaller distances. This generation
changed into being invented via Ericson in 1994. It operates within the unlicensed, business, scientific, and
clinical (ISM) bands from 2.4 GHz to 2.485 GHz.

Bluetooth stages up to 10 meters. Depending upon the version, it presents information up to at least 1
Mbps or 3 Mbps. The spreading method that it uses is FHSS (Frequency-hopping unfold spectrum). A
Bluetooth network is called a piconet and a group of interconnected piconets is called a scatter net.
Bluetooth is a wireless technology that lets devices like phones, tablets, and headphones connect to each
other and share information without needing cables. Bluetooth simply follows the principle of transmitting
and receiving data using radio waves. It can be paired with the other device which has also Bluetooth but it
should be within the estimated communication range to connect. When two devices start to share data,
they form a network called piconet which can further accommodate more than five devices.
Key Features of Bluetooth

 The transmission capacity of Bluetooth is 720 kbps.


 Bluetooth is a wireless technology.
 Bluetooth is a Low-cost and short-distance radio communications standard.
 Bluetooth is robust and flexible.
 The basic architecture unit of Bluetooth is a piconet.
Architecture of Bluetooth

The architecture of Bluetooth defines two types of networks:


Piconet
Piconet is a type of Bluetooth network that contains one primary node called the master node and seven
active secondary nodes called slave nodes. Thus, we can say that there is a total of 8 active nodes which
are present at a distance of 10 meters. The communication between the primary and secondary nodes can
be one-to-one or one-to-many. Possible communication is only between the master and slave; Slave-slave
communication is not possible. It also has 255 parked nodes, these are secondary nodes and cannot take
participation in communication unless it gets converted to the active state.

Scatternet
It is formed by using various piconets. A slave that is present in one piconet can act as master or we can
say primary in another piconet. This kind of node
can receive a message from a master in one
piconet and deliver the message to its slave in the
other piconet where it is acting as a master. This
type of node is referred to as a bridge node. A
station cannot be mastered in two piconets.
Bluetooth in IoT: Short-Range Connectivity
Bluetooth technology enables devices to communicate wirelessly over short distances (typically up to 10-
100 meters, depending on the class and version). Its low power consumption, relatively low cost, and
widespread availability make it a popular choice for many IoT use cases.

 Key Characteristics Relevant to IoT:


o Short-Range Communication: Designed for communication between devices in close
proximity.
o Low Power Consumption: Especially Bluetooth Low Energy (BLE), also known as Bluetooth
Smart, which is specifically optimized for battery-powered devices. This is a crucial factor for
many IoT applications.
o Low Cost: Bluetooth chips and modules are generally inexpensive, making it an accessible
technology for mass-produced IoT devices.
o Widespread Availability: Integrated into a vast majority of smartphones, tablets, laptops, and
many other consumer electronics, making it easy for IoT devices to connect to these central
hubs.
o Ease of Pairing and Use: Bluetooth offers relatively straightforward pairing processes,
making it user-friendly for connecting devices.
o Different Versions and Profiles: Bluetooth has evolved through various versions (e.g.,
Classic Bluetooth, Bluetooth 4.0, Bluetooth 5.x), each offering different features in terms of
speed, range, and power efficiency. Bluetooth Low Energy (BLE), introduced in Bluetooth
4.0, is particularly significant for IoT due to its ultra-low power consumption. Bluetooth
profiles define how devices use Bluetooth for specific applications (e.g., data transfer, audio
streaming, health devices).
 Key Aspects of Bluetooth in IoT:
o Personal and Wearable IoT: BLE is extensively used in wearable devices like smartwatches,
fitness trackers, and health monitors to connect to smartphones or other central devices for
data synchronization and control.
o Proximity-Based Applications: Bluetooth beacons utilize BLE to broadcast signals that
nearby devices can detect, enabling location-based services, indoor navigation, and
proximity marketing.
o Smart Home Devices: Bluetooth is used for direct control and setup of some smart home
devices, such as smart bulbs, locks, and speakers, often communicating directly with a
smartphone or a central hub with Bluetooth capabilities.
o Health and Medical IoT: BLE is crucial for connecting medical sensors (e.g., glucose
monitors, heart rate sensors) to smartphones or medical gateways for data collection and
remote monitoring.
o Industrial IoT (IIoT): While not as dominant as other protocols, Bluetooth can be used in
specific industrial applications for short-range communication, device configuration, and
localized data collection, especially in environments where low power and existing Bluetooth
infrastructure are advantageous.
o Automotive IoT: Bluetooth is widely used for connecting smartphones to car infotainment
systems, and increasingly for communication with in-car sensors and other devices.
o Retail and Marketing: Bluetooth beacons are used for proximity marketing, offering
personalized deals and information to shoppers based on their location within a store.
 Advantages of Using Bluetooth in IoT:
o Low Power Consumption (BLE): Enables battery-powered operation for extended periods,
crucial for many IoT sensors and wearables.
o Direct Connectivity to Smartphones: Leverages the widespread adoption of Bluetooth in
smartphones as a convenient control and data gateway.
o Relatively Simple Implementation: Development tools and libraries for Bluetooth are readily
available for various platforms.
o Secure Communication: Modern Bluetooth versions offer robust security features, including
encryption.
o Mesh Networking (Bluetooth Mesh): Introduced in later versions, Bluetooth Mesh allows for
the creation of large-scale, low-power networks where devices can relay messages,
extending the communication range and enabling applications like smart lighting in entire
buildings.
 Disadvantages of Using Bluetooth in IoT:
o Limited Range: Compared to Wi-Fi or cellular technologies, Bluetooth's range is relatively
short, restricting its use in wide-area deployments without intermediate devices.
o Lower Bandwidth: While sufficient for many sensor data and control applications, Bluetooth's
bandwidth is lower than Wi-Fi, making it less suitable for high-throughput data transfer like
video streaming.
o Interference: Like other wireless technologies, Bluetooth can be susceptible to interference
from other radio sources operating in the same frequency band (2.4 GHz).
o Pairing Requirements: While generally straightforward, the initial pairing process can
sometimes be a hurdle for less tech-savvy users.

these Programming APIs and Communication Protocols are key Software Components in building IoT
solutions. They bridge the gap between the physical hardware and the applications that make the IoT system
intelligent and useful. Let's recap how they fit into the broader IoT software landscape:

IoT Software Components: Orchestrating the


Connected World
Beyond the hardware, the software components are what give IoT devices their functionality, enabling them
to communicate, process data, and interact with users and other systems. The elements you listed –
Programming APIs for Communication Protocols – are a crucial layer within this software stack.

Here's a broader view of typical IoT software components, with your focus area highlighted:

1. Device Software (Firmware): This is the software that runs directly on the IoT devices themselves,
often on microcontrollers like those found in Arduino or the processors of Raspberry Pi. It's
responsible for:
o Interfacing with sensors and actuators.
o Local data processing and control logic.
o Implementing communication protocols to interact with other devices or the cloud. This is
where the Programming APIs you mentioned come into play.
2. Connectivity and Communication Middleware: This layer handles the complexities of network
communication between devices and the cloud or other on-premise systems. It often involves:
o Implementing and managing various communication protocols (MQTT, CoAP, etc.).
o Handling different network types (Wi-Fi, cellular, LoRaWAN, etc.).
o Ensuring secure communication.
o Device management aspects related to connectivity.
3. IoT Platforms and Cloud Services: These are often cloud-based services that provide a
comprehensive set of tools and capabilities for managing and leveraging IoT data. They typically
include:
o Device Management: Provisioning, onboarding, configuring, monitoring, and updating
devices.
o Data Ingestion and Storage: Receiving and storing the vast amounts of data generated by
IoT devices.
o Data Processing and Analytics: Analyzing the collected data to derive insights, identify
patterns, and trigger actions.
o Rules Engine and Event Processing: Defining rules and workflows based on real-time data
from devices.
o Visualization and User Interfaces: Creating dashboards and applications for users to interact
with the IoT system.
o Security Services: Protecting devices, data, and communication channels.
o Application Enablement: Providing tools and APIs for developers to build IoT applications.
4. Applications and User Interfaces: These are the end-user facing applications that allow users to
interact with and benefit from the IoT system. This could be mobile apps, web dashboards, or
integrations with other enterprise systems.

The Role of Programming APIs for Communication Protocols:

The Programming APIs (using Python, Node.js, Arduino) are the tools that developers use within the
Device Software and sometimes within the Connectivity and Communication Middleware layers to
implement the specific Communication Protocols (MQTT, ZigBee, Bluetooth, CoAP, UDP, TCP).

 Abstraction: These APIs abstract away the low-level details of the communication protocols, making
it easier for developers to send and receive data without needing to understand the intricate
workings of each protocol.
 Ease of Development: They provide functions and libraries that simplify tasks like connecting to
brokers or devices, subscribing to topics, publishing messages, handling data formats, and
managing connections.
 Platform Specificity: The choice of API often depends on the programming language being used on
the IoT device or gateway (Python on Raspberry Pi, C/C++ on Arduino, JavaScript/Node.js on more
powerful edge devices).

Programming APIs for IoT Communication


Protocols
An API (Application Programming Interface) is a set of rules and specifications that allows different
software components to communicate with each other. In the context of IoT, programming APIs provide a
way for developers to interact with the underlying communication protocols using their chosen
programming language.

Let's explore the common programming languages and the APIs they offer for the communication protocols
you mentioned:

1. Python APIs:

Python is a very popular language for IoT development due to its readability, extensive libraries, and ease of
use.

 MQTT (Message Queuing Telemetry Transport):


o paho-mqtt: This is a widely used and well-maintained Python client library for MQTT. It
provides functions for:
 Connecting to an MQTT broker.
 Subscribing to topics.
 Publishing messages to topics.
 Handling message reception and disconnections.
 Implementing QoS (Quality of Service) levels.
 Using TLS/SSL for secure communication.
o asyncio-mqtt: For asynchronous MQTT communication using Python's asyncio library,
suitable for building highly concurrent applications.
 ZigBee:
o Python support for ZigBee often involves interacting with hardware modules (like those from
Digi or Texas Instruments) through serial communication. Libraries like pyserial are used
to handle this serial communication.
o Higher-level libraries might exist depending on the specific ZigBee hardware and gateway
being used. Frameworks like Home Assistant (written in Python) provide abstractions for
interacting with various ZigBee devices through dedicated integrations.
 Bluetooth:
o pybluez: A common library for accessing Bluetooth resources on Linux. It allows you to:
 Scan for nearby Bluetooth devices.
 Connect to Bluetooth devices.
 Discover services and characteristics (for Bluetooth Low Energy - BLE).
 Read and write data to characteristics.
 Implement Bluetooth servers.
o bleak: A more modern and cross-platform (Linux, macOS, Windows) library specifically
focused on Bluetooth Low Energy (BLE). It provides asynchronous support and a cleaner
API for interacting with BLE devices.
 CoAP (Constrained Application Protocol):
o aiocoap: An asynchronous Python library for CoAP, built on asyncio. It supports both client
and server implementations of CoAP.
o coapy: Another Python library for CoAP, offering a more synchronous approach.
 UDP (User Datagram Protocol) and TCP (Transmission Control Protocol):
o Python's built-in socket module provides low-level access to network sockets, allowing you
to implement both UDP and TCP communication directly. You can create UDP and TCP
clients and servers, send and receive data, and manage connections.

2. Node.js APIs:

Node.js, with its event-driven, non-blocking I/O model, is also popular for IoT gateways and backend
services.

 MQTT:
o mqtt: A widely used and robust MQTT client library for Node.js. It offers similar
functionalities to paho-mqtt in Python:
 Connecting to a broker.
 Subscribing and publishing.
 Handling events (connect, message, disconnect).
 Supporting QoS and secure connections.
 ZigBee:
o Node.js support for ZigBee often involves using libraries that interact with ZigBee coordinator
hardware (connected via USB or network).
o Libraries like zigbee-herdsman are used in projects like Zigbee2MQTT to bridge ZigBee
devices to an MQTT broker. These libraries handle the complexities of the ZigBee protocol.
 Bluetooth:
o noble: A popular library for interacting with Bluetooth Low Energy (BLE) peripherals on
Linux, macOS, and Windows. It allows you to scan for devices, connect, discover services
and characteristics, and read/write data.
o Other libraries like bleno can be used to create BLE peripherals (advertise services and
characteristics) with Node.js.
 CoAP:
o coap: A Node.js library for implementing CoAP clients and servers. It supports the core
CoAP features and allows you to build resource-constrained applications.
 UDP and TCP:
o Node.js provides the built-in net module for TCP and the dgram module for UDP. These
modules offer asynchronous APIs for creating sockets, sending and receiving data, and
managing connections.

3. Arduino Language APIs (for ESP8266/ESP32 and other connected boards):

When programming directly on Arduino boards that have network capabilities (like ESP8266 or ESP32),
you often use specific libraries provided by the board's SDK or the Arduino community.

 MQTT:
o PubSubClient: A very popular and widely used MQTT client library for Arduino (compatible
with ESP8266, ESP32, and other boards). It offers functions for connecting, subscribing,
publishing, and handling messages.
 ZigBee:
o Direct ZigBee communication on standard Arduino boards often requires interfacing with
external ZigBee modules (via serial). You would then need to implement the ZigBee protocol
logic yourself or use libraries specific to the module.
o On ESP32, some libraries might provide more direct support for certain ZigBee chips.
 Bluetooth:
o For ESP32, the built-in Bluetooth capabilities are often accessed through libraries provided
in the ESP-IDF (Espressif IoT Development Framework), which can be used with the
Arduino environment. These libraries allow for BLE scanning, advertising, connecting, and
data transfer.
 CoAP:
o Libraries like CoapClient and CoapServer are available for Arduino (especially for
ESP8266/ESP32) to implement CoAP communication.
 UDP and TCP:
o For network-enabled Arduino boards (like ESP8266 and ESP32), libraries like WiFiUdp (for
UDP) and WiFiClient (for TCP) are part of the standard Arduino core for these boards.
They provide functions for creating sockets, sending and receiving data over Wi-Fi.

Key Concepts When Using These APIs:

 Client vs. Server/Broker: For protocols like MQTT and CoAP, you'll often have clients (your IoT
devices) communicating with a central server (MQTT broker) or other servers. For protocols like
TCP and UDP, devices can act as both clients and servers.
 Publish/Subscribe (Pub/Sub): MQTT is based on this pattern, where devices publish messages to
topics, and other devices subscribe to those topics to receive the messages.
 Request/Response: CoAP follows a more traditional request/response model similar to HTTP.
 Sockets: UDP and TCP communication is built on the concept of sockets, which are endpoints for
network communication.
 Asynchronous vs. Synchronous Programming: Some libraries (especially in Node.js and modern
Python) offer asynchronous APIs, allowing your program to perform other tasks while waiting for
network operations to complete, leading to more efficient and responsive applications.
 Event Handling: Many network libraries use event-driven programming, where your code defines
functions to be executed when specific network events occur (e.g., a new message arrives, a
connection is established).

You might also like