IOT
IOT
The Internet of Things (IoT) refers to a network of interconnected physical devices embedded with sensors,
software, and other technologies that enable them to collect, exchange, and analyze data over the internet.
These devices can range from everyday household items like smart thermostats and wearable health monitors
to industrial machinery and smart city infrastructure.
The Internet of Things (IoT) is transforming industries and daily life by enabling connectivity, automation, and
data-driven decision-making. Its significance spans multiple sectors, enhancing efficiency, productivity, and
convenience.
Smart devices can monitor and control operations in real time (e.g., industrial automation, smart
homes).
IoT provides real-time data collection and analysis, allowing quick responses to issues.
Example: Healthcare IoT devices track patient vitals and alert doctors in emergencies.
Optimizes resource usage (e.g., smart grids manage energy distribution efficiently).
Smart homes enhance convenience with automated lighting, security, and climate control.
IoT enables intelligent traffic management, waste management, and energy-efficient buildings.
6. Industry Transformation
IoT generates vast amounts of data that drive AI and machine learning innovations.
Businesses leverage IoT analytics for better decision-making and customer experiences.
IoT is revolutionizing various industries by enabling smart connectivity, automation, and data-driven
decision-making. Below are key application areas:
1. Smart Homes 🏠
Smart Appliances: IoT-enabled refrigerators, washing machines, and air conditioners optimize energy
use.
Home Security: Smart cameras, motion sensors, and connected door locks enhance security.
Lighting & Climate Control: Smart thermostats (e.g., Nest) and automated lighting systems improve
convenience and energy efficiency.
Remote Patient Monitoring: IoT devices track vital signs (e.g., heart rate, oxygen levels) and alert
doctors in emergencies.
Wearable Devices: Smartwatches and fitness bands monitor health metrics like steps, sleep patterns,
and calories burned.
Smart Hospitals: IoT-enabled equipment, smart beds, and automated medicine dispensers enhance
patient care.
Predictive Maintenance: IoT sensors detect machine faults early, reducing downtime.
Automation & Robotics: Smart robots improve production efficiency and quality control.
4. Smart Cities
Traffic Management: IoT-enabled traffic signals optimize flow and reduce congestion.
Waste Management: Smart bins signal when they need emptying, improving efficiency.
Pollution Monitoring: Sensors track air and water quality for environmental management.
Precision Farming: IoT sensors monitor soil moisture, temperature, and nutrient levels to optimize
irrigation.
Automated Irrigation: Smart irrigation systems reduce water wastage and improve crop yield.
Energy Optimization: IoT-based power grids improve efficiency and reduce outages.
Renewable Energy Management: Monitors and optimizes solar and wind energy production.
7. Transportation & Logistics 🚚
Fleet Management: IoT GPS tracking ensures real-time vehicle monitoring and route optimization.
Smart Parking: IoT sensors detect available parking spots and guide drivers.
Autonomous Vehicles: IoT enables self-driving cars by integrating AI, sensors, and cloud data.
Smart Shelves & Inventory Management: Sensors track stock levels and restock needs.
Veterinary IoT: Wearable devices track animal health in dairy farms and zoos.
Autonomous Defense Systems: AI-integrated IoT for threat detection and response.
IoT Architecture
The Internet of Things (IoT) architecture defines the structure and components of an IoT system, enabling
seamless connectivity, data processing, and decision-making. The architecture is typically divided into multiple
layers, ensuring efficient communication between devices and applications.
This is the physical layer where IoT devices and sensors collect data from the environment.
🔹 Components:
Cameras
Wearable devices
🔹 Function:
This layer transmits data from IoT devices to the cloud, edge servers, or gateways.
🔹 Communication Technologies:
Wired: Ethernet, Fiber Optics
🔹 Function:
This layer processes data closer to the source before sending it to the cloud, reducing latency and bandwidth
usage.
🔹 Components:
IoT Gateways
Fog Nodes
🔹 Function:
This layer is responsible for storing, analyzing, and managing IoT data in centralized cloud or on-premise
servers.
🔹 Technologies:
Cloud Platforms (AWS IoT, Microsoft Azure IoT, Google Cloud IoT)
🔹 Function:
This is the end-user layer where IoT data is visualized, monitored, and controlled.
🔹 Components:
🔹 Function:
1. Sensing – The sensor detects changes in a physical parameter (e.g., light, heat, motion, gas).
2. Conversion – The sensor converts the detected physical signal into an electrical signal.
3. Processing – The electrical signal is processed (filtered, amplified) for further use.
4. Transmission – The processed data is sent to an IoT gateway, microcontroller (e.g., Arduino, Raspberry
Pi), or cloud for analysis and action.
Working: Measures temperature changes using thermistors, infrared (IR), or resistance variations.
Working: Measures moisture in the air using a capacitive or resistive sensing element.
Working: Detects infrared radiation from moving objects (e.g., humans, animals).
Working: Detects gas concentration (CO, CO₂, methane) through chemical reactions that change
electrical resistance.
Use Cases: Air quality monitoring, gas leak detection, industrial safety.
Working: Measures the distance of nearby objects using sound waves (ultrasonic) or infrared signals.
Working: Changes resistance based on light intensity. More light = lower resistance.
Example: SW-420
Working: Uses infrared light absorption to measure pulse and oxygen levels.
Working: Uses radio waves for short-range wireless communication and object identification.
After sensing data, the sensor sends it to a microcontroller (Arduino, Raspberry Pi, ESP8266, ESP32), where it
is processed and transmitted using:
Cloud services (AWS IoT, Google Cloud, Microsoft Azure) then process, store, and analyze the data for decision-
making.
Actuators in IoT
An actuator is a device that converts electrical signals into physical actions (motion, pressure, sound, or light).
Actuators are essential in IoT systems, enabling automated responses based on sensor data.
1. How Actuators Work?
1. Signal Reception – The actuator receives a control signal from a microcontroller (e.g., Arduino,
Raspberry Pi).
2. Energy Conversion – Converts electrical energy into mechanical movement or another form of output.
3. Action Execution – Performs a task (e.g., rotating a motor, opening a valve, turning on a light).
For example, in a smart home, if a temperature sensor detects high heat, an actuator (fan or AC) is triggered to
cool the room.
Sensor calibration is the process of adjusting a sensor’s readings to match a known standard or reference
value. This ensures accuracy, reliability, and consistency in measurement. Calibration compensates for sensor
drift, aging, and environmental changes.
Example: Gas sensors calibrated using zero gas (clean air) and a known gas concentration.
Unit-2
What is UART?
UART (Universal Asynchronous Receiver-Transmitter) is a serial communication protocol that enables two
devices to exchange data without a clock signal. It is widely used in embedded systems, microcontrollers
(Arduino, Raspberry Pi), IoT devices, GPS modules, and sensors.
Start Bit Data Bits (5-9) Parity Bit (Optional) Stop Bit (1-2)
Start Bit (1-bit) → Indicates start of data transmission (always LOW (0)).
Stop Bit (1-2 bits) → Indicates end of data transmission (always HIGH (1)).
3. How UART Works? (Step-by-Step)
1. Sender (TX) converts parallel data (e.g., 8-bit ASCII character) into a serial stream.
2. Start bit (0) is sent, followed by data bits, parity bit (if used), and stop bit.
3. Receiver (RX) synchronizes with the start bit and reads the incoming bits.
TX (Arduino) → RX (ESP8266)
RX (Arduino) ← TX (ESP8266)
✅ Advantages
❌ Disadvantages
6. Applications of UART
What is I²C?
I²C (Inter-Integrated Circuit) is a synchronous serial communication protocol that allows multiple devices
(sensors, microcontrollers, and peripherals) to communicate over two wires (SDA & SCL). It is widely used in
IoT, embedded systems, and industrial automation.
Wire Function
Master Device: Controls the clock and initiates communication (e.g., Microcontroller).
VCC → 3.3V or 5V
GND → GND
#include <Wire.h>
void setup() {
Serial.begin(9600);
Wire.endTransmission();
}
void loop() {
Wire.beginTransmission(0x68);
Wire.endTransmission(false);
delay(500);
START Slave Address R/W Bit ACK/NACK Data Frame Stop Bit
LOW (0) 7-bit address 1-bit (Read/Write) Acknowledgment 8-bit data HIGH (1)
What is Wi-Fi?
Wi-Fi (Wireless Fidelity) is a wireless communication technology that uses radio waves to transmit data
between devices. It enables devices to connect to the internet or local area networks (LANs) without using
physical cables. Wi-Fi is based on the IEEE 802.11 standard.
What is a Router?
A router is a networking device that forwards data between devices on a network and enables communication
between a local network (e.g., home or office) and the internet. Routers can connect via wired or wireless
networks.
o A device that provides the Wi-Fi signal and connects to the router. It could be part of the
router itself or a separate unit.
3. Router
o Forwards data from the client devices to the internet and vice versa.
3. Client devices like smartphones or IoT sensors connect to the router via the AP.
4. Data from the device is sent through the AP, then to the router, which forwards it to the internet (or
vice versa).
Router Ports (LAN Ports): Devices can connect to the router using an Ethernet cable.
Data Flow: Data flows from the device to the router via wired Ethernet.
Reliability: Wired connections are generally more stable and faster but require cables.
Wi-Fi Interface: Wireless devices connect to the router via radio waves.
SSID (Service Set Identifier): The Wi-Fi network name that helps identify the router.
Encryption & Security: Wi-Fi typically uses security protocols like WPA2/WPA3 to ensure secure
communication.
Open a browser and type the router's IP address (usually 192.168.1.1 or 192.168.0.1).
Once authenticated, the device connects to the Wi-Fi router and can access the internet or network
resources.
Solution:
2️⃣ No Connection
Solution:
o Ensure the router is powered on and connected to the internet.
Solution:
o Check for interference from other Wi-Fi networks (e.g., change channels).
Use a complex password for the Wi-Fi network to prevent unauthorized access.
2️⃣ Encryption
Set up MAC address filtering to allow only specific devices to connect to your router.
Keep the router firmware up-to-date to fix security vulnerabilities and improve performance.
Ethernet provides a reliable and fast wired communication method for connecting devices to a network.
Ethernet configuration involves setting up a device to connect to a network via an Ethernet cable, which links
the device to a router or switch. Here's how you can configure Ethernet connections for various devices.
Ethernet Cable: A physical cable (Cat 5e, Cat 6, etc.) that connects the device to a router or switch.
Router/Switch: A device that manages traffic between the device and the internet or local network.
Network Interface Card (NIC): A hardware component in a device that allows it to connect to the
Ethernet network.
IP Address: A unique address that identifies the device on the network. Can be assigned manually
(Static IP) or automatically (Dynamic IP via DHCP).
To assign a static IP address to a device, you need to configure the network settings manually. This method
ensures the device always has the same IP address on the network.
o Plug one end of the Ethernet cable into your computer and the other end into the router or
switch.
o Click on the Start menu, then go to Control Panel > Network and Sharing Center > Change
adapter settings.
o In the Properties window, select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
IP Address: 192.168.1.100 (make sure the IP is within your router's range but
outside the DHCP range).
o You can use a custom DNS or leave it to Automatic. Common DNS servers:
6. Save Settings
If your router is configured to provide IP addresses automatically, your device can be set to obtain an IP address
dynamically using DHCP (Dynamic Host Configuration Protocol).
o Plug one end of the Ethernet cable into your computer and the other end into the router or
switch.
2. Open Network Settings
o Go to Control Panel > Network and Sharing Center > Change adapter settings.
o In the Properties window, select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
o Select Obtain an IP address automatically and Obtain DNS server address automatically.
5. Save Settings
A. Check IP Address
3. Look for Ethernet Adapter or en0 (on macOS/Linux). Verify the IP address is correct.
B. Ping Test
2. Type ping 192.168.1.1 (replace with your router's IP address) and press Enter.
A. Raspberry Pi (Linux-based)
1. Connect Ethernet Cable: Plug the cable into the Raspberry Pi and the router.
o For Static IP, click on the interface, go to IPv4 Settings, and configure the IP address, Subnet
mask, and Gateway.
3. #include <SPI.h>
4. #include <Ethernet.h>
5.
6. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Set MAC address
8.
10.
13. server.begin();
14. }
15.
19. }
Solution: Ensure that the Ethernet cable is plugged in properly and is in good condition. Try replacing
the cable if the connection is intermittent.
B. IP Address Conflicts
Solution: Ensure that each device has a unique IP address, especially in Static IP configurations.
C. No Internet Access
Solution: Verify that the router is correctly connected to the internet. Check the network settings on
both the router and the device.
Bluetooth is a wireless communication technology that allows devices to communicate over short distances. It
is widely used for transferring data between devices like smartphones, laptops, wearables, and IoT devices.
Bluetooth operates in the 2.4 GHz ISM band and uses low-power radio waves to facilitate communication.
1. Bluetooth Devices:
Devices that communicate using Bluetooth technology, such as smartphones, laptops, wearables,
sensors, etc.
2. Bluetooth Modules:
Hardware components that enable Bluetooth communication, like HC-05, HC-06 (classic Bluetooth), or
BLE modules (Bluetooth Low Energy).
3. Bluetooth Profiles:
Defines the functionality of Bluetooth communication. Some common profiles include:
o HFP (Hands-Free Profile): Used for wireless communication between a mobile phone and a
hands-free device.
o A2DP (Advanced Audio Distribution Profile): For streaming audio between devices like
Bluetooth speakers and smartphones.
o GATT (Generic Attribute Profile): Used in BLE devices for communication between a central
device (e.g., smartphone) and peripheral devices (e.g., sensors).
Bluetooth communication follows a sequence of steps that define the data flow from one device to another.
Below is a basic overview of how Bluetooth data flow occurs:
Before data can be transferred, Bluetooth devices must first pair with each other.
1. Discovering Devices:
A Bluetooth device sends a device inquiry to find other available Bluetooth devices in its range.
The device then receives a list of advertising devices with their unique MAC addresses.
2. Pairing Process:
Once a device is selected, a pairing request is sent to the other device. Depending on the security
level, this might require entering a PIN code or authentication.
If successful, the devices are paired and share an encrypted link key for secure communication.
3. Device Bonding:
Bonding is the process of storing pairing information for future communication. It helps devices
reconnect automatically without needing to pair again.
1.2 Bluetooth Data Flow (Using SPP Profile for Classic Bluetooth)
In classic Bluetooth (e.g., SPP - Serial Port Profile), the data flow is as follows:
1. Data Transmission:
o Device 1 (e.g., smartphone) sends a data packet to Device 2 (e.g., Bluetooth sensor).
o The data packet is broken down into small frames and sent over the Bluetooth link.
2. Bluetooth Radio:
o Bluetooth devices use the radio frequency to transmit data over short distances (typically up
to 100 meters).
o Each frame contains a payload (the actual data) along with control information like address,
sequence number, and checksum.
3. Receiver Device:
o Device 2 receives the data packet, processes it, and sends an acknowledgment (ACK) if the
data is correctly received.
4. Data Parsing:
o The payload (data) is parsed according to the Bluetooth profile (e.g., SPP for serial data, A2DP
for audio).
5. Feedback:
o Device 2 may send response data back to Device 1 in the same manner.
o Depending on the application, the data flow could be bidirectional (e.g., IoT sensors sending
data to a mobile app and receiving commands back).
In Bluetooth Low Energy (BLE), the data flow is more efficient and optimized for lower power consumption,
using a different protocol than classic Bluetooth.
1. Advertising:
o BLE devices send advertisements to signal their presence to other devices (e.g.,
smartphones).
o An advertisement packet contains information about the device and services it offers.
2. Scanning:
o A device (e.g., smartphone) scans for nearby BLE devices by listening to the advertisement
packets.
3. Connection Establishment:
o Once a device detects the advertisement, it initiates a connection request to the advertising
device.
o Upon connection, the devices establish a GATT (Generic Attribute Profile) server-client
relationship. The GATT profile defines how data is exchanged between devices.
4. Data Exchange:
o Each characteristic has a handle and can hold a single value (e.g., sensor data).
o The central device (e.g., smartphone) can read or write values to/from the peripheral device
(e.g., Bluetooth-enabled heart rate monitor).
5. Disconnect:
o After the data exchange is complete, the devices can either remain connected for future data
transfers or disconnect to save power.
1. Device Discovery:
The smartphone scans for Bluetooth devices in the vicinity, and the heart rate monitor starts
advertising its presence.
The user may be prompted to enter a PIN code. After successful pairing, a secure link is established.
The smartphone sends a read request to the heart rate monitor to obtain the current heart rate.
The heart rate monitor replies with the value in a GATT characteristic.
4. Data Handling:
The smartphone receives the heart rate data and processes it. The data may be displayed in the form
of a graph or numeric value in a fitness application.
5. Feedback:
The smartphone can send commands back to the heart rate monitor (e.g., to change measurement
mode or configure settings).
6. Disconnection:
After completing the data exchange, the smartphone and heart rate monitor disconnect to save
battery life.
Zigbee is a low-power, wireless communication protocol designed for creating personal area networks (PANs).
It is widely used in applications that require low data rates, long battery life, and secure communication, such
as home automation, industrial control, and healthcare systems.
Mesh networking allowing devices to communicate over a wide area by relaying signals.
Zigbee is designed to be simple and efficient, allowing low-power devices to communicate with each other. It is
based on the IEEE 802.15.4 standard, which defines the physical and data link layers of the communication.
Zigbee Devices:
1. Coordinator (ZC): The central device in a Zigbee network. It is responsible for network formation,
management, and addressing.
2. Router (ZR): A device that relays messages between devices and extends the network range.
3. End Devices (ZED): Devices that communicate with routers and coordinators. They don’t relay
messages and have limited power consumption.
Mesh topology: Devices communicate with each other through routers, extending the network range.
Cluster Tree topology: A hybrid of star and mesh topology, often used in larger networks.
Before data transmission begins, Zigbee devices must first form a network, which typically involves the
following steps:
1. Association:
Devices must associate with the network coordinator. The coordinator initiates the network and
assigns network addresses to devices.
2. Addressing:
Zigbee uses both 16-bit short addresses and 64-bit extended addresses (similar to MAC addresses).
Devices are assigned addresses during association.
3. Routing Table:
Routers create routing tables to forward messages to the correct destination. These tables are built as
devices communicate.
The data transmission in Zigbee follows a series of steps that involve the physical, data link, and network layers.
1. Message Creation:
o A device (ZED) creates a message (data packet) to send to the destination. The message is
encapsulated in a MAC frame.
o The packet contains data (payload) and control information such as source address,
destination address, and frame type.
2. Frame Preparation:
o The MAC layer prepares the frame for transmission. It adds error-checking codes (e.g., CRC)
to ensure data integrity.
o The message is passed to the PHY layer, which handles the transmission of the signal over
the air.
3. Transmission:
o The message is transmitted by the sender (ZED or ZR) through the RF channel using a
modulated signal.
o The signal travels through the air, and neighboring devices in the range receive the signal.
o The router or coordinator receives the signal, extracts the frame, and checks for errors.
o If the destination address matches a device in its network, the router forwards the message
to the correct device.
o In mesh mode, if the destination device is out of range, intermediate routers can relay the
message. The data packet will pass through multiple hops.
o Each router in the mesh network stores and forwards data based on its routing table.
6. Message Delivery:
o Once the destination device (ZED) receives the packet, it processes the message (data).
o The device sends an acknowledgment (ACK) back to the source to confirm successful
delivery.
7. Error Handling:
o If an error occurs in transmission (e.g., due to interference or signal loss), Zigbee devices will
attempt to retransmit the message or perform error correction.
1. MAC Layer:
o The Medium Access Control (MAC) layer is responsible for managing access to the
communication medium.
o It also manages sleep modes for energy efficiency, allowing devices to wake up only when
necessary.
2. PHY Layer:
o The Physical (PHY) layer handles the actual transmission of data over the air using radio
frequencies.
o The PHY layer is responsible for modulation, demodulation, frequency hopping, and channel
selection.
In this example, we will consider a smart home system where Zigbee devices control lighting and security
systems.
3. Data Transmission:
The motion sensor (ZED) sends the data packet to the nearest router (ZR) in the network. If the router
is out of range, the data will be relayed by another router.
5. Message Delivery:
The coordinator processes the received data, which is a trigger for an action (e.g., turning on the
lights). It sends a message back to the smart bulb (ZED) to switch on.
6. Acknowledgment:
After receiving the command to turn on, the smart bulb sends an acknowledgment (ACK) to the
coordinator, confirming that the action has been performed.
7. Feedback Loop:
The system can monitor the status of the smart bulb and send further commands based on new
sensor data (e.g., turn off the light after no motion is detected for a period).
To interface a Zigbee module (e.g., Xbee or CC2530) with a microcontroller like Arduino, follow these steps:
1. Hardware Setup:
o Connect the Zigbee module to the Arduino using a serial connection (TX, RX pins) and power
pins (Vcc, GND).
o If using an Xbee module, a Xbee shield can be used to make the connection easier.
2. Software Configuration:
o Use the Serial Monitor in Arduino IDE to communicate with the Zigbee module.
o You can configure the Zigbee device to operate as a ZC, ZR, or ZED by setting the appropriate
Xbee AT commands or configuring Zigbee stack settings.
o You can send data (e.g., sensor readings, commands) using Serial.write() and receive data
using Serial.read() in the Arduino program.
4. Network Communication:
o Zigbee communication involves sending messages between the devices. Ensure that the
network addresses (16-bit or 64-bit) are configured to route data correctly.
#include <SoftwareSerial.h>
SoftwareSerial Zigbee(2, 3); // RX, TX pins for Zigbee module
void setup() {
Serial.begin(9600);
void loop() {
if (Zigbee.available()) {
if (Serial.available()) {