Fundamentals · beginner

How does IoT work, from sensor to cloud?

Follow one sensor reading from a microcontroller through radio, gateway, protocol and platform to a dashboard, and the command that travels back.

A small white motion sensor in front of green foliage

Photo: User_Pascal / Unsplash

After reading this article you will be able to:

  • Follow a single reading from sensor and firmware through radio, gateway, protocol and platform to action
  • Explain why sampling rate, thresholds and deep sleep decide a battery-powered device's lifetime
  • Describe how a command travels back from an app to a relay on the device

Drafted with AI from primary sources · checked by a separate AI agent · spot-checked by our editors · How we check

On this page
  1. How does sensing turn physics into numbers?
  2. How does the device decide what to send?
  3. How does the first radio hop work?
  4. What does the gateway do?
  5. Which protocol talks to the platform?
  6. What happens at ingestion, storage and analysis?
  7. How is the loop closed?
  8. What does this journey tell you about design?
  9. Where to go next

The clearest way to understand an IoT system is to follow a single measurement from the moment a physical quantity changes to the moment someone acts on it. Every deployment, from a smart plug to a refinery, repeats the same journey.

Take a concrete example: a temperature sensor in a refrigerated storage room. The owner wants a text message if the room gets too warm, and wants to be able to switch a backup compressor on remotely. This guide traces that reading through each stage, names the components involved, and explains the decisions that are made at each hop.

The stages are: sense, process locally, transmit, aggregate at a gateway, deliver over a protocol, ingest into a platform, store and analyze, and act. The return path, from a command in the cloud to a relay on the device, runs the same stages in reverse.

One reading from sensor to cloud and the command back Top row, left to right: a sensor in a cold room is read by the microcontroller, firmware filters the reading and decides whether to send it, a radio hop and a gateway carry it to the internet, an MQTT broker delivers it on a topic, and the platform ingests, stores and evaluates it against a rule. Bottom row, right to left: the alert reaches the owner, the app sends a command through the platform API and a command topic, and the device firmware switches a relay and acknowledges. UPLINK: TELEMETRY Sense Thermistor or digital chip, read via ADC or I2C Firmware Filter, threshold, build the payload, deep sleep Radio, gateway Wi-Fi, Zigbee, Thread or LoRaWAN; buffers, translates Broker MQTT publish on a topic, over TLS, with QoS Platform Ingestion Time-series DB Rule engine Example topic: site/coldroom-1/temperature rule fires DOWNLINK: COMMAND Act SMS via webhook and dashboard; owner taps start backup compressor API, command topic The app calls the platform API, the broker delivers the command; the shadow holds it if asleep Device Firmware drives a relay through a GPIO pin and publishes an acknowledgment The command retraces the uplink in reverse; a sleeping device fetches it when it next wakes.
One cold-room reading end to end: firmware reads and filters the sensor, a radio hop and a gateway reach the internet, an MQTT broker delivers it to the platform, a rule fires an alert, and the command to start the backup compressor travels back the same way.

How does sensing turn physics into numbers?

A sensor is a transducer. A thermistor changes its electrical resistance with temperature; a digital temperature chip measures that internally and exposes a number on a serial bus. Either way the microcontroller on the device has to read it, through an analog-to-digital converter for an analog part or through a bus such as I2C or SPI for a digital one.

Two decisions are made here. The first is the sampling rate: how often to read. A fridge changes temperature slowly, so once a minute is plenty, and reading less often saves energy. The second is calibration and filtering: raw readings are noisy, so firmware typically averages several samples or discards outliers before reporting.

How does the device decide what to send?

The device’s firmware now has a number. It can send every reading, or it can be selective. Sending only when the value changes by more than a threshold, or only when it crosses an alarm limit, cuts radio traffic dramatically. On a battery-powered device the radio is the largest consumer of energy, so this step is where battery life is won or lost.

