90. IoT solution architecture
The device is only the first link. This section assembles the links from sections 37 and 86–94 into a system: - which levels a solution consists of; - where it is better to process the data; - what each message costs; - how to describe a solution so that it can be built and maintained.
Checked with a model: one day of warehouse temperature under different sending rules — in portable C and, independently, in Python.
Terms used in the documentation
Term Meaning Internet of Things (IoT), machine-to-machine (M2M) connected devices on a shared platform; direct links between machines reference model a standard split of a solution into levels edge computing, fog computing processing on the device; processing on the gateway report by exception, deadband send only on change; the change threshold that is ignored heartbeat a periodic "I am alive" message LPWAN, energy per bit low-power wide-area networks; energy spent per transmitted bit data flow what data moves where, and how often high-level design (HLD) the top-level design document of a solution service level agreement (SLA) the agreed level of service
90.1 M2M and the Internet of Things
| M2M | Internet of Things | |
|---|---|---|
| link | machine to machine, point to point: modem and SMS, Modbus, a direct channel to the control room | many devices through a shared platform |
| data | for one task | for many applications at once |
| network | usually closed | the internet and the cloud |
| scale | tens of devices | thousands and millions |
| protocols | often proprietary | open: MQTT, LoRaWAN, CoAP |
M2M does not go away — machines still talk to machines — but a platform appears around them. The device's data becomes shared: the same temperature readings go to alarms, reports and energy accounting.
This comes at a price: - security of millions of devices; - updating their firmware; - the cost of a bug in a program that runs at thousands of sites at once; - the lack of a single standard.
All of these are architecture tasks, not tasks of an individual device.
90.2 The seven levels of the reference model
The reference model splits a solution into levels, each with its own task and its own owner. A level can be replaced without touching the others:
| Level | What it is | Where in the handbook |
|---|---|---|
| 1. Devices and controllers | sensors, microcontroller, radio module | sections 8–22, 81, 93 |
| 2. Connectivity | wires, radio and protocols: LoRaWAN, MQTT, CoAP, Ethernet, cellular | 37, 86, 89, 94 |
| 3. Edge computing | filtering, compression, alarms — on the device or the gateway | 90.4 |
| 4. Data accumulation | databases and queues — like PostgreSQL and Redis on the test bench of section 94 | 87, 94 |
| 5. Data abstraction | bringing data to a common form, decoders, programming interfaces | 88, 94 |
| 6. Applications | reports, analytics, control | 91 |
| 7. People and processes | who makes decisions and how, procedures, maintenance | 90.7 |
The model is useful in the argument "whose task is this". If the device sends raw data every second, the work of level 3 has been pushed onto levels 4–6. The price is paid in airtime, battery and storage.
90.3 LPWAN: range at the cost of speed
Low-power wide-area networks are built on a simple relation. Energy per bit is power divided by data rate. Half the data rate at the same power means twice the energy for every bit, that is +3 dB, and in free space a range of ×1.41. This is exactly how SF works in LoRa (section 93).
The second lever is frequency. Path loss grows with frequency:
| Comparison | Difference | Range in free space |
|---|---|---|
| 433 MHz vs 868 MHz | 6.0 dB better | ×2.0, but a quarter-wave whip is 17.3 cm instead of 8.6 |
| 2.4 GHz vs 868 MHz | 8.8 dB worse | 2.8 times shorter |
| 5.8 GHz vs 868 MHz | 16.5 dB worse | 6.7 times shorter |
That is why LPWAN lives below 1 GHz. The 2.4 GHz band is used because it is allowed worldwide, but the range there is shorter. The 5.8 GHz band does not suit LPWAN: it has no place in the lists of licence-free bands for them.
Licence-free does not mean free of conditions. LoRaWAN and Sigfox work in licence-free bands. Anyone may transmit there, hence interference and rules such as 1 % of airtime (section 89). NB-IoT and LTE-M are also LPWAN, but in licensed bands: the operator is responsible for the network, and you pay a subscription fee.
| LPWAN strengths | Weaknesses |
|---|---|
| kilometres of range | low throughput |
| years on a battery | latency: a command waits until the device comes on air (section 94.6) |
| the signal reaches basements and manholes | no single standard |
| thousands of devices per gateway | interference in licence-free bands |
90.4 Where to compute: at the edge or in the cloud
A temperature sensor measures once a second. Sending every measurement means 86400 messages a day. The frame of such a device is 15 bytes (90.5), and at SF7 that is 4003 s of airtime, 4.6 % of the time instead of the allowed 1 %. In LPWAN this is simply not allowed, and in any other network it is a waste: almost every message says "nothing has changed".
The device decides, level 3. Two rules:
struct edge {
int32_t deadband; /* порог изменения, в сотых долях */
uint32_t heartbeat; /* контрольная посылка не реже, с */
int32_t last; /* последнее отправленное значение */
uint32_t last_time; /* когда оно ушло, с */
int started;
};
/* 1 — отправлять: значение отошло от отправленного на порог и больше или
* давно ничего не уходило. Иначе прибор молчит, а получатель считает, что
* значение — последнее присланное. */
int edge_should_send(struct edge *e, int32_t value, uint32_t now)
{
int32_t d = value - e->last;
if (e->started && d < e->deadband && -d < e->deadband && now - e->last_time < e->heartbeat)
return 0;
e->last = value;
e->last_time = now;
e->started = 1;
return 1;
}
The third rule is a summary over a window: minimum, maximum and mean over 15 minutes. It needs no array of samples: minimum, maximum, sum and counter take 24 bytes including alignment.
Model. One day in a warehouse: - 18 °C at night, 24 °C at noon; - sensor noise ±0.10 °C; - at 14:00:30 the gate was opened, and for 10 minutes the temperature dropped by 4 °C.
| Rule | Messages per day | Worst hour | Receiver error | Gate noticed after |
|---|---|---|---|---|
| every second | 86400 | 3600 | 0 | 0 s |
| on a change of 0.5 °C, heartbeat every 15 minutes | 98 | 6 | up to 0.33 °C | 0 s |
| on a change of 0.2 °C, heartbeat every 15 minutes | 285 | 29 | up to 0.19 °C | 0 s |
| summary every 15 minutes | 96 | 4 | — | 869 s |
Report by exception sends as rarely as the summary, but notices the event in the same second. The receiver error is always below the threshold — the rule itself keeps the accuracy. The summary will see the dip, its minimum is 18.81 °C, but only after 14.5 minutes.
A threshold of 0.2 °C lies too close to the ±0.10 °C noise. The noise itself crosses the threshold, and there are three times as many messages. In the worst hour there are 29. At SF12 a 15-byte frame takes 1.155 s, and 1 % of airtime allows 31 messages per hour: 29 still fit, but with no margin — a little more noise, and at the edge of coverage the device will break the rules. Filter the noise first (section 81), then choose the threshold.
⚠️ A heartbeat is mandatory. Without it the device's silence cannot be interpreted: is the temperature stable or is the device dead. With a heartbeat every 15 minutes, a longer silence is already an alarm.
The second place for edge computing is the gateway, fog computing. It sees many devices at once and can combine their data. It can run local rules and keep working when the internet is gone. The cloud remains for history, analysis across many devices and training models (section 85).
90.5 What a message costs: the battery
Assume 40 mA when transmitting, 2 µA in sleep, a 2400 mAh battery and 10 bytes of data in a LoRaWAN frame (section 89). Receive windows are not counted:
| Rule | Messages per day | SF7 | SF12 |
|---|---|---|---|
| once a minute | 1440 | 6.4 years | 101 days |
| on a change of 0.2 °C | 285 | decades | 1.4 years |
| on a change of 0.5 °C | 98 | decades | 4.0 years |
| summary every 15 minutes | 96 | decades | 4.0 years |
"Decades" means the battery will die of self-discharge first. What matters most for service life is how many times the device goes on air and at which SF. A sending rule on the device pays off directly. Temperature in hundredths of a degree is 2 bytes of data plus 13 bytes of overhead, 15 bytes per message in total (section 94.8). The table is calculated with a margin, for 10 bytes of data, as in section 89; with a 15-byte frame the lifetimes are a quarter to a third longer: once a minute — 8.3 years at SF7 and about 130 days at SF12.
90.6 Requirements that change the architecture
| Requirement | What it means for the device |
|---|---|
| scalability | thousands of devices without configuring each by hand: over-the-air activation (section 94.3), retries with jitter (section 88.6) |
| big data | send meaning, not raw data (90.4); a binary format instead of text |
| clouds | do not tie yourself to one server: address by name, settings updated over the air |
| real time | LoRaWAN class A is not for control: a command waits for the device to come on air, so fast loops are closed locally |
| distribution | any link may fail: the device buffers data while there is no connection and sends it later |
| heterogeneity | different radios and protocols are brought to a common form on the gateway or the platform (level 5) |
| security | keys (section 94.3), channel encryption (section 37.4), firmware protection (sections 43 and 77.9), updates (section 48) |
| regulatory compliance | frequency rules — airtime share and power; personal data law if the device is linked to people |
| integration | a clear programming interface and external formats (section 88) |
90.7 How to describe a solution: the high-level design
A high-level design (HLD) is the document by which a solution is built, accepted and maintained. A typical structure:
| Document section | What it contains |
|---|---|
| purpose, terms, related documents | why the system exists and what was agreed |
| problem statement | what must work and for whom |
| functions | a list of capabilities |
| solution diagram | components by level and the links between them |
| resource requirements | servers, networks, licences |
| backup | what is backed up, how often, what happens on failure |
| costs | one-off and monthly |
| work stages | survey, installation, commissioning, acceptance, operation, each with an owner and effort |
| monitoring and SLA | what is checked, how often, what counts as a failure, how quickly it is restored |
For a solution with devices it must also contain five more things:
- data flows — what, from where, to where, how often and how many bytes. An example line: "warehouse temperature → on a change of 0.5 °C and every 15 minutes → LoRaWAN, 15 bytes → network server → MQTT → database → alarm to the operator";
- radio plan — frequencies, SF, where the gateways stand, the results of the radio site survey (section 92);
- power budget — current in each mode and battery life (90.5);
- keys — where they are generated, where they are stored, how they are changed (section 94.3);
- failures — what the device does without a connection, without a server, after a reset, and how the firmware is updated (section 48).
90.8 Pitfalls
The device sends every second "just in case". Airtime and battery run out before the benefit shows up.
The device's silence cannot be interpreted. There is no heartbeat, and a dead device is indistinguishable from a steady temperature.
Threshold next to the noise. 0.2 °C with ±0.10 °C noise gives three times as many messages as 0.5 °C.
Summaries instead of events. The alarm arrives 15 minutes after the event.
Control over LoRaWAN class A as if it were real time. The command waits until the device comes on air by itself.
The device loses data when the link drops. There is no buffer where it stores readings until the channel is restored.
The solution is hard-wired to one cloud service. There is no external programming interface and no way out.
A design without data flows and without failure scenarios. Such a document can be neither verified nor maintained.
"LPWAN is free, no licence needed". In a licence-free band nobody is responsible for interference.
90.9 Summary
- The Internet of Things is M2M plus a platform. The device's data becomes shared by many applications.
- The reference model has seven levels: devices, connectivity, edge computing, accumulation, abstraction, applications, people and processes.
- LPWAN gains range through data rate (+3 dB for each doubling of energy per bit) and through frequency below 1 GHz. 5.8 GHz does not suit it.
- The device decides what to send. Report by exception at 0.5 °C with a heartbeat gives 98 messages a day instead of 86400, the event is noticed at once, the error is below the threshold.
- Battery life is set by the number of transmissions and the SF: from 101 days to decades with the same battery.
- The high-level design describes data flows, the radio plan, the power budget, keys and behaviour on failures.
Next: section 91 "IoT platforms".