Embedded Systems for IoT

Chapter 10
Device-to-Cloud and Edge Integration

Diploma in IOT
Embedded Systems for IoT   •   Diploma

Device-to-Cloud and Edge Integration

Introduction

An Internet of Things (IoT) solution becomes operational only when its devices can exchange trustworthy information with software that stores, analyses, and acts on that information. Device-to-cloud integration provides this connection, while edge integration places selected processing and control functions close to the devices. Together, these approaches support monitoring, remote control, predictive maintenance, automation, and operational decision-making.

A typical IoT system contains sensors and actuators, a local network, an edge gateway, a cloud platform, databases, applications, and human or automated decision-makers. The engineering challenge is not simply to connect a device to the Internet. It is to provision the device securely, represent telemetry and commands consistently, transport messages reliably, process data at the appropriate location, and maintain the system throughout its lifecycle.

This chapter develops a practical architecture for these activities. It uses common concepts such as MQTT, HTTP, device twins, APIs, time-series databases, event processing, digital certificates, and edge–cloud workflows. Particular technologies change rapidly, but the design principles remain applicable across platforms.

Learning Objectives

After studying this chapter, a student should be able to:

  • describe the roles of devices, gateways, edge nodes, cloud services, databases, and applications;
  • provision and authenticate IoT devices securely;
  • model telemetry, state, commands, events, and metadata;
  • select suitable communication protocols and gateway functions;
  • explain the role of APIs and cloud IoT platforms;
  • design data flows involving time-series and relational databases;
  • distinguish edge processing from cloud processing;
  • design reliable monitoring and control workflows;
  • evaluate latency, bandwidth, availability, security, and governance trade-offs; and
  • apply these principles to a realistic IoT deployment.

1. The Device-to-Cloud Continuum

The device-to-cloud continuum is a chain of responsibilities rather than a single product. A sensor measures a physical variable, such as temperature. Firmware samples and packages the measurement. A local network carries the message to a gateway or edge node. The cloud receives, authenticates, stores, and analyses it. An application presents information to a user or sends a command to an actuator.

The main layers are:

LayerMain responsibilityTypical examples
DeviceSensing, actuation, local control, secure identityMicrocontroller, smart meter, motor controller
ConnectivityLocal and wide-area transportWi-Fi, Ethernet, BLE, LoRaWAN, cellular
GatewayProtocol translation, aggregation, buffering, security boundaryIndustrial gateway, home hub
EdgeLocal analytics, rules, orchestration, controlIndustrial PC, Raspberry Pi-class computer
Cloud platformIngestion, device management, storage, analyticsIoT broker, stream processor
ApplicationMonitoring, configuration, reporting, decision supportDashboard, mobile application, maintenance system

These layers may be physically combined. For example, a small device may communicate directly with a cloud broker, whereas a factory may use programmable logic controllers, an industrial gateway, and an on-premises edge server before sending selected data to the cloud.

The continuum should be designed according to requirements. A safety shutdown cannot normally depend on an Internet round trip. Conversely, long-term fleet analysis is usually more effective in the cloud, where large datasets and scalable computing resources are available.

Layered device to cloud and edge architecture DevicesSensors / actuators GatewayTranslationBuffering Edge nodeRulesLocal analyticsControlStore-and-forward CloudIngestionStorage / analytics AppsUsers / APIs Commands, policies and configuration return toward devices
Layered device to cloud and edge architecture
Figure: Layered device to cloud and edge architecture

Figure: A device-to-cloud continuum with local edge processing and a return command path.

2. Device Provisioning and Identity

Provisioning is the process of preparing a device to operate in a particular IoT system. It includes assigning an identity, loading credentials, registering metadata, configuring communication, and applying initial policy. Provisioning may occur during manufacturing, during installation, or through a secure zero-touch process.