Between readings, a well-designed device goes into deep sleep, waking on a timer. The ratio of awake time to sleep time is the duty cycle, and a small duty cycle is what lets a sensor run for years on a coin cell.

The reading is packaged into a payload. For a constrained link that might be a few bytes in a compact binary format; for a Wi-Fi device it is often a small JSON object:

{"t": 4.8, "ts": 1760690400, "bat": 92}

How does the first radio hop work?

The device radio now sends the payload. Which radio depends on range, power and bandwidth needs, a trade-off covered in the connectivity overview. For a cold room inside a building, options include Wi-Fi directly to the site router, Zigbee or Thread to a nearby hub, or LoRaWAN to a gateway that may be on the roof of a different building.

Wi-Fi is power hungry but needs no extra hardware. Zigbee and Thread sip power but require a hub. LoRaWAN reaches far on tiny energy but moves only a few bytes at a time.

What does the gateway do?

Unless the device speaks IP natively over Wi-Fi, Ethernet or cellular, something has to translate between the local radio network and the internet. That something is the gateway. A smart home hub, a LoRaWAN gateway and an industrial edge gateway all play the same role: receive frames from many devices on one side, forward them as IP packets on the other.

Gateways often do more than forward: they buffer data when the uplink is down, convert protocols such as Modbus into MQTT, and run local rules so that an alarm still fires if the internet fails. This is where edge computing begins.

Which protocol talks to the platform?

Once there is an IP path, the device or gateway needs an application protocol to deliver the payload. The common choice for telemetry is MQTT. The device publishes its payload to a topic such as site/coldroom-1/temperature on a broker; anything interested subscribes to that topic. The publish-subscribe pattern means the device does not need to know who consumes its data, and the broker handles delivery guarantees through QoS levels.

For very constrained devices CoAP over UDP is lighter. Devices with plenty of resources sometimes just use HTTP. In every case the connection should be encrypted with TLS or DTLS, and the device should prove its identity with a certificate or token issued during provisioning.

What happens at ingestion, storage and analysis?

The IoT platform receives the message. Its first job is data ingestion: authenticate the sender, validate the payload, attach metadata such as which customer and location the device belongs to, and hand the record to the next stage.

Readings go into a time-series database, which is optimized for append-only data indexed by time. The platform may also keep a device shadow, a small document that records the last known state of each device so that applications can query it without waiting for the next report.

A rule engine or stream processing job evaluates each reading as it arrives. In our example the rule is simple: if temperature exceeds a limit for more than a few minutes, raise an alert. More complex rules combine several sensors, compare against historical baselines, or run a machine learning model for anomaly detection. The data pipeline guide covers these stages in depth.

How is the loop closed?

The alert rule fires. The platform sends a notification through a webhook to an SMS service, and the owner receives a text. A dashboard shows the trend so they can judge whether the problem is a door left open or a failing compressor.

The owner taps “start backup compressor” in an app. The command travels in reverse: the app calls the platform API, the platform publishes a message to the device’s command topic, the broker delivers it, and the device firmware drives a relay through a GPIO pin. The device publishes an acknowledgment so the shadow and the app reflect the new state.

A device that sleeps most of the time cannot receive a command until it next wakes, so the command waits in the shadow until the device fetches it.

What does this journey tell you about design?

Each stage has a failure mode. Sensors drift. Radios lose packets and devices must retry without flooding the network. Gateways go offline and need buffering. Brokers need to scale. Rules need thresholds that avoid both missed alarms and alert fatigue.

Good IoT engineering is mostly about anticipating these failures. The questions worth asking for any new deployment are: what happens when this link is down for an hour, how does the device know its data was received, and how will the firmware be fixed once a thousand units are in the field. The last one is the subject of device management and OTA updates.

Where to go next

Corrections and updates
  • October 22, 2026: diagram added

How corrections are handled: editorial policy.

Topics: IoT basics, architecture, telemetry, fundamentals

Diagram