IOT internet of things unit 4 notes PAAVAI ENGINEERING COLLEGE

stanlysebaten987 0 views 30 slides Oct 14, 2025
Slide 1
Slide 1 of 30
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30

About This Presentation

Iot notes


Slide Content

Paavai Institutions Department of CSE
UNIT - 4
CS20701
INTERNET OF THINGS
UNIT-III
lOT PHYSICAL DEVICES,
ENDPOINTS, PHYSICAL
SERVERS AND CLOUD
OFFERINGS
1

Paavai Institutions Department of CSE
UNIT - 4
CONTENTS
1.loT Device
2.Raspberry Pi
3.Raspberry Pi Interfaces
4.Programming Raspberry Pi with Python
5.Other loT Devices
6.Cloud Storage Models and Communication APis
7.WAMP
8.Xively Cloud for loT
9.Django
10.Amazon Web Services for loT
11.Sky Net loT Messaging Platform
2

Paavai Institutions Department of CSE
UNIT - 4
UNIT IV lOT PHYSICAL DEVICES, ENDPOINTS, PHYSICAL SERVERS AND CLOUD
OFFERINGS
loT Device - Raspberry Pi-Raspberry Pi Interfaces, Programming Raspberry Pi with Python, Other
loT Devices; Cloud Storage Models and Communication APis - WAMP, Xively Cloud for loT,
Django, Amazon Web Services for loT, Sky Net loT Messaging Platform.
-----------------------------------------------------------------------------------------------------------------------
4.1IOT DEVICE
A "Thing" in Internet of Things (IoT) can be any object that has a unique identifier and which
can send/receive data (including user data) over a network (e.g., smart phone, smart TV,
computer, refrigerator, car, etc. ).
IoT devices are connected to the Internet and send information about themselves or about
their surroundings (e.g. information sensed by the connected sensors) over a network (to other
devices or servers/storage) or allow actuation upon the physical entities/environment around them
remotely.
IOT DEVICE EXAMPLES
•A home automation device that allows remotely monitoring the status of appliances and
controlling the appliances.
•An industrial machine which sends information abouts its operation and health monitoring
data to a server.
•A car which sends information about its location to a cloud-based service.
•A wireless-enabled wearable device that measures data about a person such as the number
of steps walked and sends the data to a cloud-based service.
BASIC BUILDING BLOCKS OF AN IOT DEVICE
3

Paavai Institutions Department of CSE
UNIT - 4
Sensing
Sensors can be either on-board the IoT device or attached to the device.
Actuation
IoT devices can have various types of actuators attached that allow taking actions upon the
physical entities in the vicinity of the device.
Communication
Communication modules are responsible for sending collected data to other devices or cloud-
based servers/storage and receiving data from other devices and commands from remote
applications.
Analysis & Processing
Analysis and processing modules are responsible for making sense of the collected data.
4.2RASPBERRY PI
The Raspberry Pi is a small, affordable single-board computer developed by the Raspberry Pi
Foundation, primarily to promote education in computing and programming. Introduced in 2012, it
has since evolved into a versatile platform used by hobbyists, educators, and professionals for a
wide range of projects. Powered by a micro-USB connection and using a microSD card for storage,
it features GPIO pins for hardware interfacing, USB ports for peripherals, and HDMI for display
output. Available in various models (e.g., Raspberry Pi 3, 4), it runs on Linux-based operating
systems like Raspberry Pi OS and supports programming languages such as Python. Its compact
size, low cost, and expandability make it ideal for learning, prototyping, and creating innovative
applications like home automation, robotics, and media centers.Since Raspberry Pi runs Linux
operating system, it supports Python "out of the box".
4

Paavai Institutions Department of CSE
UNIT - 4
RCA Video: This is an output port that allows you to connect the Raspberry Pi to a TV or
monitor using a composite video cable, providing a basic video signal.
Audio Jack: A 3.5mm port used to connect headphones or speakers, enabling audio output
from the Raspberry Pi.
Status LEDs: Small indicator lights that provide visual feedback about the Raspberry Pi's
status, such as power, activity, or network connectivity.
GPIO Headers: General Purpose Input/Output pins that allow you to connect and control
external electronic components, making the Raspberry Pi suitable for DIY projects and
prototyping.
DSI Connector Display: A specialized port for connecting a Raspberry Pi display, offering
a direct interface for high-resolution screens designed specifically for the Pi.
SD Card Slot: Where the microSD card is inserted, serving as the primary storage for the
operating system, files, and software on the Raspberry Pi.
Micro USB Power: The power input port where a micro USB cable is connected to supply
power to the Raspberry Pi, typically requiring 5V.
USB 2.0: Ports for connecting peripherals like keyboards, mice, or external storage devices,
providing data transfer and additional functionality.
Ethernet: A port for a wired network connection, allowing the Raspberry Pi to connect to
the internet or a local network for data transfer and communication.
HDMI: A high-definition multimedia interface port used to connect the Raspberry Pi to a
monitor or TV, supporting high-quality audio and video output.
CSI Connector Camera: A port for connecting a Raspberry Pi Camera Module, enabling
the Pi to capture photos and videos.
Composite Video: Refers to the RCA Video output, providing an analog video signal to
older TVs or monitors
LINUX ON RASPBERRY PI
Raspbian
Raspbian Linux is a Debian Wheezy port optimized for Raspberry Pi
Arch
Arch is an Arch Linux port for AMD devices.
Pidora
Pidora Linux is a Fedora Linux optimized for Raspberry Pi.
RaspBMC
RaspBMC is an XBMC media-center distribution for Raspberry Pi.
OpenELEC
OpenELEC is a fast and user-friendly XBMC media-center distribution.
RISC OS
RISC OS is a very fast and compact operating system.
5

Paavai Institutions Department of CSE
UNIT - 4
Installation
Following are the steps for headless installation (without
connecting any peripherals) of Raspberry Pi OS:
(i) Download Raspberry Pi Imager software by clicking on download button
https.7Zwww.raspberrypi.org/software/.
(ii) After installing Raspberry Pi Imager, open it. The interface of Raspberry Pi .
(iii) Click on choose OS and select Raspberry Pi OS (32-bit) from the selection box .
(iv) Attach your micro SD card to computer and then click on Choose SD card button as shown
below and select the SD card.
(v) Now, click on Write button. Raspberry Pi Imager will download the official Raspberry Pi OS
online and then write it on to your SD card.
(vi) After the process of writing Raspberry Pi OS is over, open the SD card in explorer. Create a file
named wpajupplicantconf in the SD card root folder and insert the following text which include the
password into that file and save it.
4.3 RASPBERRY PI INTERFACES
Serial
The serial interface on Raspberry Pi has receive (Rx) and transmit (Tx) pins for
communication with serial peripherals.
SPI
Serial Peripheral Interface (SPI) is a synchronous serial data protocol used for communicating
with one or more peripheral devices.
I2C
The I2C interface pins on Raspberry Pi allow you to connect hardware modules. I2C interface
allows synchronous data transfer with just two pins - SDA (data line) and SCL (clock line).
Raspberry Pi GPIO
6