A useful device identity is unique, persistent, and independent of a changing network address. It may be represented by a device identifier and a cryptographic credential. Common credential approaches include:

  • Pre-shared keys: simple and inexpensive, but difficult to manage securely at scale if reused.
  • Digital certificates: support strong device authentication and certificate rotation through a public-key infrastructure.
  • Hardware-backed keys: protect secrets in a secure element or trusted platform module.
  • Federated or token-based credentials: useful for controlled service access, but tokens must be scoped and rotated.

A secure provisioning sequence normally includes manufacturing identity injection, ownership registration, mutual authentication, policy assignment, configuration retrieval, and an activation test. The device should validate the server certificate and hostname; the server should validate that the device is authorised for the requested resource.

Provisioning also includes lifecycle states such as manufactured, commissioned, active, quarantined, retired, and decommissioned. A retired device must not continue to publish or receive commands. Asset records should connect the technical identity with location, model, firmware version, owner, maintenance status, and installation date.

Firmware updates are part of provisioning and maintenance. Signed updates, version checks, rollback protection, staged deployment, and recovery from interrupted downloads are essential. A device that cannot be updated securely can become a long-term operational and cybersecurity liability.

3. Modelling Telemetry, State, Commands, and Events

A cloud service can only interpret device data reliably when the data model is explicit. A message should identify what was measured, by which device, at what time, in which unit, and with what quality status.

A practical telemetry record may contain:

{
  "deviceId": "pump-17",
  "timestamp": "2025-03-01T10:15:00Z",
  "measurements": {
    "temperature": {"value": 68.4, "unit": "degC"},
    "vibrationRms": {"value": 3.2, "unit": "mm/s"}
  },
  "quality": "good",
  "sequence": 18422
}

The timestamp should have a defined meaning. It may be the measurement time at the device, the gateway receipt time, or the cloud ingestion time. These are not interchangeable. Devices should use synchronized clocks where possible, but systems should also tolerate clock drift and preserve receipt time for auditing.

Important message categories are:

CategoryMeaningExample
TelemetryA measurement or observationTemperature = 68.4 °C
StateCurrent reported conditionValve = open
Desired stateRequested configuration or conditionSampling interval = 30 s
CommandAn instruction to perform an actionStart pump
EventA notable occurrenceOver-temperature alarm
MetadataDescriptive contextLocation, model, firmware

Commands require more control than telemetry. A command model should include a command identifier, target, creation time, expiry time, parameters, issuer, correlation identifier, and outcome. Outcomes such as accepted, rejected, expired, executed, or failed should be reported. For safety-critical actions, authorisation, interlocks, confirmation, and an audit record are required.

Data schemas should be versioned. Adding an optional field is usually less disruptive than changing the meaning or unit of an existing field. Units should be explicit; the number 68.4 without a unit is not reliable engineering data. Schemas should also define ranges, precision, null behaviour, and quality flags.

4. Communication Protocols and Gateways

MQTT is a lightweight publish–subscribe protocol widely used in IoT. Devices publish messages to topics, and subscribers receive messages through a broker. MQTT supports quality-of-service levels, retained messages, session behaviour, and a last-will mechanism. Topic names should be governed rather than improvised; a pattern such as site/line/device/telemetry can support routing, access control, and operations.

HTTP and REST APIs use request–response interactions and are widely supported by enterprise software. They are useful for provisioning, configuration, querying historical records, and integration with business systems. CoAP offers a constrained-device alternative with a REST-like model, while industrial environments may use protocols such as Modbus, OPC UA, or CAN-based interfaces.

Protocol selection should consider payload size, connection behaviour, reliability, security, power consumption, interoperability, and operational skills. No protocol is universally best.

A gateway connects networks or protocols and may provide:

  • address and protocol translation;
  • message filtering and aggregation;
  • local authentication and access control;
  • buffering during cloud outages;
  • conversion of industrial data into a common model;
  • local rules and alarms; and
  • secure routing between zones.

A gateway should not silently change measurements or discard data without recording the action. Translation mappings, time conversions, scaling factors, and error handling must be documented and tested.

5. Cloud IoT Platforms, APIs, and Databases

