Upon completion of this extended tutorial, students will be able to:
Wireless Sensor Networks (WSNs) and the Internet of Things (IoT) represent a paradigm shift in how we interact with the physical world. WSNs consist of hundreds or thousands of low‑cost, low‑power sensor nodes that cooperatively monitor environmental conditions, while IoT extends this concept to a vast ecosystem of interconnected devices, from consumer wearables to industrial automation systems. This tutorial provides a comprehensive exploration of the architecture, protocols, and technologies that underpin WSNs and IoT. We cover the fundamental components of a sensor node, the communication models (D2D, Device-to-Cloud, Device-to-Gateway), and the low‑power wireless technologies (ZigBee, BLE, LoRa, NB-IoT, Sigfox) that enable long‑range and low‑energy communication. We delve into energy‑efficient MAC and routing protocols, energy harvesting techniques, and the emerging paradigms of edge and fog computing. We also address the critical security and privacy challenges. Through detailed examples, case studies, and a rich set of assessment questions, this tutorial equips students with the knowledge to design and deploy WSN/IoT solutions across diverse domains.
A Wireless Sensor Network (WSN) is a network of spatially distributed autonomous sensors that monitor physical or environmental conditions (temperature, sound, pressure, motion, etc.) and cooperatively pass data through the network to a sink (base station).
The Internet of Things (IoT) is a broader concept where physical objects ("things") are embedded with electronics, software, sensors, and network connectivity, enabling them to collect and exchange data. IoT encompasses WSNs but also includes actuators, smart devices, and cloud services.
Key characteristics of WSNs:
A typical sensor node (mote) consists of four main components:
| Component | Description | Examples |
|---|---|---|
| Sensor(s) | Measure physical phenomena | Thermistor, accelerometer, microphone, GPS |
| Processor | Computing and control | ARM Cortex‑M, ESP32, Atmel AVR, MSP430 |
| Radio | Wireless communication | IEEE 802.15.4, BLE, LoRa transceiver |
| Power Supply | Energy source | Battery, energy harvesting (solar, vibration) |
Network architecture: typically a cluster‑tree or mesh topology, with a gateway (sink) that connects to the Internet.
The IoT architecture defines several communication models (IoT-A reference model):
| Technology | Frequency | Range | Data Rate | Power | Applications |
|---|---|---|---|---|---|
| ZigBee (IEEE 802.15.4) | 2.4 GHz, 868/915 MHz | 10‑100 m | 250 kbps | Very low | Home automation, industrial |
| Bluetooth Low Energy (BLE) | 2.4 GHz | 10‑100 m | 1‑2 Mbps | Very low | Wearables, beacons, healthcare |
| Wi‑Fi (802.11ah – HaLow) | 900 MHz | 1 km | 0.15‑78 Mbps | Low | IoT with high throughput |
| LoRa | 868/915 MHz | 2‑15 km | 0.3‑50 kbps | Very low | Smart cities, agriculture, tracking |
| NB‑IoT | Licensed (LTE) | 10‑15 km | ~250 kbps | Low | Smart meters, industrial IoT |
| Sigfox | 868/915 MHz | 10‑50 km | 100 bps | Ultra‑low | Simple sensors (GPS tracking) |
ZigBee uses a mesh topology and is widely used in home automation (ZigBee Home Automation). BLE is designed for low‑energy peripheral devices, supporting advertising and connection modes. LoRa (Long Range) uses chirp spread spectrum (CSS) for long‑range, low‑data‑rate communication, ideal for rural and urban outdoor deployments. NB‑IoT (Narrowband IoT) is a cellular‑based technology for massive IoT (mMTC) in 5G, offering deep indoor coverage and low power.
MAC protocols for WSNs must be energy‑efficient, scalable, and adaptive. Key protocols:
Routing protocols for WSNs must be energy‑aware and scalable. Categories:
Energy is the most critical constraint in WSNs. Techniques to extend lifetime:
Edge computing brings computation and data storage closer to the devices, reducing latency and bandwidth consumption. Fog computing extends cloud services to the edge, providing a hierarchical architecture. Benefits:
Examples: AWS IoT Greengrass, Microsoft Azure IoT Edge, Cisco IOx.
IoT devices are vulnerable due to limited resources and lack of standardised security. Key challenges:
Mitigations:
A farm deploys LoRa‑based sensor nodes to monitor soil moisture, temperature, and humidity. The gateways send data to the cloud, where analytics provide irrigation recommendations. Solar panels power the nodes.
Using ZigBee, the home has smart bulbs, plugs, and sensors. A hub (gateway) connects to the Internet, allowing remote control via a smartphone app. BLE is used for wearables (e.g., fitness trackers).
A factory deploys NB‑IoT sensors for vibration analysis on motors. Edge computing (at the gateway) performs FFT analysis to detect anomalies before the data is sent to the cloud, reducing bandwidth and latency.
Test your understanding of WSN and IoT concepts.
Q1. What are the four main components of a wireless sensor node (mote)?
Sensor(s), processor, radio transceiver, and power supply (battery or energy harvester).
Q2. What is the key difference between a WSN and the broader IoT?
WSN focuses on sensing and monitoring with low‑power, resource‑constrained nodes. IoT encompasses a wider ecosystem including actuators, smart devices, cloud services, and diverse communication models.
Q3. Name the four IoT communication models defined in the IoT-A reference model.
Device-to-Device (D2D), Device-to-Cloud, Device-to-Gateway, and Back‑end Data Sharing.
Q4. Which low‑power wireless technology uses chirp spread spectrum (CSS) for long‑range communication?
LoRa (Long Range).
Q5. What is the typical data rate of ZigBee (IEEE 802.15.4) at 2.4 GHz?
250 kbps.
Q6. What is the advantage of NB‑IoT over LoRa for massive IoT deployments?
NB‑IoT uses licensed cellular spectrum and provides better reliability, deeper indoor coverage, lower latency, and integration with existing LTE/5G infrastructure, but requires subscription.
Q7. What is the purpose of duty cycling in WSN MAC protocols?
To reduce energy consumption by putting the radio to sleep for most of the time, waking periodically to listen for transmissions.
Q8. How does the S‑MAC protocol achieve energy efficiency?
By using a periodic listen/sleep schedule (duty cycling) where nodes synchronise to a common schedule and turn off their radios during sleep periods.
Q9. What is the main idea behind the LEACH routing protocol for WSNs?
LEACH forms clusters with a cluster head (CH) that aggregates data from cluster members and transmits to the base station. The CH role rotates among nodes to balance energy consumption.
Q10. What is RPL and what is its role in IoT?
RPL (Routing Protocol for Low‑Power and Lossy Networks) is an IETF standard routing protocol for IPv6‑based IoT networks (6LoWPAN). It builds a Destination‑Oriented DAG (DODAG) for efficient routing.
Q11. What is energy harvesting, and give three examples of energy sources.
Energy harvesting captures ambient energy to power devices. Sources: solar (photovoltaic), thermal (thermoelectric), vibrational (piezoelectric), and RF energy.
Q12. What is the difference between edge computing and fog computing?
Edge computing brings computation close to the devices (at the edge of the network). Fog computing extends this with a hierarchical architecture that includes gateways and intermediate nodes, providing more processing and storage layers between edge and cloud.
Q13. What is the purpose of data aggregation in WSNs?
To reduce the amount of data transmitted by combining data from multiple nodes, saving energy and bandwidth.
Q14. What is the role of a gateway in an IoT architecture?
A gateway acts as a bridge between local devices (e.g., ZigBee, BLE) and the Internet (Wi‑Fi, Ethernet, cellular), performing protocol translation, data aggregation, and sometimes edge processing.
Q15. Which encryption protocol is commonly used for securing IoT communications?
DTLS (Datagram Transport Layer Security) for UDP‑based IoT protocols, and TLS for TCP‑based communication. Lightweight cryptography (AES‑CCM) is also used.
Q16. What was the Mirai botnet attack and what did it exploit?
Mirai was a malware that infected IoT devices (cameras, DVRs) with default credentials, using them as a botnet to launch large‑scale DDoS attacks. It highlighted the security weaknesses of IoT devices.
Q17. What is the purpose of a secure element (e.g., TPM, eSIM) in IoT devices?
A secure element provides hardware‑based security for storing cryptographic keys and performing secure operations (e.g., authentication, encryption), protecting against physical and software attacks.
Q18. What is the difference between a star topology and a mesh topology in WSNs?
Star topology: nodes communicate directly with a central coordinator (gateway). Simple but limited range. Mesh topology: nodes can relay packets for each other, providing multi‑hop communication and better coverage and resilience.
Q19. What is the approximate range of a LoRa network in rural areas?
2‑15 km (up to 50 km in ideal line‑of‑sight conditions).
Q20. What is 6LoWPAN and why is it important for IoT?
6LoWPAN (IPv6 over Low‑Power Wireless Personal Area Networks) allows IPv6 packets to be transmitted over IEEE 802.15.4 networks by using header compression and fragmentation, enabling IP connectivity for sensor nodes.
Q21. What is the role of adaptive sampling in energy management for WSNs?
Adaptive sampling adjusts the sensing rate based on the variability of the measured data. When the environment is stable, the sampling rate is reduced to save energy.
Q22. Compare BLE and ZigBee in terms of use cases.
BLE is typically used for wearables, health monitors, and beacons (short‑range, low‑latency). ZigBee is used for home automation, industrial control, and mesh networks (more devices, lower data rate).
Q23. What is the concept of "digital twin" in IoT?
A digital twin is a virtual representation of a physical object or system that is updated with real‑time data from sensors. It is used for simulation, analysis, and predictive maintenance.
Q24. What are the main security challenges in IoT devices due to limited resources?
Limited memory, CPU, and battery power make it difficult to implement strong encryption, secure boot, or regular firmware updates, leading to vulnerabilities.
Q25. What is the role of the CoAP protocol in IoT?
CoAP (Constrained Application Protocol) is a lightweight RESTful protocol for IoT devices, replacing HTTP for resource‑constrained environments. It runs over UDP and supports multicast, low overhead, and simple request/response interactions.
Apply your knowledge to WSN and IoT scenarios.
Exercise 1: A farmer wants to monitor soil moisture across a 10 km² field. The field has no cellular coverage. Propose a WSN/IoT solution, including technology choice (LoRa, ZigBee, etc.), topology, power source, and data transmission strategy.
Use LoRa for long‑range, low‑power communication. Deploy 20‑30 sensor nodes with soil moisture sensors, placed in a grid. Each node is solar‑powered with a battery backup. A LoRa gateway is placed on a high point (e.g., a building or pole) to receive data. Nodes send data every hour (or on demand). The gateway transmits data via satellite or fixed Ethernet (if available) to the cloud for analytics.
Exercise 2: Compare the energy consumption of a node using S‑MAC (duty cycle 10%) vs. using a simple CSMA/CA with no duty cycle. Assume the radio consumes 20 mA in receive, 30 mA in transmit, and 10 µA in sleep. Estimate the average current draw.
Assume 1% transmit, 9% receive, 90% sleep for S‑MAC: I = 0.01×30 + 0.09×20 + 0.9×0.01 = 0.3 + 1.8 + 0.009 = 2.109 mA. Without duty cycling: 100% receive (if always listening) = 20 mA. S‑MAC saves ~90% energy.
Exercise 3: A smart home uses ZigBee for lights and sensors. The hub (gateway) connects to the Internet via Wi‑Fi. Draw a diagram showing the communication path from a light switch (ZigBee) to a smartphone app (cloud).
ZigBee light switch → ZigBee Gateway (hub) → Wi‑Fi router → Internet → Cloud server (back‑end) → Wi‑Fi router → Smartphone app. The gateway performs protocol translation (ZigBee to IP).
Exercise 4: Explain how LEACH rotates the cluster head role to balance energy consumption. What are the phases of LEACH operation?
LEACH operates in rounds. Each round has a setup phase (cluster formation and CH selection based on a random threshold) and a steady‑state phase (data transmission). The threshold is T(n) = p/(1 - p*(r mod 1/p)) where p is the desired percentage of CH nodes. Nodes that have been CH recently have a lower probability, ensuring rotation.
Exercise 5: A factory uses NB‑IoT sensors for vibration monitoring. The sensors send 100 bytes of data every minute. The NB‑IoT module consumes 100 mA during transmission and 5 µA in sleep. Calculate the battery life for a 1000 mAh battery, assuming 10 ms transmission time per minute.
Transmission duty cycle = 10 ms / 60 s = 0.000167. Average current = 0.000167 × 100 mA + (1 - 0.000167) × 0.005 mA ≈ 0.0167 + 0.005 = 0.0217 mA. Battery life = 1000 mAh / 0.0217 mA ≈ 46,000 hours ≈ 5.25 years.
Exercise 6: What are the advantages of using edge computing for video surveillance analytics in a smart city?
Edge computing processes video frames locally (at the camera or gateway), reducing the amount of data sent to the cloud, lowering bandwidth costs and latency. It enables real‑time detection of events (e.g., traffic violations, accidents) and can operate with intermittent cloud connectivity.
Exercise 7: In a WSN, nodes are deployed in a large area with no fixed infrastructure. Which routing protocol (LEACH, GPSR, or RPL) would be most suitable and why?
RPL is suitable for large, low‑power networks where IPv6 connectivity is needed and nodes have some processing capability. LEACH is good for homogeneous networks with a single sink. GPSR works well if nodes have GPS (location awareness). For a large area with many nodes, RPL provides flexibility and supports scalable IPv6 routing.
Exercise 8: What is the role of CoAP in IoT, and how does it differ from MQTT?
CoAP is a request/response protocol for constrained devices, similar to HTTP but over UDP. MQTT is a publish/subscribe protocol that uses a broker. CoAP is lightweight and supports multicast; MQTT is more suitable for many‑to‑one data collection with QoS levels.
Exercise 9: A hospital deploys BLE beacons for indoor navigation. How does BLE advertising work, and what information is typically sent in an advertisement packet?
BLE beacons broadcast advertising packets periodically (e.g., every 100 ms). The packet contains the beacon's UUID, major/minor numbers, and measured transmit power (for ranging). The smartphone scans and uses the signal strength to estimate distance for navigation.
Exercise 10: Explain the concept of "secure boot" in IoT devices and why it is important.
Secure boot ensures that the device only loads authenticated firmware. It uses cryptographic signatures to verify the bootloader and OS before execution. This prevents attackers from loading malicious firmware, providing a root of trust for the device.
Exercise 11: A water utility company wants to monitor water pressure in pipes across a city. The pipes are underground. Which wireless technology (LoRa, NB‑IoT, ZigBee) would be most suitable and why?
NB‑IoT is most suitable because it offers deep indoor/sub‑surface penetration (due to lower frequency and higher power), works on licensed cellular bands with good reliability, and supports battery‑powered devices. LoRa could also work but may be less reliable in dense urban environments with underground pipes.
Exercise 12: A smart city deploys a network of air quality sensors. The network uses a mesh topology. What happens if one sensor node fails? How does the network maintain connectivity?
In a mesh network, if one node fails, the network can dynamically reroute packets through other nodes. The routing protocol (e.g., RPL) detects the failure via link‑layer notifications or lack of acknowledgments and finds an alternative path. This provides fault tolerance and resilience.
Independent research and advanced analysis.
HW1. Derive the energy consumption model for a sensor node in a WSN, including sensing, processing, and transmission. How does the transmission distance affect energy consumption? Use the Friis transmission equation.
Energy consumption per round = E_sense + E_process + E_tx(d). E_tx ∝ d^n (n is path loss exponent). Using Friis, transmit power ∝ d² (free‑space) or d⁴ (two‑ray). Thus, increasing distance significantly increases energy consumption, making multi‑hop communication more energy‑efficient than direct transmission.
HW2. Research the IEEE 802.15.4 standard. What are its main features, and how does it differ from IEEE 802.11? What is the role of the MAC superframe structure with beacon‑enabled mode?
802.15.4 is designed for low‑rate, low‑power, low‑cost WPANs. It supports star and peer‑to‑peer topologies. Beacon‑enabled mode uses a superframe structure with active and inactive periods. The coordinator sends beacons for synchronisation, and nodes use CSMA/CA during the active period.
HW3. Compare the MAC layer protocols: S‑MAC, T‑MAC, and X‑MAC. Analyse their energy efficiency, latency, and throughput for different traffic loads.
S‑MAC uses fixed duty cycle, good for periodic traffic but wastes energy in low load. T‑MAC adapts the active time based on traffic, better for variable load. X‑MAC uses low‑power listening with short preambles, good for low‑duty‑cycle networks. Each has trade‑offs; the choice depends on application requirements.
HW4. Explain the concept of "data fusion" in WSNs. How does it differ from data aggregation, and what are its benefits?
Data fusion combines data from multiple sensors to produce a more accurate or comprehensive result (e.g., Kalman filtering). Data aggregation is a simpler form that reduces data volume (e.g., averaging). Fusion improves accuracy and decision‑making but requires more processing.
HW5. Research the security features of the ZigBee protocol stack (MAC, NWK, APS, ZCL). What are the key encryption and authentication mechanisms?
ZigBee uses AES‑128 encryption at the MAC and NWK layers. Security services include: MAC layer encryption (for data frames), NWK layer encryption and integrity, and APS layer encryption for application data. Key management: trust centre distributes keys (network key, link key).
HW6. Analyse the role of MQTT and CoAP in IoT architectures. Compare them in terms of QoS, overhead, and typical use cases.
MQTT: publish/subscribe, broker‑based, supports 3 QoS levels (0‑2). Overhead: 2‑4 bytes header, TCP. Use cases: telemetry, sensor data. CoAP: request/response, UDP, similar to HTTP, supports confirmable/non‑confirmable messages. Overhead: 4 bytes header. Use cases: RESTful APIs for constrained devices.
HW7. Research the concept of "time‑slotted channel hopping" (TSCH) in IEEE 802.15.4e. How does it improve reliability and energy efficiency?
TSCH synchronises nodes to a schedule (timeslots) and uses channel hopping to avoid interference and fading. It provides deterministic communication, high reliability, and low power by allowing nodes to sleep between slots. Used in industrial IoT (e.g., WirelessHART).
HW8. Explain the concept of "digital twin" in industrial IoT. How is it implemented, and what are the benefits for predictive maintenance?
A digital twin is a virtual replica of physical assets, updated with real‑time sensor data. It uses simulation and machine learning to predict failures, optimise maintenance schedules, and improve asset performance. Benefits: reduced downtime, lower costs, and enhanced safety.
HW9. Analyse the challenges of using 5G for mMTC (massive IoT). How does 5G address these challenges compared to previous generations?
5G mMTC supports 1 million devices/km², low power, deep coverage, and low cost. Challenges: signalling congestion, battery life, and coverage. 5G uses NB‑IoT and LTE‑M integrated with 5GC, flexible numerology, and power‑saving features (eDRX, PSM).
HW10. Write a critical evaluation of the statement: "Edge computing will eventually replace cloud computing for IoT applications." Discuss the strengths and limitations of both.
Edge computing offers low latency, privacy, and bandwidth savings, but it has limited storage and processing power. Cloud computing provides scalability, analytics, and centralised management. A hybrid approach (fog/edge + cloud) is more realistic; edge pre‑processes data, and cloud handles long‑term storage and complex analytics.
HW11. Research the LoRaWAN protocol. What is the network architecture (end‑devices, gateways, network server, application server)? How does LoRaWAN handle security and device authentication?
LoRaWAN uses a star‑of‑stars topology: end‑devices (sensors) communicate with gateways (multiple) that forward to a network server. Security: AES‑128 encryption with a session key (AppSKey for application, NwkSKey for network). Authentication uses a device‑specific AppKey and join procedure (OTAA or ABP).
HW12. Design a complete IoT solution for a smart parking system in a city. Include: sensor type, wireless technology, gateway/cloud architecture, mobile app, and security considerations.
Sensors: ultrasonic or magnetic sensors in parking spaces. Technology: LoRa (for range) or NB‑IoT (for reliability). Architecture: sensors → LoRa gateways → network server → cloud (with database and analytics). Mobile app: shows real‑time availability, navigation. Security: DTLS for cloud communication, secure provisioning of sensors, and encrypted data storage.
This extended tutorial covered Wireless Sensor Networks and the Internet of Things, including:
Understanding WSN and IoT principles is essential for building the intelligent, connected systems that will shape the future. The next tutorial will delve into Mobile and Wireless Security.
© COMP347 – Unit 7: Wireless and Mobile Networks (Extended Tutorial 11)