Paavai Institutions Department of CSE
UNIT - 4
1. GPIO (General Purpose Input/Output)
The GPIO pins are the most prominent interface on the Raspberry Pi. These pins provide an easy
way to control electronic components such as LEDs, switches, sensors, and motors.
Key Features of GPIO:
40-pin header (on models like Raspberry Pi 4, 3B+, etc.)
Can be configured as input or output
Voltage levels: 3.3V logic (do not connect 5V directly)
Includes PWM (Pulse Width Modulation) support for controlling motors and LEDs
Common GPIO Pin Usage:
Digital Input: Reading data from switches, buttons, or sensors
Digital Output: Controlling LEDs, buzzers, or relays
PWM Control: Adjusting brightness of LEDs or motor speed
Example GPIO Pin Configuration:
3.3V Power: Provides power for low-voltage sensors
5V Power: Provides power to higher voltage peripherals
GND (Ground): Ensures proper circuit grounding
I2C, SPI, UART: Integrated within GPIO for communication purposes
2. I2C (Inter-Integrated Circuit)
The I2C interface is a two-wire communication protocol commonly used for connecting multiple
sensors and low-speed devices.
Features of I2C:
Uses SDA (Data Line) and SCL (Clock Line)
Supports multiple devices using unique addresses
Ideal for connecting sensors, real-time clocks (RTC), and LCD displays
Example I2C Devices:
Temperature and humidity sensors (e.g., DHT22, BME280)
OLED and LCD displays
Real-time clocks (RTC modules)
Pin Connections:
SDA (Data): GPIO 2 (Pin 3)
SCL (Clock): GPIO 3 (Pin 5)
3. SPI (Serial Peripheral Interface)
The SPI interface is a synchronous serial communication protocol ideal for high-speed data transfer
between the Raspberry Pi and peripherals.
Features of SPI:
Uses separate lines for data in, data out, clock, and chip select
Suitable for fast communication with displays, sensors, and memory cards
Commonly used in TFT displays, RFID modules, and ADCs
SPI Pin Configuration:
MOSI (Master Out Slave In): GPIO 10 (Pin 19)
7

Paavai Institutions Department of CSE
UNIT - 4
MISO (Master In Slave Out): GPIO 9 (Pin 21)
SCLK (Clock): GPIO 11 (Pin 23)
CE0/CE1 (Chip Enable): GPIO 8 (Pin 24), GPIO 7 (Pin 26)
4. UART (Universal Asynchronous Receiver/Transmitter)
UART is a serial communication protocol used for communicating with devices such as GPS
modules, GSM modems, or serial consoles.
Features of UART:
Asynchronous communication protocol
Ideal for debugging and serial data exchange
Commonly used with USB-to-TTL converters for remote access
UART Pin Configuration:
TX (Transmit): GPIO 14 (Pin 8)
RX (Receive): GPIO 15 (Pin 10)
5. USB Interfaces
The Raspberry Pi includes multiple USB ports that support a variety of peripherals such as
keyboards, mice, cameras, and storage devices.
Features of USB Ports:
1.USB 3.0 ports for faster data transfer (Raspberry Pi 4)
2.Supports plug-and-play devices
3.Commonly used for Wi-Fi dongles, USB drives, and webcams
6. HDMI Interface
The Raspberry Pi offers HDMI ports for video and audio output. Newer models like the Raspberry
Pi 4 feature Micro HDMI ports, supporting 4K resolution at 60fps.
HDMI Port Usage:
Connecting  monitors, TVs, or projectors for display output
Supports CEC (Consumer Electronics Control) for remote device control
7. Ethernet Interface
Raspberry Pi models like the Raspberry Pi 4 and 3B+ include an Ethernet port for wired network
connections.
Features of Ethernet:
Offers faster, stable internet connectivity
Useful for creating web servers, NAS systems, and IoT gateways
8. Wi-Fi and Bluetooth Interfaces
Recent Raspberry Pi models include integrated Wi-Fi and Bluetooth capabilities for wireless
connectivity.
Features:
Wi-Fi supports 2.4 GHz and 5 GHz bands
8

Paavai Institutions Department of CSE
UNIT - 4
Bluetooth 5.0 support in Raspberry Pi 4 for enhanced data speed and range
9. Audio Interface (3.5mm Jack)
The 3.5mm audio jack combines audio output and composite video, offering an easy way to
connect speakers or headphones directly.
Use Cases:
Connecting audio speakers for media playback
Integrating sound systems into IoT applications
10. Power Interface (Micro USB / USB-C)
Raspberry Pi boards are powered via Micro USB (older models) or USB-C (Raspberry Pi 4 and
newer).
Recommended Power Ratings:
Raspberry Pi 4: 5V/3A via USB-C
Raspberry Pi 3 and earlier: 5V/2.5A via Micro USB
11. Camera Serial Interface (CSI)
The CSI port connects camera modules directly to the Raspberry Pi’s board for improved image
and video performance.
Features:
Ideal for applications like facial recognition, surveillance, and   computer  vision
Supports Raspberry Pi Camera Module V2 and other third-party cameras
12. Display Serial Interface (DSI)
The DSI port is dedicated to connecting official Raspberry Pi touchscreens for interactive display
projects.
Features:
High-performance data transfer for display panels
Used for projects requiring custom touch interfaces
4.4 PROGRAMMIN RASBERRY PI WITH PYTHON
Raspberry Pi can be programmed using Python to interact with hardware via its General Purpose
Input/Output (GPIO) pins. These 40-pin headers (on models like Pi 4) allow control of LEDs,
sensors, motors, and switches. Python libraries simplify GPIO handling.
Key Concepts
GPIO Modes: Use BCM (Broadcom numbering, e.g., GPIO 17) or BOARD (physical pin
numbers, e.g., pin 11).
Libraries:
oRPi.GPIO: Low-level control for setting pins as input/output, reading/writing states.
ogpiozero: High-level, beginner-friendly for LEDs, buttons, sensors.
Installation (if needed): Run sudo apt update && sudo apt install python3-rpi.gpio
python3-gpiozero on Raspberry Pi OS.
Safety: Always use resistors (e.g., 220-330Ω for LEDs) to limit current. Clean up GPIOs
with GPIO.cleanup() to reset states.
9

