Lecture 6 - IoT Comms and Storage
Lecture 6 - IoT Comms and Storage
Storage
2
Webservers from and IoT Perspective
3
Messaging
4
What are Middleware/Carrier Languages?
5
Components of carrier languages
Identity of devices:
1000s of devices in a IoT system
Each one needs to have a different identification
mechanism
Sensor/Actuator data:
Sensing information
Decision information
Metadata:
Time
Geo Locations
Application Details
6
Best Practices for Carrier Languages
Keep it small.
Especially for the Things to Middleware.
Keep it with descriptions
Especially for the Middleware to Cloud and Cloud to
User related outputs
Keep a mapping between the things’ components
with the storage all throughout the IoT system
Easy to identify things
recordtemp.php?t=%d&h=%d&ts=%d
Easy to scale up
Easy for maintenance
7
Data Storage in IoT Systems
8
IoT Data exchange
9
IoT Data exchange
10
Storage
11
On Device Storage
12
Middleware Storage
13
Cloud Server
14
Text based
communication
15
Data structure
16
Comma / Tab Separated values
17
XML
Highly structured data
Lots of metadata relative to data.
larger files
Easy for devices to parse, but requires more
memory/storage.
Easy for humans to parse.
Example message:
<iot id=e2f9a344>
<ldr>
<value>24 </value>
</ldr>
<distance>
<value> 10 </value>
<direction> 270 </direction>
</distance>
</iot>
18
JSON
Moderately data structure.
Less metadata than XML.
Smaller files than XML
Easy for devices to parse, but requires more
memory/storage.
Easy for humans to parse.
Example message:
{
“IoT":
[
{“type": “id", “value": “e2f9a344"},
{“type": “ldr", “value": “24"},
{“type": “distance", “value": “10", “direction": “270"}
]
}
19
Applications
and Data
20
Application Logic (for IoT devices)
21
IoT Data Generation
22
IoT Data Generation
Authentication requests
The device sends:
Authentication inputs ie:
Username
Password
or any ID details such as RFID card numbers,
finger prints etc…
What the device gets:
True or false response
Authentication mechanism:
PHP matches credential details and then responds
Server will log the authentication request.
23
IoT Data Generation
Log data request
The device sends:
Raw data ie:
Current temperature (float)
Time stamp
Device ID (and authentication if required)
What the device gets:
Success / Failure
How it works:
PHP matches the device ID.
The temp data and time stamp is logged to the
database.
24
IoT Data Generation
Automation request (Thermostat)
The device sends:
Raw data ie:
Current temperature (float)
Time stamp
Device ID (and authentication if required)
What the device gets:
Current fan mode and setting (on/off and percentage)
How it works:
PHP matches the device ID.
The temp data and time stamp is logged to the
database, and compared to a threshold.
The server returns the automation data for the fan.
25
MQTT
26
Traditional IoT communication
27
P2P Data exchange for IoT
28
What do IoT devices need for communication?
29
Message Queue Telemetry Transport
30
The Publish and Subcribe Model
31
Publish and Subcribe (Broker)
32
Publish and Subcribe (Publisher)
33
Publish and Subcribe (Subscriber)
A subscriber:
Can ask for any data at any time (subscribe
to a feed/channel/topic)
Expect the data in time
Can ask for multiple feeds at the same time
The broker maintains a list of subscribers and
pushes their subscribed topics to them as they
are updated.
34
Topics
35
How it works
36
MQTT Advantages
Can be Asynchronous as in HTTP:
Device can send the output and don’t stay
blocked up to when it gets the response
Persistent connection
Not stateless like in HTTP
Real Time
Low energy as it is more light weight (lower
overhead)
Packet headers are very small
Flexible
No need to know IP address
Only the feed name is sufficient
37
MQTT Disadvantages
38
Coming up...
Next week:
IoT Data Visualisatons