Download PDF · Cloudnix: Iot And Embedded Systems
Connected systems rarely fail because of the sensor. They fail in the space between the device and the decision: an alert nobody trusts, a command nobody can confirm, a reader that loses signal at the exact place the work happens, or a tap that is accepted without checking who made it. This paper describes the patterns we use to close that space, drawn from systems we have designed, built and operated: environmental and cold-chain monitoring, remote control of pumps and valves, NFC authentication for people, documents and products, fleet and fuel capture, and process calculations in a foundry.
The chapters that follow go from architecture to protocol, device lifecycle, control, alerting, two domain patterns (water level, NFC), offline capture, compliance, security and operations, followed by an anonymised case study, a roadmap and a checklist.
| Failure mode | What it looks like | Pattern that addresses it |
|---|---|---|
| Alert floods | A drifting sensor alerts on every reading; within a day alerts are muted. | Safe bands with excursion tracking (ch. 7) |
| Unconfirmed commands | The screen says “off”; nobody knows whether the pump heard it. | Command queue with device confirmation (ch. 6) |
| Connectivity gaps | Readers and devices lose signal where the work happens. | Offline-first capture and sync (ch. 10) |
| Unverifiable identity | A card is accepted without checking validity or context. | NFC validation chain (ch. 9) |
| Data without evidence | Readings exist but cannot be produced cleanly for an audit. | Event logging and scheduled reports (ch. 7, 14) |
| Silent devices | A dead sensor looks like a healthy one reporting nothing unusual. | Device registry, last-seen and online window (ch. 5) |
Every system in this paper follows the same five-layer shape. Keeping the layers distinct is what lets a temperature sensor, a pump controller and an NFC reader share one platform without sharing failure modes.
| Layer | Owns | Never does |
|---|---|---|
| Devices | Sensing, actuation, local safety interlocks | Decide who gets alerted |
| Connectivity | Framing, confirmation, delivery, connection health | Business rules |
| Data | Durable record of every reading, command and tap | Silent overwrites; every change is appended or audited |
| Logic | Bands, alert state, command lifecycle, compliance rules | Talk to devices directly; it goes through connectivity |
| Experience | Views and actions by role | Assume a command succeeded before confirmation |
A typical deployment runs the connection service and the web platform on separate processes on the same or separate servers, with a relational database for registry, readings and queues, scheduled jobs for alerts and reports, and a mobile sync API for phone readers. Device traffic arrives on a dedicated port; the web panel is served separately over HTTPS. Backups, monitoring and patching are part of the deployment, not an afterthought (chapter 14).
Low-cost controllers have little memory and intermittent links. The protocol we use for always-connected devices is deliberately small [1, 7]: a persistent TCP connection, one message per line, and comma-separated key:value pairs. Every inbound line gets a reply on the same connection, and the same connection carries commands down.
| Direction | Message | Fields | Reply |
|---|---|---|---|
| Device → platform | Reading | device id, parameter, value | status OK, or ERROR with reason |
| Platform → device | Command | device id, action, response id | device sends a confirmation |
| Device → platform | Confirmation | response id, status | command marked confirmed |
| Either | Close | — | connection closed cleanly |
# a session, as seen on the wire
device → es_id:7,parameter:temperature,parameter_value:9.4
platform → status:OK,message:Saved
device → es_id:3,parameter:level,parameter_value:18
platform → status:OK,message:Saved
platform → es_id:12,action:PUMP_START,response_id:912
device → response_id:912,status:OKExample exchange or schema.
Storage-layer failures are translated into messages firmware can act on, rather than generic errors: an unknown device identity (the device is not registered), or a duplicate reading. A device receiving “unknown device” should stop sending and signal for provisioning, instead of retrying forever.
A single process multiplexes all device connections with an event loop (a select-style wait with a short timeout). On each pass it reads complete lines from devices that sent data, writes replies, and checks the command queue for work to deliver. This keeps memory per connection tiny and needs no threads; for larger fleets the same design scales out by sharding devices across several connection services behind a TCP load balancer.
| Option | Best when | Trade-offs |
|---|---|---|
| Persistent TCP, line protocol | Mains-powered controllers that must take commands quickly | Simple and fast; needs TLS and device credentials added for public networks |
| MQTT [1] | Many devices, publish/subscribe, brokers already in place | Rich ecosystem; broker to run and secure |
| HTTPS polling | Battery devices, readings every few minutes, no inbound commands | Simple through firewalls; commands wait for the next poll |
| LoRaWAN / NB-IoT [9] | Wide areas, low power, small payloads | Low bandwidth; network operator or gateways required |
Every device is registered before it can report. The registry is the single source of truth for what exists, where it is, what limits apply and who is told.
| Field | Purpose |
|---|---|
| Identity | The id the device sends in every message |
| Location and physical location | Site, room, tank or vehicle; shown on every alert |
| Safe minimum and maximum | The band for the measured parameter |
| Alert list | Who is told about excursions |
| Status | Enabled, disabled or fault |
| Last seen | Time of the last message from the device |
A device counts as online if it has reported within the online window (five minutes in our deployments). The panel shows last-seen on every row; quiet devices are highlighted and their controls are locked, so nobody sends a command to equipment that cannot answer.
A command is a row in a queue with a lifecycle, not a fire-and-forget packet. The operator sees exactly where it is, and the system never shows equipment in a state the equipment has not confirmed.
| State | Meaning | Next |
|---|---|---|
| WAITING | Queued by an operator, not yet delivered | SENT when written to the device's connection |
| SENT | Delivered; awaiting the device's confirmation | ACKNOWLEDGED on confirmation |
| ACKNOWLEDGED | The device confirmed; equipment state updated | Final |
| Timer | Value | Why |
|---|---|---|
| Panel poll | 2 s | Feels live without loading the server |
| Give-up | 30 s | Long enough for slow links; short enough for an operator to act |
| Online window | 5 min | Devices quieter than this cannot be commanded |
| At 30 s the command is… | Operator sees | Likely cause |
|---|---|---|
| Still WAITING | “No response from the connection service” | Service down, or device not connected |
| SENT, not acknowledged | “No response from the device” | Device received but did not act, or lost power |
Readings are stored in a narrow table: device, parameter, value and timestamp. A narrow shape lets one table hold temperature, level, pressure or any new parameter without schema changes. Index by device and time; for long retention, roll raw readings into hourly and daily minimum, maximum and average.
reading(device_id, parameter, value DECIMAL(10,2), recorded_at) INDEX (device_id, parameter, recorded_at)
Example exchange or schema.
A reading is in band when minimum ≤ value ≤ maximum. The alerting logic tracks excursions, not readings, so a sensor that stays out of band for an hour produces one alert, not hundreds.
An alert names the device and its physical location, the value, the band, how long it has been out of band, and who else has been told. It goes by email by default; SMS and chat are added per site. A recovery message closes the loop.
Scheduled jobs render activity reports as PDF by device, site and period, with minimum, maximum and every excursion, and email them to administrators. For cold chain and pharma, keep the raw readings and excursion log [8] for the regulator's retention period.
Overhead tanks and sumps are the most common control problem we see: keep the tank full, never run the pump dry, never overflow, and know when the pump has stopped responding.
| Sensor | Strength | Watch out for |
|---|---|---|
| Ultrasonic | Non-contact; reports level as a continuous percentage | Foam, condensation and tank geometry |
| Pressure transducer | Accurate in deep tanks and sumps | Calibration and sediment |
| Float switches | Cheap, robust discrete marks | Only tells you “above / below” |
# evaluated on every level reading (automatic mode) if pump.locked: return if sump.level < sump.dry_mark: stop(pump); lock(pump, "sump dry"); alert() elif tank.level <= tank.low_mark and pump.off: command(pump, "START") elif tank.level >= tank.high_mark and pump.on: command(pump, "STOP") if tank.level >= tank.overflow_mark: alert("overflow risk") # every START/STOP goes through the confirmed command queue (chapter 6); # no confirmation in 30 s → alert "pump not responding" and lock automatic mode
Pseudocode.
An NFC card or tag carries an identity; an approved phone is the reader. The same mechanism authenticates people at gates and on transport, confirms who collected a child, and proves that a certificate or product is genuine.
| Use | Who taps | What is checked | Result |
|---|---|---|---|
| Campus and lab attendance | Staff, students, researchers | card valid, person active, reader approved | check-in / check-out with time and place |
| Transport boarding | Students | card valid, vehicle active, crew assigned | boarding record, guardian notified |
| Guardian handover | Registered guardian | guardian linked to the child | handover recorded |
| Certificate verification | Verifier | certificate exists, issuer approved | issuer, holder and details shown |
| Product and asset authenticity | Inspector or customer | tag linked to a genuine record | genuine / not found |
Identifying a card by its serial number (UID) alone is simple and fast but can be copied by determined attackers. For higher assurance, use tags that generate a fresh cryptographic code on each tap (for example NTAG 424 DNA with secure unique messaging [5]), or store a signed payload on the tag [6] and verify the signature on the reader. Combine either with reader approval and context checks.
| Assurance | Approach | Good for |
|---|---|---|
| Basic | Tag UID mapped to a record | Attendance with supervision, asset tags |
| Medium | Signed payload on the tag | Certificates, licences |
| High | Dynamic per-tap codes from secure tags | Product authenticity, high-value assets |
Phones used as readers and data-capture tools work where signal is worst: buses, basements, plants and rural sites. The pattern below keeps them working without signal and makes synchronisation safe.
Compliance data is most accurate when captured where the event happens. For fleets, that is the fuel pump and the vehicle.
| Captured | Where | How it is identified |
|---|---|---|
| Fuel quantity and station | At the pump | Vehicle NFC tag |
| Odometer | At fill and at trip start/end | Vehicle tag + photo |
| Trip sheet and crew | Start of trip | Driver and supervisor tags |
| Job cards | Workshop | Vehicle tag |
From these, kilometres between fills, consumption trends and anomalies follow directly. Documents (driver licence, insurance, pollution certificate, permits) carry expiry dates; a nightly job deactivates drivers and vehicles whose documents have expired and notifies the fleet manager, so a non-compliant trip cannot start.
Some of the most valuable IoT is a calculation placed where the decision is made [10]. In an iron foundry, the metallurgist enters the spectrometer reading at the furnace; the tablet returns corrections in kilograms.
| Quantity | Formula |
|---|---|
| Carbon equivalent | CE = C + Si/3 + P/3 − 0.027·Mn + 0.4·S |
| Liquidus temperature | TL = (14.45 − CE) / 0.0089 °C |
| Band per element | target ± tolerance (C 0.10, Si 0.05, Mn 0.10, P 0.01, S 0.01, CE 0.03) |
| Addition | kg = shortfall% × (metal + steel kg) / 100 / recovery% |
| Input | Value | Output | Value |
|---|---|---|---|
| Charge | 1,000 kg | CE | 4.05 |
| Recovery, carbon raiser | 30% | Liquidus | ≈ 1,169 °C |
| Recovery, ferro-silicon | 65% | Out of band | Si (low) |
The app works offline, is licensed to one device, and keeps each iteration of the melt so the trend across a shift is visible.
| Threat | Example | Mitigation |
|---|---|---|
| Spoofed device | A laptop sends fake readings as device 7 | Per-device credentials at provisioning; TLS; reject unregistered identities |
| Replay | An old “valve open” is resent | Response ids are single-use; commands expire; absolute actions |
| Unauthorised command | A viewer switches off a pump | Role-based control rights; audit of every command |
| Service disruption | A client tells the connection service to stop | Administrative actions only from authenticated operators, never from device sockets |
| Cloned tag | A copied student card | Approved readers; validity and context checks; dynamic-code tags for high assurance |
| Lost phone | A reader phone is stolen | Device approval revoked centrally; local data scoped to the signed-in user |
| Tampering with records | Editing a reading after the fact | Append-only readings; audit trail on every change |
| Role | Can |
|---|---|
| Administrator | Register devices, set bands and alert lists, manage users, control equipment |
| Power user | Control equipment, acknowledge alerts, run reports |
| Viewer | See dashboards and reports |
Readings per day = devices × (86,400 ÷ reporting interval in seconds). 200 sensors reporting every 30 seconds produce 576,000 readings a day; at roughly 50 bytes a row with index, that is about 30 MB a day before roll-up. A single event-loop connection service handles hundreds to low thousands of mostly idle connections comfortably; beyond that, shard devices across several services.
| Devices | Interval | Readings / day | Approx. storage / day |
|---|---|---|---|
| 50 | 60 s | 72,000 | 4 MB |
| 200 | 30 s | 576,000 | 30 MB |
| 1,000 | 10 s | 8,640,000 | 430 MB |
Anonymised. A school transport operation running morning and evening routes.
Parents wanted to know when their child boarded. The operator needed proof of who travelled on which vehicle, and a guarantee that no run started with an unassigned driver or an inactive vehicle. Coverage along routes was unreliable, and supervisors had minutes at each stop.
| Moment | What happens |
|---|---|
| Before departure | Vehicle, driver and supervisor validated; the reader is approved. |
| At each stop | Students tap; valid taps check in and notify guardians; refused taps are logged with the reason. |
| On arrival | The headcount on board is known; anyone expected but missing stands out. |
| Evening | Drop-offs recorded as check-outs; handovers to guardians logged. |
Guardians are informed at the moment of boarding instead of calling the school; the operator has a per-run record of who travelled with whom; and compliance gaps, such as an expired licence, stop a run before it starts rather than being found afterwards.
| Phase | Outcome | Key activities |
|---|---|---|
| 1. Discovery and site survey | Agreed device list, bands, roles and alert paths | Walk the site; check power and coverage; list parameters and limits; map who acts on what |
| 2. Pilot | One site live with real devices | Provision 5–20 devices; panel, alerts and reports; test commands and failure cases |
| 3. Scale | All sites onboarded | Provisioning runbook; per-site dashboards; training; role set-up |
| 4. Operate and improve | Stable, measured service | Monitoring; monthly reviews of alerts, quiet devices and command success; firmware updates |
| 1 | Is every device registered with a location, band and owner before it can report? |
| 2 | Does every reading get a confirmation, and does the device act on errors? |
| 3 | Do you get one alert per excursion, with a recovery message? |
| 4 | Are band comparisons unit-tested (including reversed limits)? |
| 5 | Is every command complete only when the device confirms it? |
| 6 | Can an operator tell “never delivered” from “device didn't answer”? |
| 7 | Are quiet devices visible and locked out of control? |
| 8 | Are commands absolute, single-use and set to expire? |
| 9 | Do pumps have hysteresis, minimum run times and dry-run lock-out? |
| 10 | Do device connections use TLS and per-device credentials on public networks? |
| 11 | Can only authenticated operators perform administrative actions? |
| 12 | Is every identity tap validated for reader, tag, validity and context? |
| 13 | Are refused taps logged with place and reason? |
| 14 | Does your tag choice match the assurance you need? |
| 15 | Do readers and apps work offline, with per-row sync status? |
| 16 | Are documents and certifications tracked with expiry and acted on automatically? |
| 17 | Can you produce a clean report for any device and period? |
| 18 | Do you roll up raw readings and keep them for the required retention? |
| 19 | Are backups restored in a drill, regularly? |
| 20 | Who runs it after launch: patches, monitoring, support? |
| Band | The safe minimum and maximum for a measured parameter. |
| Excursion | A period during which readings are outside the band. |
| Online window | How recently a device must have reported to count as online. |
| Confirmation | A reply that proves a message or command was received and acted on. |
| Hysteresis | A gap between switching thresholds that prevents rapid on-off cycling. |
| NFC | Near-field communication: short-range radio used by cards, tags and phones. |
| UID | A tag's serial number. |
| Carbon equivalent (CE) | A single figure summarising how an iron melt's chemistry affects solidification. |
| Liquidus | The temperature at which a melt begins to solidify. |
| Recovery rate | The share of an addition that ends up in the melt. |
| Document control | |||
|---|---|---|---|
| Report | CNX-TR-2026-01 | Version | 1.1 |
| Issued | November 2026 | Status | Published |
| File | cloudnix-iot-field-systems-v1.1.pdf | ||