Paavai Institutions Department of CSE
UNIT - 4
Basic Setup:
python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) # Or GPIO.BOARD
GPIO.setwarnings(False) # Suppress warnings
# At end: GPIO.cleanup()
Controlling LED with Raspberry Pi
Control an LED by setting a GPIO pin HIGH (3.3V, on) or LOW (0V, off). This introduces digital
output.
Hardware Setup
Components: Raspberry Pi, LED, 220-330Ω resistor, breadboard, jumper wires.
Circuit:
oConnect LED anode (long leg) to GPIO 17 via resistor.
oConnect LED cathode (short leg) to GND (e.g., pin 6).
Diagram Reference: Standard setup from Circuit Basics—resistor prevents overcurrent,
which could damage Pi or LED.
Python Code Example (Blinking LED)
Use RPi.GPIO for precise control or gpiozero for simplicity.
RPi.GPIO Version (blinks every 1s):
python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
led_pin = 17
GPIO.setup(led_pin, GPIO.OUT)
try:
while True:
GPIO.output(led_pin, GPIO.HIGH) # LED on
print("LED ON")
time.sleep(1)
GPIO.output(led_pin, GPIO.LOW) # LED off
print("LED OFF")
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup() # Reset on Ctrl+C
Explanation: GPIO.setup() configures pin as output. GPIO.output() toggles state.
time.sleep() controls blink rate. Run with sudo python3 led_blink.py (sudo for GPIO
access).
10

Paavai Institutions Department of CSE
UNIT - 4
gpiozero Version (simpler):
python
from gpiozero import LED
from time import sleep
led = LED(17)
while True:
led.on()
sleep(1)
led.off()
sleep(1)
Interfacing an LED and Switch with Raspberry Pi
Add a switch (pushbutton) as digital input to control the LED (e.g., press to turn on). Introduces
input reading and pull-up resistors to avoid floating states.
Hardware Setup
Components: As in 4.6.1 + pushbutton switch, 10kΩ pull-up resistor.
Circuit:
oLED: Same as above (GPIO 17 to resistor to anode; cathode to GND).
oSwitch: One leg to GPIO 2 (input), other to GND. Pull-up: 10kΩ from GPIO 2 to
3.3V (prevents false readings).
Diagram Reference: Pull-up circuit ensures switch reads LOW when pressed, HIGH when
released.
Python Code Example (LED On When Pressed)
gpiozero Version (event-driven, recommended):
python
from gpiozero import LED, Button
from signal import pause
led = LED(17)
button = Button(2, pull_up=True) # Internal pull-up
button.when_pressed = led.on # Turn on when pressed
button.when_released = led.off # Turn off when released
pause() # Keep running
Explanation: Button detects press/release events. pull_up=True uses internal resistor. LED
follows button state.
RPi.GPIO Version (polling-based):
python
import RPi.GPIO as GPIO
11

Paavai Institutions Department of CSE
UNIT - 4
import time
GPIO.setmode(GPIO.BCM)
led_pin = 17
button_pin = 2
GPIO.setup(led_pin, GPIO.OUT)
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Internal pull-up
try:
while True:
if GPIO.input(button_pin) == GPIO.LOW: # Pressed
GPIO.output(led_pin, GPIO.HIGH)
print("LED ON")
else:
GPIO.output(led_pin, GPIO.LOW)
print("LED OFF")
time.sleep(0.2) # Debounce delay
except KeyboardInterrupt:
GPIO.cleanup()
Explanation: Polls GPIO.input() in loop. PUD_UP enables internal pull-up. sleep(0.2)
debounces switch bounce.
Toggle Variant (press once to on, again to off): Add a flag variable:
python
# In RPi.GPIO loop, replace if with:
state = GPIO.input(button_pin) == GPIO.LOW and not flag # Edge detection
if state:
flag = not flag
GPIO.output(led_pin, not GPIO.input(led_pin)) # Toggle
time.sleep(0.2)
(Initialize flag = False outside loop.)
Interfacing a Light Sensor (LDR) and Switch with Raspberry Pi
LDR (Light Dependent Resistor) measures light intensity (resistance drops in light). Since Pi lacks
analog inputs, use RC timing circuit for approximate reading. Combine with switch: e.g., switch
enables LDR-triggered LED.
Hardware Setup
Components: As in 4.6.2 + LDR, 10µF capacitor.
Circuit:
oLDR Section: One leg to 3.3V, other to GPIO 4 (input) and capacitor positive.
Capacitor negative to GND. (RC circuit charges slower in dark.)
oSwitch/LED: Same as 4.6.2 (button on GPIO 2, LED on 17).
Diagram Reference: Wire from LDR-capacitor junction to GPIO 4 for timing
measurement.
Python Code Example (LDR Reads Light; Switch Toggles LED Based on Light)
12

Paavai Institutions Department of CSE
UNIT - 4
RC Timing for LDR (higher value = darker):
python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT) # LDR timing pin
GPIO.setup(2, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Switch
GPIO.setup(17, GPIO.OUT) # LED
def rc_timing(channel):
GPIO.setup(channel, GPIO.OUT)
GPIO.output(channel, GPIO.LOW)
time.sleep(0.1)
GPIO.setup(channel, GPIO.IN)
count = 0
while GPIO.input(channel) == GPIO.LOW:
count += 1
return count
try:
while True:
if GPIO.input(2) == GPIO.LOW: # Switch pressed: check light
light_level = rc_timing(4)
print(f"Light level: {light_level}") # >50000 = dark
if light_level > 50000: # Threshold for dark
GPIO.output(17, GPIO.HIGH) # LED on in dark
print("Dark - LED ON")
else:
GPIO.output(17, GPIO.LOW)
print("Light - LED OFF")
else:
GPIO.output(17, GPIO.LOW) # Switch off: LED off
print("Switch OFF")
time.sleep(0.5)
except KeyboardInterrupt:
GPIO.cleanup()
Explanation: rc_timing() measures charge time (analog proxy). Switch enables reading;
LED activates if dark (adjust threshold). Calibrate by covering LDR.
gpiozero Variant (for module with DO pin, if using pre-built LDR module):
python
from gpiozero import LightSensor, LED, Button
13

Paavai Institutions Department of CSE
UNIT - 4
from signal import pause
sensor = LightSensor(4) # Analog-capable with MCP3008, or use DO for digital
led = LED(17)
button = Button(2)
def light_control():
if not sensor.light_detected: # Dark
led.on()
else:
led.off()
button.when_pressed = light_control # Trigger on press
pause()
LED blink program
The schematic or connection diagram for blinking a LED using Raspberry Pi is as shown below.
 
Code for blinking and LED using Raspberry Pi given below:
import RPi.GPIO as GPIO
import time
led_pin = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)
while True:
GPIO.output(led_pin, GPIO.HIGH)
time.sleep(1)
GPIO.output(led_pin, GPIO.LOW)
time.sleep(1)
GPIO.cleanup( )
 
DHT11 Sensor
14

Paavai Institutions Department of CSE
UNIT - 4
We need to install two libraries/software for making DHT11 sensor work with Raspberry Pi 4.
Open a terminal and type the following commands.
 
pip3 install adafruit-circuitpython-dht
sudo apt-get install libgpiod2
 The first command installs Adafruit’s DHT library that works with CircuitPython. The second
command is a library for accessing the GPIO pins of Raspberry Pi.
 The schematic or connections diagram for connecting DHT 11 sensor with Raspberry Pi is given
below. 
 