A cloud IoT platform commonly provides a message broker, device registry, authentication, rule engine, digital-twin or device-shadow service, stream processing, storage integration, monitoring, and management APIs. These services separate device connectivity from application development.

A platform API may expose operations to register a device, retrieve its reported state, update desired state, send a command, query telemetry, or obtain audit information. API design should use authentication, authorisation, input validation, rate limits, pagination, idempotency where appropriate, and documented error codes.

A device shadow is a cloud representation of device state. It commonly distinguishes reported state from desired state. This distinction is important when a device is offline: the cloud can store the desired configuration and reconcile it when the device reconnects. A shadow is not automatically proof that the physical device has applied the setting; confirmation must be reported by the device.

Different databases serve different purposes:

Database typeSuitable useMain consideration
Time-series databaseMeasurements indexed by timeRetention, downsampling, query windows
Relational databaseAssets, users, work orders, transactionsConsistency and relationships
Document databaseFlexible device or configuration documentsSchema governance
Object storageRaw files, logs, long-term archivesLow-cost durable storage
Graph databaseRelationships among assets and dependenciesRelationship queries

Storage design must address retention and cost. Raw high-frequency telemetry may be retained for a short period, while aggregates and important events are retained longer. Aggregation must not remove information needed for safety, compliance, or diagnosis.

For a stream of measurements, an arithmetic mean over n values x₁, x₂, …, xₙ is:

x̄ = (1/n) ∑ᵢ₌₁ⁿ xᵢ

Here x̄ is the mean in the same unit as each xᵢ, and n is the number of valid observations. This formula assumes that the observations are appropriately selected and that missing or invalid values have been handled. A mean can hide peaks; therefore maximum, minimum, percentile, count, and quality indicators may also be required.

6. Edge Processing and Edge–Cloud Workflows

Edge computing places computation near the data source. It is valuable when latency, connectivity, privacy, bandwidth, or autonomy matters. Cloud computing is valuable for fleet-wide comparison, large-scale analytics, central governance, and integration with enterprise systems.

Typical edge functions include threshold rules, signal filtering, anomaly detection, local dashboards, protocol conversion, buffering, and closed-loop control. Cloud functions include historical analysis, model training, cross-site benchmarking, digital-twin management, reporting, and long-term policy management.

A robust workflow often follows this pattern:

  1. The device measures a variable and adds a sequence number.
  2. The edge node validates the message and checks its quality.
  3. A local rule detects an unsafe condition.
  4. The edge node performs the immediate control action.
  5. The event and relevant telemetry are buffered and sent to the cloud.
  6. The cloud stores the data, updates the asset record, and notifies authorised personnel.
  7. A cloud policy or maintenance decision is returned to the edge.
  8. The edge acknowledges application of the policy.

Latency can be considered as a budget. If total response time is the sum of sensing, processing, communication, actuation, and verification delays, then:

Ttotal = Tsense + Tedge + Tnetwork + Tactuate + Tverify

Each term is a time, usually measured in milliseconds or seconds. The expression is an engineering decomposition, not a guarantee: queueing, retries, contention, and failures can make delays variable. A safety function should be allocated to a location that meets its worst-case response requirement, not merely its average latency.

Bandwidth planning also matters. If a device sends b bytes per message at frequency f messages per second, the payload rate is:

Rpayload = 8bf

where R_payload is in bits per second when b is in bytes and f is in messages per second. Protocol headers, encryption overhead, retransmissions, and network framing make actual rate greater than this payload estimate. For example, 100 devices sending 200-byte messages every 10 seconds produce 100 × 200 ÷ 10 = 2,000 bytes/s, or 16,000 bits/s of payload, before overhead.

Edge filtering can reduce bandwidth, but filtering rules must preserve information needed by operators and analysts. A common approach is to transmit every alarm and periodic summaries while retaining raw data locally for a defined period.

7. Reliability, Security, and Observability

IoT reliability involves more than message delivery. It includes correct measurement, ordering, duplication handling, command safety, recovery, and visibility into failures.

