Header Ads

IoT (Internet of Things): How it Works, Components, and Monitoring Project Implementation

 CHAPTER 1: What is IoT? Concepts and Benefits

1.1 Definition of the Internet of Things (IoT)

The Internet of Things (IoT) is a concept where various physical devices are interconnected via the internet to collect and exchange data. These devices can include sensors, actuators, vehicles, household appliances, and even industrial equipment. IoT allows physical objects to “talk” to each other and provide information in real time without direct human involvement.

1.2 A Brief History of IoT

The term “Internet of Things” was first introduced by Kevin Ashton in 1999. However, the idea of internet-connected devices has been around since the early 1980s. One of the first examples was a vending machine at Carnegie Mellon University, which could report the contents and temperature of drinks online.

1.3 Key Components of IoT

  1. Connectivity Devices – Sensors and actuators that collect data from the physical environment.
  2. Networks – Communication between devices, typically using protocols such as WiFi, Bluetooth, ZigBee, LoRa, or LTE.
  3. IoT Platforms – Where data is collected, analyzed, and controlled.
  4. User Applications – The interfaces users use to monitor and control systems.

1.4 Benefits of IoT

IoT has wide-ranging benefits across various sectors:

  1. Industry: Improved operational efficiency through real-time monitoring.
  2. Agriculture: Automatic monitoring of soil, temperature, and humidity.
  3. Healthcare: Remote patient monitoring.
  4. Smart Homes: Automated lighting, air conditioning, cameras, and security systems.
  5. Transportation: Intelligent navigation systems and traffic management.

1.5 Challenges in IoT Implementation

  1. Data Security: IoT devices are vulnerable to cyberattacks.
  2. Privacy: Personal information can be captured unknowingly.
  3. Scalability: Scaling up the number of devices efficiently can be challenging.
  4. Compatibility: Differences in standards and protocols between devices.

CHAPTER 2: Popular IoT Platforms: MQTT, Node-RED, and ThingsBoard

2.1 MQTT (Message Queuing Telemetry Transport)

2.1.1 What Is MQTT?

MQTT is a lightweight, publish-subscribe communication protocol designed for resource-constrained devices and unstable networks. MQTT works with three main components: Publisher, Broker, and Subscriber.

2.1.2 MQTT Advantages:
  1. Lightweight and efficient.
  2. Ideal for low-bandwidth networks.
  3. TCP/IP-based protocol.
  4. Quality of Service (QoS) support.
2.1.3 Use Case:

A temperature sensor sends data to an MQTT broker, and a dashboard reads the data for real-time display.

2.2 Node-RED

2.2.1 What is Node-RED?

Node-RED is a flow-based programming tool built on Node.js. It is used to connect hardware, APIs, and online services with a visual interface.

2.2.2 Key Features:
  1. Drag-and-drop interface.
  2. Integration with MQTT, HTTP, WebSocket, and more.
  3. Real-time data flow visualization.

2.2.3 Advantages:
  1. Very flexible and easy to use.
  2. Can be run on a Raspberry Pi, PC, or the cloud.
  3. Active community and extensive documentation.
2.3 ThingsBoard

2.3.1 What is ThingsBoard?

ThingsBoard is an open-source IoT platform for device management, data collection, processing, and visualization. It supports popular protocols such as MQTT, CoAP, and HTTP.

2.3.2 ThingsBoard Features:

  1. Interactive dashboard.
  2. Rule engine for automation.
  3. Historical data storage.
  4. Multi-tenant and scalable.

2.3.3 ThingsBoard Advantages:

  1. Suitable for large-scale industrial solutions.
  2. Can be deployed on-premises or in the cloud.
  3. Security support such as authentication and encryption.

CHAPTER 3: Sensors and Actuators in IoT

3.1 Sensors: Data Collectors

Sensors are devices that detect and measure changes in the physical environment and then convert these changes into signals that can be processed by IoT systems.

3.2 Actuators: Executing Actions

An actuator is a device that receives commands from the system and performs a physical action, such as turning on a motor or opening a valve.

Examples of Actuators:
  1. Servo Motor: Used to open automatic doors.
  2. Relay: Controls high-voltage electrical devices.
  3. Water Pump: Turned on by a soil moisture sensor.
  4. LED: Turned on when certain conditions are met.

3.3 The Role of Sensors and Actuators in IoT Systems
  1. Sensors observe the environment.
  2. Data is sent via protocols such as MQTT.
  3. The platform processes the data using a rule engine.
  4. Actuators perform actions based on the analysis.
Example: A sensor detects a temperature above 30°C, and the platform sends a command to the relay to turn on the fan.