The code for sensing temperature and humidity using DHT 11 sensor using Raspberry Pi 4 is given
below.
import time
import board
import adafruit_dht
dhtDevice = adafruit_dht.DHT11(board.D17)
while True:
try:
# Print the values to the serial port
temperature_c = dhtDevice.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = dhtDevice.humidity
print(“Temp: {:.1f} F / {:.1f} C    Humidity: {}% “.format(temperature_f, temperature_c,         
humidity))
except RuntimeError as error:
# Errors happen fairly often, DHT’s are hard to read, just keep going
print(error.args[0])
time.sleep(2.0)
continue
except Exception as error:
dhtDevice.exit()
raise error
15

Paavai Institutions Department of CSE
UNIT - 4
time.sleep(2.0)
 
4.5 OTHER IoT DEVICES
pcDuino
BeagleBone Black
Cubieboard
pcDuino
pcDuino is a cost-effective, high-performance mini PC platform that combines the processing
power of a Linux-based SBC with Arduino-compatible GPIO headers. Developed by Linksprite, it
targets developers, makers, and hobbyists for DIY IoT projects. It runs full PC-like OSes and
supports Arduino shields, making it a "super Arduino" for hardware-software integration.
Key Features and Specifications
Processor: Allwinner A10 (ARM Cortex-A8 @ 1GHz), Mali-400 GPU.
Memory: 1GB DDR3 RAM; 2GB onboard NAND flash (expandable via microSD up to
32GB).
GPIO and I/O:
oArduino-compatible 28-pin headers (digital I/O, PWM, analog inputs: A0-A1 6-bit
0-2V, A2-A5 12-bit 0-3.3V).
oPWM pins (3,5,6,9,10,11) for analog output simulation.
oInterfaces: USB 2.0 (x2), Ethernet, HDMI, audio jack, camera connector, serial
UART.
Connectivity: Ethernet; Wi-Fi/Bluetooth via USB dongles.
OS Support: Ubuntu Linux, Android ICS; programming in C/C++, Python, Java, Node.js
(via iotduino module).
Power: 5V DC; low-power for embedded use.
Dimensions: Compact (similar to Raspberry Pi).
IoT Applications
Sensor Integration: Read temperature/humidity (DHT11) or ultrasonic distance (HC-SR04)
via GPIO; requires 3.3V level shifters for 5V sensors.
Home Automation: Node.js-based web servers for controlling LEDs/relays; MQTT for
cloud connectivity.
Prototyping: Blinking LEDs or PWM motor control using Arduino-style code.
Example: IoTduino Node.js module for real-time sensor data to a web dashboard.
BeagleBone Black
16

Paavai Institutions Department of CSE
UNIT - 4
BeagleBone Black (BBB) is a community-supported, low-cost SBC from BeagleBoard.org,
emphasizing real-time processing and hardware expansion via "capes" (add-on boards). It's suited
for industrial IoT due to its PRU (Programmable Real-Time Units) for low-latency tasks,
outperforming Raspberry Pi in embedded control.
Key Features and Specifications
Processor: TI Sitara AM335x (ARM Cortex-A8 @ 1GHz), PowerVR SGX530 GPU.
Memory: 512MB DDR3 RAM; 4GB eMMC storage (expandable via microSD).
GPIO and I/O:
o65 digital I/Os, 7 analog inputs (12-bit ADC), PWM, I2C, SPI, UART.
o2x 46-pin headers for capes (e.g., Robotics Cape for motors/sensors).
Connectivity: 10/100 Ethernet; HDMI (mini), USB 2.0 (host/client); Wi-Fi/BT on Wireless
variant.
OS Support: Debian/Ubuntu; programming in Python, C++, Node.js, JavaScript
(BoneScript).
Power: 5V DC; heat sink recommended for heavy loads.
Dimensions: Credit-card sized (86.4 x 53.3mm).
IoT Applications
Industrial Automation: Real-time sensor polling (e.g., temperature via ADC) and actuator
control (relays/motors) using PRUs.
Robotics/Edge Computing: Cape add-ons for comms (RS485/CAN) or power
management; cloud integration via MQTT/AWS IoT.
Monitoring Systems: Ethernet-based data logging to servers; Node-RED for visual IoT
wiring.
Example: Bluetooth SensorTag integration for environmental monitoring, pushing data to
cloud with HTTPS.
Cubieboard
Cubieboard is an open-source SBC series from CubieTech, known for multimedia capabilities and
expandability. Early models (e.g., Cubieboard1/2) use Allwinner SoCs; later ones (e.g.,
Cubieboard4/6/7) offer octa-core power for demanding IoT/media tasks. It's versatile for mini-PCs,
robots, or clusters.
Key Features and Specifications (Focusing on Popular Models: Cubieboard1 & Cubieboard4)
Processor:
oCubieboard1: Allwinner A10 (Cortex-A8 @ 1GHz, Mali-400 GPU).
oCubieboard4: Allwinner A80 (octa-core: 4x A15 + 4x A7 @ 2GHz, PowerVR
GX6450 GPU).
Memory:
oCubieboard1: 1GB DDR3; onboard NAND (expandable via microSD).
oCubieboard4: 2GB DDR3; 16GB eMMC + SATA for HDD/SSD (up to 4TB).
GPIO and I/O:
o96-pin expansion header (digital I/O, UART, I2C, SPI, PWM).
oInterfaces: USB 2.0/3.0, HDMI (up to 4K), SATA, Ethernet, IR, audio I/O.
Connectivity: Gigabit Ethernet; Wi-Fi/BT (e.g., AP6212 on later models); optional 4G.
17

Paavai Institutions Department of CSE
UNIT - 4
OS Support: Android 4.4/ICS, Ubuntu 12.04/14.04, Debian, Fedora; programming in C,
Python.
Power: 5V DC; supports batteries (e.g., 5300mAh in Cubietruck variant).
Dimensions: Compact (100 x 100mm for base models).
IoT Applications
Media/IoT Gateways: High-res video streaming with sensors; SATA for storage in
surveillance systems.
Robotics/Clusters: Hadoop clusters for big data IoT; GPIO for motor/sensor control.
Home Servers: Run Apache servers or Android apps for smart home hubs.
Example: Ultrasonic sensor integration for distance-based automation.
4.6 INTRODUCTION TO CLOUD STORAGE MODELS & COMMUNICATION APIs
Cloud storage and communication APIs form the backbone of IoT ecosystems, enabling devices
to store, process, and share data seamlessly across networks. Cloud storage models provide
scalable, accessible repositories for the vast amounts of data generated by IoT devices, such as
sensor readings from a Raspberry Pi or actuator states from an Arduino.
These models are categorized by deployment (public, private, hybrid, community) and service
types (IaaS, PaaS, SaaS), each addressing specific IoT needs like cost-efficiency, security, or ease
of development. Communication APIs, such as MQTT, HTTP/REST, and WebSocket, standardize
data exchange between devices and cloud platforms, ensuring reliable, secure, and real-time
connectivity. These technologies are critical for applications ranging from smart home automation
(e.g., controlling LEDs via cloud dashboards) to industrial monitoring (e.g., BeagleBone Black
logging factory data). This section explores these models and APIs, with practical examples for IoT
integration.
Cloud Storage Models
Cloud storage models are essential for managing IoT data, offering flexible solutions for storage,
processing, and analytics. They are divided into deployment models, which define how
infrastructure is managed, and service models, which determine the level of abstraction provided to
users. Each model suits specific IoT use cases, balancing factors like cost, scalability, security, and
ease of use.
Deployment Models
Public Cloud The public cloud, hosted by providers like AWS, Google Cloud, or Microsoft Azure,
uses shared infrastructure accessible over the internet, making it a cost-effective choice for IoT
applications. For example, an ESP32 can send humidity data to AWS S3, costing approximately
$0.023/GB/month for standard storage, ideal for startups or small-scale projects like smart home
monitoring. Public clouds offer high scalability and eliminate hardware maintenance, but they pose
security risks for sensitive data and require reliable internet connectivity. This makes them suitable
for non-critical IoT tasks, such as a Raspberry Pi logging temperature to Google Cloud Storage for
analysis, but less ideal for applications requiring strict data privacy.
Private Cloud Private clouds provide dedicated infrastructure for a single organization, hosted on-
premises or by providers like VMware or OpenStack, prioritizing security and customization. In
IoT, they are used in scenarios demanding compliance, such as a BeagleBone Black storing factory
sensor data in a private Azure instance for industrial automation. Private clouds ensure data
18

