Unit 2: Hardware and software components
IoT and Its Applications notes · PTU syllabus (PGCA1943)
On this page
Unit summary
IoT devices combine computing boards, sensors and communication modules programmed through APIs. This unit covers Arduino and Raspberry Pi, communication and I/O interfaces, programming with Python, Node.js and Arduino, and protocols — MQTT, ZigBee, Bluetooth, CoAP, UDP and TCP.
After this unit you can
- Compare Arduino and Raspberry Pi
- Explain I/O interfaces — GPIO, ADC, PWM, UART, I2C, SPI
- Program devices in Arduino C and Python
- Compare IoT communication protocols
PTU syllabus topics
- Computing platforms (Arduino, Raspberry Pi)
- communication
- sensing and actuation
- I/O interfaces
- programming APIs using Python/Node.js/Arduino
- communication protocols — MQTT
- ZigBee
- Bluetooth
- CoAP
- UDP
- TCP
MQTT
Publish-subscribe over TCP
Lightweight telemetry
CoAP
Request-response over UDP
Constrained devices
ZigBee
Low-power mesh radio
Home and industrial sensors
Bluetooth LE
Short-range, low power
Wearables, phones
Topic 1
Computing platforms
Type
Microcontroller (ATmega328P)
Single-board computer (ARM Cortex-A72)
OS
None — runs one sketch
Linux (Raspberry Pi OS)
Clock and memory
16 MHz, 2 KB RAM
1.5 GHz, 2–8 GB RAM
Analog input
Yes (6 ADC pins)
No (needs external ADC)
Best for
Real-time sensing and control, low power
Networking, cameras, databases, gateways
- ESP8266 and ESP32 add built-in Wi-Fi (ESP32 also Bluetooth) at low cost.
Topic 2
I/O interfaces
- GPIO
- Digital input and output pins
- ADC
- Reads analog voltages
- PWM
- Simulated analog output — LED dimming, motor speed
- UART
- Serial, two wires (TX, RX)
- I2C
- Two-wire bus (SDA, SCL) with addresses — OLEDs, sensors
- SPI
- Fast four-wire bus — SD cards, displays
Topic 3
Programming APIs
cpp// Arduino: read DHT11 and blink LED if hot
#include <DHT.h>
DHT dht(2, DHT11);
void setup() { Serial.begin(9600); dht.begin(); pinMode(13, OUTPUT); }
void loop() {
float t = dht.readTemperature();
Serial.println(t);
digitalWrite(13, t > 30 ? HIGH : LOW);
delay(2000);
}python# Raspberry Pi: LED on GPIO 17 with gpiozero
from gpiozero import LED, Button
from signal import pause
led, btn = LED(17), Button(2)
btn.when_pressed = led.toggle
pause()- Node.js (Johnny-Five, Node-RED) builds event-driven IoT apps and flows.
Topic 4
Communication protocols
Model
Publish–subscribe via a broker
Request–response like REST
Transport
TCP
UDP
Features
Topics, QoS 0/1/2, retained messages, last will
GET, PUT, POST, DELETE; observe; very light
Use
Telemetry to cloud
Constrained devices and networks
pythonimport paho.mqtt.publish as publish
publish.single("sbs/lab/temp", "28.5", hostname="test.mosquitto.org")Bluetooth and BLE
About 10–100 m; low power (BLE)
Wearables, phones
ZigBee (IEEE 802.15.4)
10–100 m; 250 kbps; mesh
Home and building automation
Wi-Fi
About 50 m; high rate
Cameras, home devices
LoRaWAN
Several km; very low rate
Agriculture, smart meters
NB-IoT and LTE-M
Cellular wide area
Utility meters, trackers
Connection
Connection-oriented, reliable, ordered
Connectionless, no guarantees
Overhead
Higher
Lower
IoT use
MQTT, HTTP
CoAP, DNS, streaming
Key terms
- Microcontroller
- Single chip with CPU, memory and I/O
- PWM
- Pulse-width modulation
- I2C
- Two-wire serial bus
- MQTT
- Lightweight publish–subscribe protocol
- CoAP
- Constrained Application Protocol over UDP
Quick revision
- Arduino vs Raspberry Pi; ESP32.
- GPIO, ADC, PWM, UART, I2C, SPI.
- Arduino C, Python gpiozero, Node.js.
- MQTT vs CoAP; Bluetooth, ZigBee, Wi-Fi, LoRaWAN, NB-IoT; TCP vs UDP.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Distinguish Arduino and Raspberry Pi.
- Q2.What is PWM used for?
- Q3.What is I2C?
- Q4.Explain MQTT QoS levels.
- Q5.Why is CoAP suited to constrained devices?
- Q6.Distinguish TCP and UDP.
Long-answer questions
- Q1.Compare Arduino and Raspberry Pi as IoT platforms.
- Q2.Explain I/O interfaces and programming of IoT devices.
- Q3.Compare IoT communication protocols.
Stuck on this unit?
Message SBS on WhatsApp for help with IoT and Its Applications, or to ask about studying M.Sc IT at Synetic.
