Iot 4
Iot 4
Powe
Range Application Latency
Efficiency
Medium to
~10m (100m Medium
Range ~100m ~100m 10+ km 10+ km Medium (LAN) 1+ km Long (LAN,
BLE 5.0) (WAN)
WAN, Cloud)
Power
High Very Low (BLE) Low Very Low Low Low High High Low
Consumption
Low to
Latency Low Very Low Low High High Low High Ultra-low
Medium
Up to 2 Mbps
Data Rate Up to 1 Gbps 250 kbps 0.3–50 kbps ~100 kbps 10s of kbps Mbps Gbps 10s of kbps
(BLE 5.0)
Supports
AES AES AES Cellular 5G Security
Security WPA2, WPA3 DTLS TLS/SSL TLS/SSL
encryption encryption encryption encryption Framework
encryption
Cloud
Wearables, Smart homes, Smart Resource- Smart cities, communicatio
Smart Homes, Agriculture, Web-based
Use Cases Smart home Industrial metering, constrained Autonomous n, Industrial
Industrial IoT Smart Cities IoT, APIs
devices sensors Industrial IoT devices vehicles IoT, Remote
Monitoring
MQTT Protocol
(Message Queuing Telemetry Transport)
What is the MQTT protocol?
• IoT MQTT is a lightweight publish/subscribe messaging protocol
designed for M2M (machine to machine) telemetry in low bandwidth
environments.
• MQTT is fast becoming one of the main protocols for IOT (internet of
things) deployments.
Main Functions of MQTT
• 1. Publish-Subscribe Messaging Model
• Instead of direct communication between devices, MQTT uses a broker-
based architecture where:
• Publishers send messages to a central broker.
• Subscribers receive messages from the broker when they are subscribed to a specific
topic.
• This decouples the sender and receiver, making MQTT scalable and
efficient.
• 2. Efficient Data Transmission
• MQTT transmits small message payloads, reducing bandwidth usage.
• Works well in low-power and constrained environments, such as sensor
networks and mobile applications.
Main Functions of MQTT
• 3. Quality of Service (QoS) Levels
• Quality of Service (QoS) in networking and communication protocols refers to the level of reliability and
guarantee provided for message delivery.
• In MQTT (Message Queuing Telemetry Transport), there are three QoS levels, each defining how messages
are delivered between the sender (publisher) and receiver (subscriber)
• MQTT supports three QoS levels to ensure message delivery reliability:
Example: How QoS Levels Affect the
application design:
1.QoS 0 (At most once) – Used for non-critical sensor data
1. The ESP32 sends temperature readings every 10 seconds to the MQTT broker.
2. If a message is lost due to network issues, the system does not resend it.
3. This is acceptable because a new reading will be sent soon.
2.QoS 1 (At least once) – Used for logging temperature data
1. The Raspberry Pi logs temperature data to a database.
2. The message is retransmitted if an acknowledgment (ACK) is not received.
3. If a duplicate is received, it can be handled by checking timestamps.
3.QoS 2 (Exactly once) – Used for controlling the Smart AC
1. When the temperature exceeds 30°C, the Raspberry Pi sends a command to the smart AC unit
to turn on.
2. The AC must receive this command exactly once, as duplicate messages could cause
unnecessary toggling.
3. QoS 2 ensures the command is delivered reliably without duplication.
Main Functions of MQTT
• 4. Persistent Session Support
• Retains messages for disconnected clients and delivers them once
they reconnect.
• Useful for IoT devices that may experience intermittent connectivity.
• 5. Security & Authentication
• Supports TLS/SSL encryption for secure communication.
• Uses username-password authentication and Access Control Lists
(ACLs) to manage client permissions.
Components of MQTT Sender & Receiver in IoT
• In an MQTT communication system, the Sender (Publisher) and
Receiver (Subscriber) are usually IoT devices, microcontrollers, or
servers that exchange messages through an MQTT broker.
•The Sender (Publisher) is any device that sends data (sensors,
apps, cloud platforms).
•The Receiver (Subscriber) is any device that listens and reacts
(microcontrollers, actuators, cloud).
•Both communicate via an MQTT broker, making the system
scalable and efficient for IoT.
1. Physical Components of an MQTT Sender
(Publisher)
• The Sender (Publisher) is the device that collects data and sends
messages to the MQTT broker. It could be:
• Sensors & Microcontrollers
• ESP32/ESP8266 – Used in IoT applications to send sensor data.
• Arduino + Wi-Fi Module – Sends data to an MQTT broker.
• Raspberry Pi – Runs Python scripts to publish messages.
• Industrial Machines
• PLCs (Programmable Logic Controllers) in factories send data on temperature,
pressure, or machine status.
• Mobile Apps & Web Applications
• A smartphone app (e.g., a smart home app) sends commands like “Turn on the
light”.
• A web dashboard sends MQTT messages to control devices remotely.
2. Physical Components of an MQTT Receiver
(Subscriber)
• The Receiver (Subscriber) is the device that listens for messages from the MQTT
broker. It could be:
• Microcontrollers & IoT Devices
• ESP32/ESP8266 with a relay – Turns on/off appliances when receiving MQTT commands.
• Arduino with an OLED display – Displays sensor values received via MQTT.
• Raspberry Pi – Logs data from the MQTT broker.
• Actuators & Smart Devices
• Smart Bulbs, Fans, or Thermostats – Receive MQTT messages to change state.
• Motors, Servo Controls – Used in robotics, home automation, or industrial applications.
• Cloud Platforms & Web Apps
• AWS IoT Core, Azure IoT Hub, Google Cloud IoT – Receive and process MQTT messages.
• Web dashboards & mobile apps – Display received data in real-time.
How an MQTT Broker Connects to a Cloud Server
• An MQTT broker is responsible for routing messages between MQTT
clients (publishers and subscribers). When deploying an MQTT broker
in a cloud environment, it enables remote access, scalability, and
global communication for IoT devices.
1. Architecture of an MQTT Broker in the Cloud
• IoT Devices (Publishers & Subscribers) → Send and receive MQTT messages.
MQTT Broker (Cloud-based or On-Premises) → Routes messages between
devices.
Cloud Server (AWS, Azure, Google Cloud, etc.) → Stores, analyzes, and
processes data.
• Scenario:
• Sender (Publisher): ESP32 with a DHT11 Sensor sends temperature
data via MQTT.
• MQTT Broker: Mosquitto Broker running on a cloud server.
• Receiver (Subscriber): Raspberry Pi listens for MQTT messages and
logs temperature.
• Actuator: Smart AC unit turns on/off when a temperature threshold
is met.
Components:
Example Setup: MQTT-Based Home Automation
Actuator: Smart
AC unit
Difference Between ESP32 and Raspberry Pi
ESP32 and Raspberry Pi are both popular platforms for IoT and embedded systems, but they serve different purposes
Feature ESP32 Raspberry Pi
Type Microcontroller (MCU) Single-Board Computer (SBC)
Processor Dual-core Xtensa 32-bit LX6 ARM-based CPU (Quad-core in most models)
Operating System No OS (runs on bare-metal or RTOS) Runs full OS (Linux, Raspberry Pi OS)
Connectivity Built-in Wi-Fi, Bluetooth, LoRa (some models) Wi-Fi, Ethernet, USB, HDMI
Power Consumption Very Low (Deep Sleep mode ~10µA) Higher (Typically 5V, 2.5A)