CHAPTER 4: IoT Project: Remote Temperature and Humidity Monitoring

4.1 Project Description

This project aims to build a remote temperature and humidity monitoring system using DHT11/DHT22 sensors, ESP8266, MQTT, and a ThingsBoard dashboard. Data will be sent periodically, displayed graphically, and stored for further analysis.


4.3 Circuit Schematic
  • VCC DHT11 to 3V ESP8266
  • GND DHT11 to GND ESP8266
  • Data DHT11 to D4 (GPIO2) ESP8266

4.4 System Flow
  • The sensors read temperature and humidity.
  • Data is sent to ThingsBoard via MQTT.
  • The dashboard displays the data in graphs.
  • Data is stored for historical analysis.

The rule engine manages notifications if extreme values are detected.

4.5 Program Code (Example – Arduino IDE)

#include <ESP8266WiFi.h>
#include <DHT.h>
#include <PubSubClient.h>

#define DHTPIN D4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "NamaWiFi";
const char* password = "PasswordWiFi";
const char* mqttServer = "broker.thingsboard.io";
const int mqttPort = 1883;
const char* token = "YOUR_DEVICE_TOKEN";

WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
  Serial.begin(115200);
  dht.begin();
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  client.setServer(mqttServer, mqttPort);
  while (!client.connected()) {
    if (client.connect("ESP8266", token, NULL)) {
      Serial.println("Connected to ThingsBoard");
    } else {
      delay(2000);
    }
  }
}

void loop() {
  float suhu = dht.readTemperature();
  float kelembapan = dht.readHumidity();

  String payload = "{\"temperature\":" + String(suhu) + ",\"humidity\":" + String(kelembapan) + "}";
  client.publish("v1/devices/me/telemetry", (char*) payload.c_str());

  delay(5000);
}

4.6 ThingsBoard Dashboard

  • Create a new device in ThingsBoard.
  • Use an authentication token in the code.
  • Create a dashboard with temperature and humidity widgets.
  • Add a notification rule if the temperature is above 35°C.

4.7 Advanced Development
  • Add email/Telegram notifications.
  • Automatically activate a fan with a relay.
  • Logging data to a Google Sheet or database.

CHAPTER 5: Security and Privacy in IoT

5.1 The Importance of Security in IoT

Because IoT connects millions of devices and processes vast amounts of data, security is crucial. Unsecured systems can be infiltrated by hackers, endangering user privacy and system stability.

5.2 Common Threats in IoT

Distributed Denial of Service (DDoS) Attacks
Thousands of IoT devices can be used as "bots" to attack a specific server, making the service inaccessible.

Man-in-the-Middle Attack (MitM)
Hackers can intercept communications between devices and servers if they are not encrypted.

Unauthorized Access
Unsecured devices can be accessed and controlled by third parties from outside.

Data Leakage
Sensitive information such as user location or health data can be leaked if not protected.

5.4 User Privacy

Users are often unaware that their data is being passively collected by IoT devices. Therefore, it is necessary to:
  • Transparency: Disclosure of the types of data collected.
  • User Consent: Request explicit permission before accessing personal data.
  • Data Deletion: Provide users with the option to delete their data from the system.

CHAPTER 6: Case Study – Real-World IoT Implementation

6.1 Smart Farming: Automated Irrigation System

Background

Farmers often struggle to manage crop watering times and needs. An IoT-based automated irrigation system helps water crops only when needed, based on soil moisture sensor data.

Components:
  • Soil moisture sensor
  • NodeMCU ESP8266
  • Relay and water pump
  • Node-RED and MQTT Platform

Workflow:
  • The sensor reads soil moisture.
  • If it's <30%, the NodeMCU sends data to the MQTT broker.
  • A Node-RED rule activates the relay.
  • The pump waters the crops for 5 minutes.
  • The system stops automatically when the soil becomes moist again.

Benefits:
  • Water savings
  • Increased productivity
  • Can be controlled from a smartphone
6.2 Smart City: Air Quality Monitoring

City governments can use IoT to monitor air pollution in real time across various city areas.

Components:
  • Gas sensor (MQ135)
  • ESP32
  • ThingsBoard Dashboard

Functions:
  • Provides a live air quality map
  • Provides alerts if pollution levels exceed thresholds
  • Makes data-driven decisions

6.3 Health: Remote Patient Monitoring

IoT allows elderly patients or those with chronic diseases to be monitored from home.

Devices:
  • Heart rate and oxygen sensor (MAX30100)
  • ESP8266
  • Mobile app for family or doctors

Advantages:
  • Reduces hospital visits
  • Quick response if vital signs are abnormal
  • Historically recorded health data

No comments

Powered by Blogger.