Internet of Things (IoT) Integration

Ship Your First IoT Integration Without a Platform Team

A device sending data is not yet an IoT integration: the product still needs to identify the device, reject bad events, tolerate retries, and show operators what arrived. For a 15–30 person engineering team, I would start with one simulated device and one product-facing read path. I would not start with a fleet platform, because its provisioning machinery can conceal an untested data contract.

One simulated device should reach the product before any hardware rollout

Pick one event the existing application can use: for example, a temperature reading that appears on a device detail page. Name the product behavior first. If a reading arrives, the page shows its value and observation time; if readings stop, it shows the last observation time rather than pretending the device is healthy. That small requirement forces the team to settle the questions that a connection diagram usually skips.

Write a sample event with device_id, seq, observed_at, and temp_c. Define observed_at as a UTC timestamp supplied by the device and add a server-side received_at when the event enters your system, because a delayed upload must not look like a current measurement. Make seq a monotonically increasing integer per device, because a retry should be recognizable without comparing floating-point readings. Specify the units in the field name, because “temperature” invites incompatible interpretations.

Put that event in a JSON Schema Draft 2020-12 file and reference the same example from an OpenAPI 3.1 description of POST /events. Schema validation belongs at the boundary, while product-specific judgments—such as whether a reading is implausible—belong in a separate step, because changing a business rule should not silently redefine the wire format. Assign one engineer to the event contract and one to the product read path; on a small team, shared ownership without a named reviewer tends to leave both sides waiting.

Build a simulator before ordering devices. It should send an event, resend that identical event, skip a sequence number, and send an older observation after a newer one. These are test cases, not predictions about a particular device. Use a fixture of 100 events for the first replay drill; that is a deliberately small test size to adjust once real device behavior is known. The initial milestone is a product page that tells the truth after all four cases, not a dashboard showing that packets crossed a network.

I would push back on Scope IoT Integration Around Metrics That Prove It Works as the very first task: choose the event contract before finalizing success metrics, because otherwise a team can measure reliable delivery of data the product cannot interpret. The contract still needs an acceptance test before implementation expands beyond this first event.

A local ingest seam should fail visibly before it scales

Run the smallest possible receiver on a developer machine. The following Python 3.12 example accepts JSON at /events and uses SQLite’s composite primary key to ignore a repeated device-and-sequence pair. Save it as server.py and run it with python3 server.py. It binds to loopback intentionally; it has no authentication, timestamp validation, or production request limits.

import json, sqlite3
from http.server import BaseHTTPRequestHandler, HTTPServer
db = sqlite3.connect("telemetry.db", check_same_thread=False)
db.execute("CREATE TABLE IF NOT EXISTS events (device TEXT, seq INTEGER, payload TEXT, PRIMARY KEY(device, seq))")
class Handler(BaseHTTPRequestHandler):
    def do_POST(self):
        try:
            x = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
            assert self.path == "/events" and isinstance(x["device_id"], str)
            assert isinstance(x["seq"], int) and isinstance(x["temp_c"], (int, float))
            db.execute("INSERT OR IGNORE INTO events VALUES (?, ?, ?)", (x["device_id"], x["seq"], json.dumps(x)))
            db.commit()
            self.send_response(204); self.end_headers()
        except (KeyError, ValueError, AssertionError, TypeError): self.send_error(400)
HTTPServer(("127.0.0.1", 8080), Handler).serve_forever()

This code proves one behavior only: replaying the same identifier and sequence does not create a second row. It does not prove that a reused sequence with different contents is safe; the production receiver should reject that conflict and record it, because silently keeping the first payload would hide device or client faults. Replace assertions with explicit validation before deploying, because Python can disable assertions with the -O flag.

Next, put the real boundary behind HTTPS with TLS 1.3, authenticate each device or gateway, and validate the full schema before writing to PostgreSQL 16. Keep the unique constraint on (device_id, seq); application-level duplicate checks alone can race when requests arrive together. Give the request an adjustable 16 KiB body limit at the ingress, because an unbounded body lets a misconfigured client consume resources before schema validation starts. Return a clear client error for invalid events and a retryable server error for temporary storage failure, because the sender needs to distinguish correction from retry.