Design practices include:

  • use sequence numbers and timestamps;
  • make processing idempotent where duplicate messages are possible;
  • use acknowledgements for important commands;
  • apply retry limits and exponential backoff;
  • buffer data during temporary disconnection;
  • define maximum buffer duration and overflow behaviour;
  • monitor last-seen time, message rates, error rates, and battery status; and
  • test recovery after power loss, network loss, and corrupted messages.

“Exactly once” processing is difficult across distributed systems. Many practical systems use at-least-once delivery and deduplicate messages using a unique event identifier. A command such as “increase setpoint by 1” is not naturally idempotent, whereas “set setpoint to 25 °C” can be made idempotent if repeated execution has the same intended result.

Security should be layered. Devices need secure boot, protected credentials, least-privilege permissions, encrypted communication, signed firmware, vulnerability management, and secure decommissioning. Gateways should be segmented from ordinary office networks. Cloud resources should use role-based access control, key management, logging, and network policies.

Observability combines logs, metrics, traces, and domain signals. A dashboard should show not only temperature but also whether the device is online, whether data is stale, whether the clock is valid, and whether a command was applied. Operational teams need alerts that are actionable rather than excessively noisy.

8. Applied Case: Cold-Chain Monitoring

The following is an illustrative case. A food distributor operates refrigerated vehicles carrying perishable products. Each vehicle contains temperature sensors, a door sensor, a GPS receiver, and a cellular gateway.

Background and problem. Existing monitoring uploads temperature every fifteen minutes. Drivers and supervisors learn about a serious temperature excursion too late. Connectivity is intermittent in rural areas, and the organisation must demonstrate compliance with food-safety procedures.

Analysis. Temperature protection has a local operational requirement, while fleet reporting and compliance analysis are cloud requirements. The design must distinguish sensor time from cloud receipt time, preserve evidence during outages, and prevent unauthorised commands. A simple average temperature is insufficient because short high-temperature peaks may be important.

Approach. Each sensor has a unique identity and certificate. The gateway validates readings, checks the sensor range, adds a sequence number, and stores messages locally. An edge rule generates an alarm when temperature exceeds the configured limit for a defined persistence period, or when the door remains open unusually long. The gateway can alert the driver locally and control an approved refrigeration response, subject to vehicle safety interlocks.

The gateway publishes telemetry and events through a secure MQTT connection. The cloud platform stores raw readings in a time-series database, vehicle and shipment information in a relational database, and signed compliance reports in object storage. A dashboard displays current temperature, alarm status, vehicle position, communication health, and command history. The cloud application sends configuration changes as desired state; the gateway acknowledges the applied configuration.

Outcome. Local alarms continue during cellular outages. When connectivity returns, buffered records are uploaded with their original measurement timestamps and sequence numbers. Supervisors receive a consolidated event history, and analysts can compare routes, vehicle performance, and refrigeration maintenance indicators.

Learning points. The case demonstrates that edge processing is not merely a faster cloud connection. It provides autonomy and immediate action. It also demonstrates the importance of data provenance, command acknowledgement, schema design, security, and separate storage choices for different workloads.

9. Professional Design Method

A practical design can be developed through the following sequence:

  1. Define operational outcomes. State what must be monitored, controlled, predicted, or audited.
  2. Classify data and actions. Separate telemetry, events, state, commands, personal data, and safety functions.
  3. Set requirements. Specify latency, availability, retention, bandwidth, accuracy, security, and recovery targets.
  4. Allocate functions. Place safety and low-latency functions at the device or edge; place fleet analytics and long-term storage in the cloud.
  5. Define identities and schemas. Establish naming, units, timestamps, versions, permissions, and lifecycle states.
  6. Select protocols and services. Choose based on constraints rather than popularity.
  7. Design failure behaviour. Decide what happens during disconnection, duplicate delivery, stale data, invalid commands, and power loss.
  8. Implement observability. Define health metrics, logs, alarms, and audit records before deployment.
  9. Test progressively. Conduct unit, integration, security, load, field, failover, and recovery tests.
  10. Operate and improve. Monitor performance, rotate credentials, patch software, review schemas, and retire assets securely.

