Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 36 ยท Getting Started

IoT Architecture and Layers

Understand the layered architecture of an IoT system, from perception and network layers to cloud and application, with a runnable gateway simulation.

An IoT system is never a single box. Even a smart light bulb involves firmware on the bulb, a radio link, a hub or router, a cloud service and a phone app. To reason about such systems, engineers split them into layers, each with one job. If you know which layer a problem belongs to, you know where to look and what to change.

This lesson walks through the common layered model, shows where gateways and the edge fit, and then simulates data climbing through the layers.

The layered model

Several models exist (three, four, five and seven layers). The four-layer version below is the most practical for building things.

flowchart TB
    A["Application layer<br/>dashboards, mobile apps, alerts"]
    B["Platform / cloud layer<br/>ingestion, storage, analytics, rules"]
    C["Network layer<br/>Wi-Fi, BLE, LoRaWAN, cellular, gateways"]
    D["Perception layer<br/>sensors, actuators, microcontrollers"]
    D --> C --> B --> A
    A -. commands .-> B -. commands .-> C -. commands .-> D

Data climbs from the perception layer to applications; commands travel back down.

Layer Job Example parts
Perception (devices) Measure and act on the physical world Temperature sensor, relay, ESP32
Network (connectivity) Carry bytes reliably and cheaply Wi-Fi, LoRa, NB-IoT, gateway
Platform (cloud) Receive, store, process, manage devices Message broker, database, rules engine
Application Give value to people Web dashboard, phone app, alarm email

Some diagrams add a security plane that cuts across all four layers, because every layer needs identity, encryption and updates. Security gets its own chapter later in the course.

The perception layer

This is where physics meets code. A temperature sensor produces a voltage or a digital number, and a microcontroller turns that into a value such as 21.4. Devices here are usually constrained: kilobytes of RAM, a coin cell or small battery, and no screen. Constraints shape every decision, from which protocol to use to how often you wake up.

The network layer and gateways

Not every device can talk to the internet directly. A Zigbee light switch has a low-power radio but no IP stack for the wider internet. A gateway (or hub) translates between the local network and the internet. A gateway may:

  • Convert protocols (for example BLE to MQTT, or LoRa to HTTPS).
  • Buffer data when the uplink is down.
  • Filter, aggregate or reject data before it leaves the site.
  • Run local rules so that a light still turns on when the internet is out.

The platform layer

The platform receives millions of messages and must make sense of them. Typical responsibilities: authenticate devices, route messages, store time series, evaluate rules ("alert if the freezer is above -15 C for 10 minutes"), keep a device shadow (the last known state of each device) and roll out firmware updates.

The application layer

Applications turn data into decisions: a farmer's moisture map, a building manager's energy report, a maintenance alert on a technician's phone. This layer is closest to users, so it needs good design more than clever protocols.

Edge, fog and cloud

Where should the computing happen? There is a spectrum:

  • Device edge: the microcontroller itself, instant and offline-capable but tiny.
  • Edge gateway (fog): a small server near the devices, handling filtering and local control.
  • Cloud: unlimited storage and analytics, but with latency, cost and a dependency on connectivity.

A safety rule such as "shut the valve if pressure is too high" belongs at the device edge, because it must work even if the network is gone. Long-term trend analysis belongs in the cloud.

Simulating data through the layers

The simulation below models three layers in plain Python. The device produces readings, the gateway validates and batches them, and the "cloud" computes statistics. The point is the structure, not the details.

Python Device, gateway and cloud pipeline (simulation)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Batching reduces radio time, which saves battery, at the price of delay. That trade-off appears everywhere in IoT.

A command travelling down

Control flows in the opposite direction. The app says "set the target to 21", the platform stores it and forwards it, the gateway delivers it, and the device applies it. Because devices may be offline, platforms store the desired state and the device later reports its reported state; when they differ, the platform knows the command is still pending.

Python Desired vs reported state (device shadow idea)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real platforms (AWS IoT Device Shadow, Azure Device Twin) implement exactly this idea with versions and timestamps.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In the four-layer model, which layer contains sensors, actuators and microcontrollers?

    The perception layer is where devices touch the physical world.
  2. 2. What is the main job of an IoT gateway?

    Gateways connect constrained local radios to the wider network and can filter, translate and buffer.
  3. 3. Where should an emergency "close the valve if pressure is too high" rule run?

    Safety logic must not depend on connectivity or cloud latency.
  4. 4. What does a device shadow store?

    Desired versus reported state lets the platform track commands for devices that are offline.

Summary

  • IoT systems are layered: perception, network, platform, application, with security across all.
  • Gateways bridge local radios to the internet and can buffer, filter and translate.
  • Edge computing keeps fast and safety-critical decisions close to the device; the cloud handles scale and analytics.
  • Device shadows track desired versus reported state for devices that are sometimes offline.

Next: IoT Applications and Industries