I also disagree with the sequence implied by Seamless IoT Integration for Modern Software Systems: preserve a visible ingest seam until retries, identity, and bad data have been exercised, because early abstraction can make those failures difficult to locate. The product can read from a simple query or view for now; adding a streaming layer does not improve a contract that still changes every sprint.

A managed device platform earns its place through fleet work

Choose between direct HTTPS ingestion and AWS IoT Core after the local receiver has exposed the requirements. Direct HTTPS wins when a small number of controllable gateways can authenticate to an API the team already operates; its cost is owning credential rotation, reconnect behavior, ingress capacity, and device visibility. AWS IoT Core wins when per-device identities, certificate lifecycle, and routing rules would otherwise become a substantial internal service; its cost includes usage charges, AWS-specific policy and routing work, and another operational surface to debug. Neither option removes the need for a product event contract or replay handling.

For the first deployment, document who provisions an identity, who revokes it, and what happens to data buffered during an outage. If gateways send on behalf of devices, retain both gateway identity and claimed device identity, because authenticating the gateway does not verify which attached device produced a reading. If devices connect directly, test credential replacement on a spare unit before rollout, because a credential plan that works only at initial enrollment is incomplete.

Set a provisional 60-second reporting interval in the simulator and make it configurable, because the appropriate cadence depends on how quickly the product must notice change and how much traffic devices can sustain. Give senders a bounded retry queue and preserve original observation timestamps, because uploading buffered readings as though they were new corrupts the product view. Define the queue’s retention from an expected outage scenario rather than guessing a fleet-wide default.

Mosquitto 2.x can be useful as a local broker when the selected devices already speak MQTT 5, but I would not add it merely to make the architecture look like an IoT diagram: an extra hop introduces credentials and failure states without answering what the application should do with an event. Keep protocol choice separate from the decision to use a managed fleet service. A tech lead should be able to replace the simulator with a real sender without rewriting the product read path.

The setup works when a failure drill leaves an explainable record

Before calling the integration ready, run the simulator through the deployed path and inspect both the product page and the stored events. Resend an event and confirm it appears once. Send a malformed payload and confirm it is rejected without an event row. Pause the sender, restore it, and confirm buffered readings retain their observation times. Revoke its credential and confirm later requests fail. Each result needs a traceable record, because “the dashboard looked right” cannot distinguish a correct read path from a lucky refresh.

Instrument the receiver with OpenTelemetry traces and expose Prometheus counters for accepted events, rejected events by reason, duplicate events, and storage failures. Use Grafana to graph the rate of each counter, but keep raw examples of rejected payloads in access-controlled diagnostics, because a rate chart cannot show which field broke. Avoid putting device credentials or unrestricted payloads in logs, because debugging convenience should not create a second data store with weaker access controls.

Measure ingest latency from received_at to durable storage, and separately measure observation lag from observed_at to received_at; combining them would blame the server for a device that was offline. For the first drill, aim to identify the cause of a missing reading within 30 minutes. That is an acceptance target to revise after rehearsal, not a claim about typical incident response. Record the observed time and diagnosis for each injected failure so the next drill can show whether the team improved.

Put the schema checks, replay cases, and API tests in GitHub Actions, and require them on changes to either the sender or receiver. Then test one real device against the same contract. A working setup is not the absence of errors; it is one in which a tech lead can point to the event, its identity, its retry history, and the reason the product did—or did not—display it.

The first pull request should contain a replayable event

Tomorrow, ask one engineer to commit the sample event, its JSON Schema, and a simulator case that sends it twice. Ask another to make the product page show the stored value and observation time. Review those changes together before selecting a device platform. If the second send produces a second reading, fix that seam first; more infrastructure will only make the mistake harder to find.