10. Challenges, Governance, and Contemporary Developments

Interoperability remains difficult because vendors use different data models, naming systems, and interpretations of state. Standards and semantic models reduce this problem, but integration still requires testing. Vendor lock-in can arise when device identities, message formats, analytics, and storage are tightly coupled to one provider. Portable schemas, export procedures, and documented APIs reduce migration risk.

Privacy is relevant even when devices appear industrial. Location, occupancy, work patterns, and inferred behaviour may identify individuals. Data minimisation, purpose limitation, access control, retention limits, and transparent notices should be applied. Regulations may impose requirements for security, safety, records, or personal data depending on jurisdiction and sector.

Artificial intelligence is increasingly used for anomaly detection, predictive maintenance, and adaptive control. Models should not be deployed merely because data is available. Training data quality, drift, false alarms, explainability, human oversight, and safe fallback behaviour must be evaluated. A cloud model should never bypass a local safety interlock. Edge AI can reduce latency and protect sensitive data, but it introduces model update and resource-management challenges.

Digital twins are evolving from simple state replicas into models linking assets, relationships, events, and operational context. Digital twins are useful only when their identity mappings, update semantics, and data quality are governed. A visually impressive twin with stale or ambiguous data can mislead decision-makers.

Best Practices Checklist

  • Give every device a unique identity and its own credentials.
  • Use mutual authentication and encrypted transport.
  • Define schemas, units, timestamps, quality flags, and versions.
  • Separate reported state from desired state.
  • Design commands with expiry, authorisation, acknowledgement, and auditability.
  • Keep safety-critical control local and fail-safe.
  • Buffer data and define behaviour during outages.
  • Use appropriate databases for time-series, transactional, document, and archival needs.
  • Monitor both business signals and system health.
  • Protect privacy and minimise collected data.
  • Plan firmware updates, credential rotation, and secure retirement.
  • Test failure modes rather than only normal operation.

Chapter Summary

Device-to-cloud and edge integration connects physical processes with software services across a distributed architecture. Devices provide measurements and actions; gateways translate and buffer; edge nodes provide local rules, analytics, and control; cloud platforms provide scalable ingestion, storage, management, and fleet-wide analysis; applications support users and enterprise decisions.

Secure provisioning establishes identity, credentials, configuration, and lifecycle control. Well-designed data models distinguish telemetry, state, desired state, commands, events, and metadata. Protocols such as MQTT and HTTP serve different communication patterns, while gateways provide translation and local resilience. Cloud databases should be selected according to workload rather than used indiscriminately.

Edge–cloud design is an allocation problem. Low-latency, safety-sensitive, privacy-sensitive, or connectivity-dependent functions generally belong near the device. Long-term analytics, cross-site comparison, governance, and large-scale storage generally belong in the cloud. Reliability requires sequence numbers, timestamps, buffering, retries, deduplication, acknowledgements, and explicit failure behaviour. Security, observability, privacy, lifecycle management, and responsible AI are integral engineering concerns.

Key Terms

Device provisioning: Preparing a device with identity, credentials, configuration, and registration.

Device identity: A unique identifier used to recognise and authorise a device.

Telemetry: Measurements or observations transmitted by a device.

State: The currently reported condition of a device or asset.

Desired state: A requested condition or configuration maintained for reconciliation.

Command: An instruction requiring an action by a device or actuator.

Event: A notable occurrence, often requiring attention or workflow.

Gateway: A system that connects networks or protocols and may buffer or filter data.

Edge computing: Processing performed near the data source.

Cloud IoT platform: Managed services for IoT connectivity, security, device management, and data processing.

MQTT: A lightweight publish–subscribe messaging protocol commonly used in IoT.

API: An interface through which software systems exchange operations and data.

Time-series database: A database optimised for records indexed by time.

Device shadow: A cloud representation of reported and desired device state.

Idempotency: The property that repeating an operation produces the same intended result.

Digital twin: A data-linked representation of a physical asset or process.