Paavai Institutions Department of CSE
UNIT - 4
isolation and meet regulatory standards like GDPR, but they involve high setup and maintenance
costs, making them less scalable than public clouds. For instance, a Cubieboard could log critical
machine data to a local Nextcloud server, ensuring secure, on-site storage for sensitive IoT
applications.
Hybrid Cloud Hybrid clouds combine public and private clouds, offering a balance of cost,
scalability, and security. They are ideal for IoT systems where sensitive data is processed locally,
but analytics or backups leverage public cloud resources. For example, a smart city project might
use a Cubieboard to process traffic sensor data on a private cloud for real-time control, while
aggregating historical data in AWS for analysis. Hybrid clouds provide flexibility but require
complex integration to manage data flow between environments. This makes them suitable for
advanced IoT setups needing both security and scalability.
Community Cloud Community clouds serve multiple organizations with shared needs, such as
healthcare or environmental IoT projects, offering a cost-shared infrastructure with tailored
compliance. For instance, a group of environmental monitoring projects could use a community
cloud to store data from multiple Arduino-based air quality sensors. These clouds provide cost
efficiency and collaboration but are less scalable and require coordination among stakeholders.
They are less common in IoT but useful for niche, collaborative applications.
Service Models
Infrastructure as a Service (IaaS) IaaS provides virtualized computing resources like virtual
machines, storage, and networking, giving IoT developers full control over infrastructure. For
example, a Raspberry Pi can push sensor data to an AWS EC2 instance hosting an MQTT broker
for real-time IoT communication. IaaS is flexible for custom IoT backends but requires more setup
effort, making it suitable for developers building scalable IoT platforms, such as a BeagleBone
Black running a custom database for industrial monitoring.
Platform as a Service (PaaS) PaaS offers a development environment for building and deploying
IoT applications without managing underlying infrastructure. For instance, a pcDuino can host a
Node.js-based web server on AWS Elastic Beanstalk to display ESP32 sensor data on a dashboard.
PaaS simplifies development, making it ideal for rapid prototyping of IoT apps, such as smart home
interfaces, but may limit low-level control. It’s widely used for creating scalable IoT solutions with
minimal server management.
Software as a Service (SaaS) SaaS delivers ready-to-use applications accessible via the cloud,
ideal for quick IoT integration. Platforms like ThingSpeak or Blynk allow devices like Arduino to
visualize sensor data (e.g., temperature logs) on mobile apps or web dashboards without coding
complex backends. SaaS is user-friendly for non-technical users but offers less customization. For
example, a Raspberry Pi can send light sensor data to ThingSpeak for real-time graphing,
streamlining IoT deployment for hobbyists or small projects.
Communication APIs
Communication APIs enable IoT devices to exchange data with cloud platforms, other devices, or
applications, ensuring reliable and secure connectivity. Protocols like MQTT, HTTP/REST, and
WebSocket are widely used in IoT for their efficiency and compatibility with constrained devices
like Raspberry Pi or ESP8266.
19

