Skip to main content

IoT Intro

Internet of Things (IoT)

IoT world is all about communication between devices, gateways and the cloud; messages are exchanged between all these parties in order to provide a comprehensive end-to-end solution.

Shadow (Device Shadow)

A json file maintained on the cloud where all the updates are performed. These is synced with the devices on fields.

Digital Twin

https://dzone.com/articles/apache-kafka-as-digital-twin-in-industrial-iot-iio

TPM - Trusted Platform Module

Is an international standard for a secure cryptoprocessor, a dedicated microcontroller designed to secure hardware through integrated cryptographic keys

Four basic architectural components

Devices

Devices are the physical hardware elements that collect sensor data and might perform actuation.

IoT Gateway

Gateways collect, preprocess, and transfer sensor data from devices and might deliver actuation requests from the cloud to devices.

Cloud platform

The cloud platform - usually offered as a software-as-a-service solution - has a number of important roles, including data acquisition, data analytics, and device management and actuation.

Applications

Applications range from simple web-based data visualization dashboards to highly domain-specific mobile apps. On a high level, the software architecture choices for IoT client devices fall into the following seven categories, ranging from simple to more complex:

Software architecture options for IoT devices

FeatureArchitecture option
No OS or RTOSLanguage runtimeFull OSApp OSServer OSContainer OS
Typical devicesSimple sensor devices, heartbeat sensors, lightbulbs, and so onFeature watches, more advanced sensing devices"Maker" devices, generic sensing solutionsHigh-end smartwatchesSolutions benefiting from a portable webserver and edge-computing capabilitiesSolutions benefiting from fully isomorphic apps - that is, code that can be migrated between the cloud and the edge
Minimum required RAMTens of kilobytesHundreds of kilobytesA few megabytesHundreds of megabytesTens of megabytesGigabytes
Typical communication protocolsConstrained (MQTT, LWM2M, CoAP)Constrained (MQTT, LWM2M, CoAP)Standard Internet protocols (HTTP, HTTPS)Standard Internet protocols (HTTP, HTTPS)Standard Internet protocols (HTTP, HTTPS)Standard Internet protocols (HTTP, HTTPS)
Typical development languageC or assemblyJava, JavaScript, PythonC or C11Java, ObjectiveC, SwiftJavaScriptVarious
LibrariesNone or system- specificLanguage- specific generic librariesOS libraries, generic UI librariesPlatform librariesNode.js npm modulesVarious
Dynamic software updatesFirmware updates onlyYesYesYesYesYes
Third-party apps supportedNoYesYesYesYesYes
Isomorphic apps possibleNoYesOnly if the hardware architectures are binary compatibleYesYesYes

Key points

  • Windowing for streaming data

Messaging mechanisms

  1. Store and forward mechanism (using queues, topic/subscriptions in a broker)
  2. Direct messaging (receiver needs to be online in order to allow the devices to send data)

Messaging Patterns

  1. competing consumers - A messaging pattern in which more consumers get messages from a common source (i.e. queue) but each message is delivered to only one consumer.
  2. request/reply
  3. pub/sub

Communication patterns

Telemetry

  • Data flows in one direction from the device to other systems for conveying status changes in the device itself (i.e. sensors reading, ...)
  • Direct Messaging mechanism can be used if data is not to be stored.

Inquires

Requests from the device looking to gather required information or asking to initiate activities

  • Requests and response

Commands

  • Commands from other systems sent to a device (or a group of devices) to perform specific activities expecting a result from the command execution, or at least a status for that
  • Mainly store and forward mechanism is used, sometimes a TTL (Time To Live) on the command message is useful in order to avoid the possibility that an offline device will execute an "old" message that is not useful at the time the device comes back online.

Notifications

Information flows in one direction from other systems to a device (or a group of devices) for conveying status changes

image

Classifying Device States

ClassifierDescription
Assumed StateWe are unable to get the state of the device. Best we can do is to assume the state based on our last command. Example - WattMan Lite which we deployed previously, we were controlling ACs based on infrared signal - during that time we used to work on "Assumed State".
Cloud PollingIntegration of this device happens via the cloud and requires an active internet connection. Polling the state means that an update might be noticed later.
Cloud PushIntegration of this device happens via the cloud and requires an active internet connection. Home Assistant will be notified as soon as a new state is available.
Local PollingOffers direct communication with device. Polling the state means that an update might be noticed later. Example - For relay boards where we communicate over modbus protocol, we work on Local Polling. Periodically, we read the current status of values in relay board and ensure that it's the same state that we had last set.
Local PushOffers direct communication with device. Home Assistant will be notified as soon as a new state is available. Example - For the smart plug that we are currently interfacing, device does "Local Push" on the mqtt server on Rpi. So it reports it's state on a mqtt topic in a periodic basis.

Tools

Node-RED

  • Flow-based programming for the Internet of Things
  • Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
  • It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.

IoT Protocols

  1. Infrastructure(ex: 6LowPAN, IPv4/IPv6, RPL)
  2. Identification(ex: EPC, uCode, IPv6, URIs)
  3. Comms / Transport(ex: Wifi, Bluetooth, LPWAN)
  4. Discovery(ex: Physical Web, mDNS, DNS-SD)
  5. Data Protocols(ex: MQTT, CoAP, AMQP, Websocket, Node)
  6. Device Management(ex: TR-069, OMA-DM)
  7. Semantic(ex: JSON-LD, Web Thing Model)
  8. Multi-layer Frameworks(ex: Alljoyn, IoTivity, Weave, Homekit)

https://www.postscapes.com/internet-of-things-protocols

References