Store-and-forward: Temporarily storing data locally and transmitting it when connectivity returns.

Data provenance: Information about the origin, timing, transformation, and custody of data.

Least privilege: Giving an identity only the permissions required for its task.

Secure boot: Starting software only after verifying its trust or digital signature.

Review Questions

Short Answer Questions

  1. What are the main responsibilities of an IoT gateway?
  2. Distinguish telemetry from a command.
  3. Why should a device identity be independent of its network address?
  4. What is the purpose of a device shadow?
  5. State two reasons for processing data at the edge.

Long Answer Questions

  1. Explain a secure device-provisioning lifecycle from manufacturing through decommissioning.
  2. Compare MQTT and HTTP for IoT communication, including suitable use cases and limitations.
  3. Explain how reported state, desired state, commands, and acknowledgements should work together.
  4. Describe a reliable edge–cloud workflow for monitoring and controlling an industrial asset.
  5. Discuss database selection for telemetry, asset records, configuration documents, and long-term archives.

Analytical / Application Questions

  1. A factory must stop a machine within 200 ms of detecting a dangerous condition, but its cloud connection is unreliable. Design the device, edge, and cloud responsibilities and justify your allocation.
  2. One thousand devices send 500-byte messages every 20 seconds. Calculate the payload bandwidth before protocol overhead, then identify at least three factors that could increase the required network capacity.
  3. Design a command model for remotely changing a refrigeration setpoint. Specify identity, authorisation, expiry, acknowledgement, failure handling, and audit information.

Multiple Choice Questions with Answers

Question 1

Which function is most appropriately assigned to an edge node when immediate response is required?

A. Long-term fleet benchmarking

B. Local safety threshold control

C. Annual compliance archiving

D. Cross-region model training

Correct Answer: B. Local safety threshold control

Question 2

What does a device shadow commonly distinguish?

A. Raw voltage from current

B. Manufacturing cost from selling price

C. Reported state from desired state

D. Gateway traffic from radio traffic

Correct Answer: C. Reported state from desired state

Question 3

Which characteristic is essential for a secure device identity?

A. It is shared by all devices of one model

B. It changes whenever the device changes networks

C. It is unique and linked to controlled credentials

D. It is based only on the device location

Correct Answer: C. It is unique and linked to controlled credentials

Question 4

A device sends 200-byte messages every 10 seconds. Ignoring overhead, what is the payload rate?

A. 20 bytes/s

B. 200 bytes/s

C. 2,000 bytes/s

D. 20,000 bytes/s

Correct Answer: A. 20 bytes/s

Question 5

Which database is generally most suitable for measurements indexed by time?

A. Time-series database

B. Relational database only

C. Graph database only

D. Source-code repository

Correct Answer: A. Time-series database

Question 6

Why are sequence numbers useful in IoT telemetry?

A. They encrypt the message payload

B. They help detect duplicates and missing messages

C. They replace device authentication

D. They increase sensor accuracy

Correct Answer: B. They help detect duplicates and missing messages

Question 7

Which command is more naturally idempotent?

A. Increase speed by 5 rpm

B. Toggle the relay

C. Set speed to 1,000 rpm

D. Add one unit to the counter

Correct Answer: C. Set speed to 1,000 rpm

Question 8

What is store-and-forward behaviour?

A. Deleting data when the network fails

B. Storing data locally until connectivity returns

C. Forwarding every command to every device

D. Replacing encryption with compression

Correct Answer: B. Storing data locally until connectivity returns

Question 9

Which practice best protects against unauthorised firmware modification?

A. Using longer topic names

B. Signed firmware and secure boot

C. Increasing telemetry frequency

D. Removing device identifiers

Correct Answer: B. Signed firmware and secure boot

Question 10

In the latency expression T_total = T_sense + T_edge + T_network + T_actuate + T_verify, what does T_network represent?

A. Sensor calibration error

B. Time used for communication across the network

C. Time required to archive data

D. The number of network devices

Correct Answer: B. Time used for communication across the network

Embedded Systems for IoT
Chapter 10 of 15