Paavai Institutions Department of CSE
UNIT - 4
MQTT (Message Queuing Telemetry Transport) API
MQTT is a lightweight, publish-subscribe protocol designed for low-bandwidth, high-latency IoT
networks, making it ideal for resource-constrained devices. It operates via a broker (e.g., Mosquitto,
AWS IoT Core), where devices publish data to topics (e.g., home/temperature) and subscribers
receive updates. MQTT supports Quality of Service (QoS) levels for delivery guarantees (0: at most
once, 1: at least once, 2: exactly once). In IoT, it’s used for real-time applications, such as an ESP32
publishing light sensor data to AWS IoT Core or a Raspberry Pi controlling a relay via MQTT
messages. For example, a Python script on a Raspberry Pi using the Paho-MQTT library can
publish temperature data every 5 seconds to a public broker like broker.hivemq.com and subscribe
to home/led for control commands. MQTT’s low overhead makes it efficient, but it requires a
broker setup, which adds complexity. Its widespread use in smart homes and industrial IoT
highlights its reliability for real-time data exchange.
HTTP/REST API
HTTP/REST APIs use standard HTTP methods (GET, POST, PUT, DELETE) for request-response
communication, making them simple and widely supported for IoT. Devices send data (e.g., JSON
payloads) to cloud endpoints, such as a BeagleBone Black posting sensor readings to ThingSpeak’s
REST API. For instance, an ESP8266 can use the HTTPClient library in Arduino IDE to send
temperature data to api.thingspeak.com every 20 seconds, respecting rate limits. REST is ideal for
data logging or web-based control (e.g., toggling a Cubieboard relay via a dashboard), but its
polling-based nature consumes more bandwidth than MQTT, making it less efficient for real-time
applications. Its simplicity and compatibility with web standards make it a go-to choice for
integrating IoT devices with cloud platforms like AWS or Google Cloud.
WebSocket API
WebSocket APIs enable persistent, bidirectional communication over a single connection, ideal for
real-time IoT applications like live dashboards or device control. Unlike HTTP’s request-response
model, WebSocket (using ws:// or wss:// for secure connections) maintains an open channel for
continuous data exchange. For example, a pcDuino can stream sensor data to a Node.js WebSocket
server for real-time visualization, or an Arduino can adjust motor speed based on WebSocket
messages. A Node.js server running on port 8080 can handle connections from an ESP32 client
using the WebSocketClient library, acknowledging sensor data in real time. WebSocket excels in
low-latency scenarios but is resource-intensive for low-power devices, limiting its use on
constrained IoT hardware. Its real-time capabilities make it suitable for interactive IoT applications.
CoAP (Constrained Application Protocol)
CoAP is a lightweight, REST-like protocol designed for constrained IoT devices with low power
and memory, using UDP instead of TCP to reduce overhead. It supports GET, POST, PUT, and
DELETE methods, similar to HTTP, but is optimized for devices like ESP8266 in smart agriculture
or mesh networks like Particle Argon. For example, a Raspberry Pi can use the libcoap library to
query sensor nodes in a low-power network. CoAP is efficient for battery-powered devices but has
a smaller ecosystem and less adoption than MQTT or HTTP, limiting its use. Its design for
constrained environments makes it a niche but valuable option for specific IoT scenarios.
20

Paavai Institutions Department of CSE
UNIT - 4
Other APIs
Additional APIs enhance IoT connectivity for specific needs. AMQP (Advanced Message Queuing
Protocol), used in platforms like RabbitMQ, supports enterprise-grade messaging for industrial IoT,
such as factory data aggregation. gRPC, a high-performance framework, is used in IoT backends
(e.g., Google Cloud IoT Core) for microservices. Blynk API, a SaaS platform, simplifies mobile
app integration, allowing an Arduino to control a smart home device via a smartphone interface.
These APIs cater to specialized IoT requirements, from high-throughput industrial systems to user-
friendly consumer applications.
4.7 WAMP
The Web Application Messaging Protocol (WAMP) is a routed protocol for polyglot distributed
applications with all application agents connecting to a WAMP Router that performs message
routing between them. WAMP unifies the two most important communication patterns under a
single protocol: Publish-Subscribe and Routed Remote Procedure Calls.
How is WAMP different than other protocols?
Six key features makes WAMP unique amongst alternative application messaging protocols:
Session-oriented. All messages are routed within an established session. Sessions are authenticated and
all messages are authorised.
Designed for multi-tenancy through the use of Realms for both security and routing. Realms are virtual
so it does not impose additional infrastructure requirements e.g. dedicated ports. Sessions are attached to a
single Realm at a time.
Provides both application messaging patterns, Publish-Subscribe (PubSub) and Routed Remote
Procedure Calls (rRPC) a dynamic RPC variant where Caller and Callee are completely decoupled and no
direct connection exists between them.
Provides a peer-to-peer programming model, as any distributed application component can play any
and the same roles simultaneously: Caller and Callee (RPC), Publisher and Subscriber. This is in contrast
to protocols that distinguish between RPC Client and RPC Server, treating the client as dumb e.g. HTTP
and gRPC.
Supports multiple-transports and each client can choose which one to use. WAMP can run over any
transport which is message-oriented, ordered, reliable, and bi-directional such as Websockets, TCP, Unix
domain socket, etc.
Supports multiple serializations and each session can choose which one to use e.g. JSON, Msgpack, etc.
21

Paavai Institutions Department of CSE
UNIT - 4
WAMP Session between Client and Router:
Web Application Messaging Protocol (WAMP) is a sub-protocol of Websocket which
provides publish-subscribe and remote procedure call (RPC) messaging patterns.
1.Transport: Transport is channel that connects two peers.
2.Session: Session is a conversation between two peers that runs over a transport.
3.Client: Clients are peers that can have one or more roles. In publish-subscribe model
client can have following roles:
–Publisher: Publisher publishes events (including payload) to the topic maintained by
the Broker.
–Subscriber: Subscriber subscribes to the topics and receives the events including the
payload.
In RPC model client can have following roles:
–Caller: Caller issues calls to the remote procedures along with call arguments.
–Callee: Callee executes the procedures to which the calls are issued by the caller and
returns the results back to the caller.
4.Router: Routers are peers that perform generic call and event routing. In publish-
subscribe model Router has the role of a Broker:
–Broker: Broker acts as a router and routes messages published to a topic to all
subscribers subscribed to the topic.
In RPC model Router has the role of a Broker:
–Dealer: Dealer acts a router and routes RPC calls from the Caller to the Callee and
routes results from Callee to Caller.
5.Application Code: Application code runs on the Clients (Publisher, Subscriber, Callee or
Caller).
22

Paavai Institutions Department of CSE
UNIT - 4
WAMP Protocol interaction between peers:
WAMP sessions are established over web socket transport within the lifetime of web socket
transport. The client (in the publisher role) Runs a WAMP application component that publishes a
message to the router. The router (in the broker role) runs on the server and routes the message to
the subscriber. It decouples the publisher from the subscribers. The communication between
publisher- broker and broker to publisher happens over a WAMP web web-socket session 
Advantages of WAMP in IoT
WAMP’s design as a unified, web-native protocol offers significant benefits for IoT, enhancing
efficiency, security, and interoperability. Its ability to combine messaging patterns and support web
integration makes it ideal for real-time, distributed IoT systems.
Unified Pub/Sub-RPC Model
WAMP integrates Publish & Subscribe (Pub/Sub) for event broadcasting and Remote Procedure
Calls (RPC) for control, simplifying IoT design. Unlike MQTT, which focuses only on Pub/Sub,
WAMP allows a single protocol to handle both sensor data streaming (e.g., ESP32 publishing
temperature) and actuator commands (e.g., RPC to toggle a BeagleBone Black relay), reducing the
need for multiple protocols in smart home or industrial setups.
Web-Native WebSocket Transport
WAMP’s default WebSocket transport enables seamless integration with browsers and mobile apps,
perfect for real-time IoT dashboards. For example, a Raspberry Pi can publish sensor data to a
Crossbar.io router, which a web app subscribes to for live visualization, eliminating the need for
complex gateways required by MQTT or CoAP for web compatibility.
23

Paavai Institutions Department of CSE
UNIT - 4
Robust Security
WAMP ensures security through TLS encryption, WAMP-CRA (Challenge-Response
Authentication), and role-based access control (RBAC) via realms, protecting sensitive IoT data
like medical sensor readings. Its router-based model closes device ports, reducing attack risks on
devices like ESP32, unlike protocols requiring open ports, making it suitable for secure
applications.
Scalability and High Availability
WAMP routers, like Crossbar.io, handle thousands of connections and support clustering for high
availability, ideal for large-scale IoT deployments. For instance, a smart city network with multiple
Cubieboards publishing traffic data can rely on clustered routers to ensure uptime, offering better
scalability than single-broker MQTT setups.
Low Protocol Overhead
Using lightweight JSON or MessagePack serialization, WAMP minimizes overhead, suiting
moderately constrained devices like Raspberry Pi. This allows efficient data transmission (e.g.,
sensor JSON payloads) compared to verbose protocols like SOAP, making it viable for real-time
IoT with moderate bandwidth constraints.
Cross-Platform Compatibility
WAMP’s language-agnostic libraries, such as Autobahn for Python and Autobahn|JS for JavaScript,
ensure compatibility across IoT platforms. A BeagleBone Black can use Python to publish data,
while a JavaScript dashboard subscribes, enabling seamless integration in diverse setups like smart
factories.
Disadvantages of WAMP in IoT
WAMP’s advanced features come with limitations, particularly in complexity and resource
demands, making it less suitable for certain IoT scenarios compared to simpler protocols like
MQTT or CoAP.
Higher Complexity Than MQTT
WAMP’s unified Pub/Sub-RPC model is more complex than MQTT’s straightforward Pub/Sub,
requiring additional setup (e.g., Crossbar.io router configuration) for simple tasks like Raspberry Pi
sensor logging. This complexity can slow development for basic IoT applications compared to
MQTT’s lightweight brokers.
Router Dependency
WAMP’s reliance on a central router introduces a potential single point of failure, unlike MQTT’s
distributed broker options. Without clustering, a router crash (e.g., Crossbar.io) can disrupt IoT
systems, such as a smart home using ESP32, adding complexity and cost to ensure reliability.
Less Efficient for Ultra-Low-Power Devices
WAMP’s WebSocket-based design is less efficient for ultra-low-power devices compared to
CoAP’s UDP-based approach. Battery-powered sensors (e.g., Arduino Nano) may struggle with
WAMP’s overhead, making CoAP better for low-power IoT like smart agriculture.
24

Paavai Institutions Department of CSE
UNIT - 4
Smaller Ecosystem
WAMP’s ecosystem is less mature than MQTT’s or HTTP’s, with fewer IoT-specific tools and
community resources. Developers building a sensor network may find more MQTT-compatible
devices and tutorials, limiting WAMP’s support for integration and troubleshooting compared to
widely adopted protocols.
Steep Learning Curve
WAMP’s advanced features, like routed RPC and realm-based RBAC, create a steeper learning
curve than MQTT or HTTP/REST. Beginners using Raspberry Pi may find configuring WAMP’s
router and authentication challenging, slowing adoption in educational or hobbyist IoT projects.
Applications of WAMP in IoT
Smart Homes: Enables real-time control, e.g., Raspberry Pi publishing motion sensor data
to a topic, with RPC triggering smart locks via a Crossbar.io router for secure home
automation.
Industrial IoT (IIoT): Supports machine monitoring, e.g., BeagleBone Black publishing
vibration data and using RPC for predictive maintenance, ensuring scalability in factories.
Environmental Monitoring: Facilitates sensor networks, e.g., ESP32 broadcasting air
quality data to topics, with RPC for remote sensor calibration in distributed systems.
Smart Cities: Powers vehicle-to-vehicle (V2V) messaging, e.g., cars publishing location
updates and calling rerouting procedures via WAMP for traffic management.
Healthcare: Secures wearable data, e.g., devices publishing vitals to topics and RPC
triggering hospital alerts, leveraging WAMP’s TLS and RBAC for privacy.
Edge AI: Routes inference requests, e.g., WAMP enabling real-time AI processing between
devices, supporting scalable, low-latency IoT ecosystems.
4.8 XIVELY CLOUD FOR IoT
Xively Cloud, formerly known as Pachube and Cosm, was a pioneering Platform as a Service
(PaaS) designed specifically for Internet of Things (IoT) applications, enabling developers to
connect, manage, and scale devices without building complex backend infrastructure. Acquired by
LogMeIn in 2011 and later by Google in 2018, it was integrated into Google Cloud IoT Core, which
itself was retired in 2023. Xively provided a cloud-based API and SDK to simplify IoT
development, supporting real-time data collection from devices like Arduino or Raspberry Pi,
secure connectivity, and integration with analytics tools. It used MQTT for publish-subscribe
messaging, alongside REST and WebSockets, making it ideal for prototyping connected products in
smart homes, industrial monitoring, and environmental sensing. Although discontinued, its legacy
influences modern IoT platforms like AWS IoT or Azure IoT Hub, emphasizing device
management and data visualization.
25

Paavai Institutions Department of CSE
UNIT - 4
Key Features
Device Connectivity and Management: Allowed secure registration and provisioning of
IoT devices, supporting protocols like MQTT, HTTP, and WebSockets for real-time data
ingestion from sensors (e.g., temperature or motion data from ESP32).
Data Storage and Analytics: Offered cloud storage for time-series data, with built-in
analytics and visualization dashboards to monitor device performance and derive insights,
such as alerting on anomalies in industrial sensors.
API and SDK Support: Provided RESTful APIs for easy integration, plus language-
specific SDKs (e.g., Python, Arduino libraries) to embed code for data feeds, enabling quick
prototyping without server setup.
Security and Scalability: Included a trust engine for authentication, encryption, and role-
based access, scaling from small prototypes (e.g., hobbyist Arduino projects) to enterprise
deployments with thousands of devices.
Integration Capabilities: Facilitated linking IoT data with third-party services (e.g., CRM
systems or mobile apps) via APIs, supporting hybrid ecosystems for business value
extraction.
Applications in IoT
Smart Homes and Prototyping: Used for connecting Arduino-based sensors (e.g., soil
moisture for smart plants) to cloud dashboards, enabling remote monitoring and control via
mobile apps.
Industrial IoT (IIoT): Facilitated machine-to-machine communication, such as vibration
monitoring on factory equipment, with real-time alerts for predictive maintenance.
Environmental Monitoring: Enabled distributed sensor networks (e.g., air quality via
ESP32) to stream data for visualization, as seen in post-Fukushima radiation tracking
projects.
Connected Products: Supported OEMs in building scalable solutions, like ARM mbed kits
for rapid device development integrated with Xively for data management.
Education and Development: Provided tutorials for beginners, linking hardware like
Raspberry Pi to cloud APIs for learning IoT concepts.
Advantages
Ease of Use: Simplified IoT development with no-code dashboards and SDKs, reducing
time-to-market for prototypes compared to custom servers.
Scalability: Handled massive device fleets, from hobbyist to enterprise, with auto-scaling
cloud resources.
Interoperability: Broad protocol support (MQTT, REST) integrated with ecosystems like
ARM and TI chipsets.
Cost-Effective: Free tier for testing, pay-as-you-go for production, minimizing upfront
infrastructure costs.
Disadvantages
Discontinuation: Retired via Google Cloud IoT Core shutdown in 2023, forcing migrations
to alternatives like AWS IoT, disrupting legacy projects.
Limited Customization: Advanced analytics required external tools, less flexible than full-
fledged platforms like Azure IoT.
26

Paavai Institutions Department of CSE
UNIT - 4
Dependency on Cloud: Relied heavily on internet connectivity, posing challenges for
offline or low-bandwidth IoT scenarios.
Ecosystem Shift: Post-acquisition integration reduced standalone features, with smaller
community support compared to open-source alternatives.
4.9 DJANGO
Django is a Python framework that makes it easier to create web sites using Python.
Django takes care of the difficult stuff so that you can concentrate on building your
web applications.
Django emphasizes reusability of components, also referred to as DRY (Don't Repeat
Yourself), and comes with ready-to-use features like login system, database
connection and CRUD operations (Create Read Update Delete).
Django Architecture
Django follows the MVT design pattern (Model View Template).
Model - The data you want to present, usually data from a database.
View - A request handler that returns the relevant template and content - based on the
request from the user.
Template - A text file (like an HTML file) containing the layout of the web page, with logic
on how to display the data.
Model
The model provides data from the database. In Django, the data is delivered as an Object Relational
Mapping (ORM), which is a technique designed to make it easier to work with databases.
The most common way to extract data from a database is SQL. One problem with SQL is that you
have to have a pretty good understanding of the database structure to be able to work with it.
Django, with ORM, makes it easier to communicate with the database, without having to write
complex SQL statements. The models are usually located in a file called models.py.
View
A view is a function or method that takes http requests as arguments, imports the relevant model(s),
and finds out what data to send to the template, and returns the final result. The views are usually
located in a file called views.py.
Template
A template is a file where you describe how the result should be represented. Templates are
often .html files, with HTML code describing the layout of a web page, but it can also be in other
file formats to present other results, but we will concentrate on .html files. Django uses standard
HTML to describe the layout, but uses Django tags to add logic:
<h1>My Homepage</h1>
<p>My name is {{ firstname }}.</p>
The templates of an application is located in a folder named templates.
27

Paavai Institutions Department of CSE
UNIT - 4
4.10 AMAZON WEB SERVICES FOR IOT
Amazon Ec2 – Python Example
Boto is a Python package that provides interfaces to Amazon Web Services (AWS). In this
example, a connection to EC2 service is fi rst established by calling boto.ec2.connect_to_region.
The EC2 region, AWS access key and AWS secret key are passed to this function. After
connecting to EC2 , a new instance is launched using the conn.run_instances function. The AMI-
ID, instance type, EC2 key handle and security group are passed to this function.
Amazon AutoScaling – Python Example
AutoScaling Service
A connection to AutoScaling service is first established by
calling boto.ec2.autoscale.connect_to_region function.
Launch Configuration
After connecting to AutoScaling service, a new launch configuration is created by
calling
conn.create_launch_con f iguration. Launch configuration contains instructions on how
to launch new instances including the AMI-ID, instance type, security groups, etc.
AutoScaling Group
After creating a launch configuration, it is then associated with a new AutoScaling
group. AutoScaling group is created by calling conn.create_auto_scaling_group. The settings for
AutoScaling group such as the maximum and minimum number of instances in the group, the
launch configuration, availability zones, optional load balancer to use with the group, etc.
Amazon DynamoDB – Python Example
In this example, a connection to DynamoDB service is first established by calling
boto.dynamodb.connect_to_region.
After connecting to DynamoDB service, a schema for the new table is created by calling
conn.create_schema.
The schema includes the hash key and range key names and types.
A DynamoDB table is then created by calling conn.create_table function with the table
schema, read units and write units as input parameters.
Python for MapReduce
 The example shows inverted index mapper program.
The map function reads the data from the standard input (stdin) and splits the tab-
limited data into document-ID and contents of the document.
The map function emits key-value pairs where key is each word in the document and
value is the document-ID.
Python Packages of Interest
28

Paavai Institutions Department of CSE
UNIT - 4
 JSON
JavaScript Object Notation (JSON) is an easy to read and write data-interchange
format. JSON is used as an alternative to XML and is is easy for machines to parse and
generate. JSON is built on two structures - a collection of name-value pairs (e.g. a Python
dictionary) and ordered lists of values (e.g.. a Python list).
 XML
XML (Extensible Markup Language) is a data format for structured document
interchange. The Python minidom library provides a minimal implementation of the
Document Object Model interface and has an API similar to that in other languages.
 HTTPLib & URLLib
HTTPLib2 and URLLib2 are Python libraries used in network/internet
programming
 SMTPLib
Simple Mail Transfer Protocol (SMTP) is a protocol which handles sending email
and routing e-mail between mail servers. The Python smtplib module provides an SMTP
client session object that can be used to send email.
 NumPy
NumPy is a package for scientific computing in Python. NumPy provides support
for large multi-dimensional arrays and matrices
4.11 SKY NET LOT MESSAGING PLATFORM
Scikit-learn is an open source machine learning library for Python that provides
implementations of various machine learning algorithms for classification, clustering, regression
and dimension reduction problems.
Skynet was an open-source machine-to-machine instant messaging platform for the Internet of
Things (IoT) that allowed devices like sensors and smart home devices to communicate by
registering on the network with a UUID and token. It supported both HTTP REST and real-time
WebSockets, enabling devices to send, receive, and subscribe to messages from other devices. The
platform's functionality was later continued and open-sourced by Octoblu, following its acquisition
by Citrix.  
Key Features of Skynet  
Open-Source: 
Skynet was an open-source platform, making its code available to users for development and
modification.
Device Registration: 
Devices were registered on the network using a unique UUID and secret token for authentication.
Messaging Protocols: 
It supported communication via HTTP REST and real-time WebSockets.
Device-to-Device Communication: 
The platform enabled devices to discover and send messages to each other directly.
Subscription Model: 
Devices could subscribe to messages from other devices or specific sensor activities.
29

Paavai Institutions Department of CSE
UNIT - 4
NPM Module: 
A Node.js module was available to simplify connectivity for Node.js applications.
Applications in IoT
Smart Homes: Enables autonomous device interactions, e.g., a Raspberry Pi motion sensor
messaging Philips Hue lights to flash on detection, or Nest thermostat coordinating with
WeMo outlets for energy management.
Industrial IoT (IIoT): Supports predictive maintenance, e.g., BeagleBone Black sensors
querying and messaging factory machines for vibration alerts or automated adjustments.
Robotics and Drones: Allows fleet control, e.g., querying idle drones in a zone and sending
flight instructions via M2M messages for coordinated tasks.
Environmental Monitoring: Facilitates sensor networks, e.g., ESP32 nodes streaming air
quality data and subscribing to threshold-based alerts for distributed environmental tracking.
Automation and Integration: Pairs with Node-RED for visual wiring of IoT flows, e.g.,
drag-and-drop control of Arduino pins/servos via SkyNet messages for custom bots or
prototypes.
Advantages
Interoperability: Unified API across protocols reduces fragmentation, allowing seamless
M2M messaging without multiple SDKs.
Ease of Prototyping: Open-source with Docker support enables rapid deployment; free for
self-hosting, saving on cloud costs.
Real-Time and Scalable: WebSocket/MQTT ensures low-latency communication for large
fleets, with mesh potential for resilient networks.
Device-Centric Security: UUID/token auth and permissions empower direct device control,
bypassing vendor lock-in.
Disadvantages
Discontinued Hosted Service: Original skynet.im is offline (post-2018 Citrix shutdown),
requiring self-hosting and maintenance.
Limited Modern Support: Smaller community than MQTT/AWS IoT; lacks built-in
analytics or advanced scaling out-of-the-box.
Complexity for Beginners: Multi-protocol setup and RPC model may overwhelm simple
use cases compared to plug-and-play platforms.
Dependency on Node.js: Core relies on Node.js ecosystem, potentially limiting non-JS
environments without adaptation.
30
Tags