Factories are filling up with connected equipment. IoT Analytics expects 21.1 billion connected devices worldwide by the end of 2025, and a growing share of them sit on production lines. Developers are increasingly asked to pull that data into dashboards and models.
The pipes usually work. The trouble starts when a production manager looks at the dashboard and says the numbers are wrong.
Usually it isn't a protocol problem. It's a meaning problem, and it comes from treating machines like any other event source. Below are five common mistakes, each with the symptom you'll notice and a concrete fix. If you want the end-to-end architecture first, this post on how factory data moves is a good primer.
1. Collecting signals without production context
A programmable logic controller (PLC) tag or a sensor pulse tells you that a machine cycled. It doesn't tell you what it was making, which shift was on or why it stopped for twenty minutes after lunch. Without that context, a count is just a number.
Manufacturing data collection means capturing machine signals together with the context that makes them useful: the product or order, the shift, whether a stop was planned or unplanned and the reason behind each stop. That's why dedicated manufacturing data collection tools capture counts automatically from line sensors, then turn them into real-time dashboards giving everyone on the floor a shared view of output, downtime and availability.
If you're building your own pipeline, aim for the same result. Treat context as first-class data rather than something an analyst will reconstruct later.
Imagine a hypothetical packaging line where the count rate jumps by 30% on Tuesday afternoon. Without context, it looks like a great shift. With context, you can see that the line switched from 500 ml bottles to 330 ml cans, which run faster by design. The rate didn't improve at all.
The fix is to join context at ingest time. Pull the active order and product from the scheduling system, the shift from the plant calendar and stop reasons from the operator interface. Then attach them to each event as it enters the pipeline. Guessing them afterwards from timestamps is where most reporting arguments begin.
2. Trusting every timestamp you receive
Every device in the chain has its own clock. The PLC, the edge gateway, the broker and your database server can all disagree by seconds or even minutes, and clocks that aren't synchronized drift further apart over time.
A stop that starts at 05:59 and ends at 06:04 belongs partly to the night shift and partly to the morning shift. Get the clock wrong and you'll charge the whole stop to the other team.
Separate two ideas in your schema:
- Source time: When the event actually happened on the machine.
- Ingest time: When your pipeline received it.
Keep both, in UTC. Sync edge devices with Network Time Protocol (NTP), or Precision Time Protocol (PTP) where you need sub-millisecond accuracy. Store the plant's time zone and its shift calendar as reference data, and never derive the shift from your server's local time.
Shifts that cross midnight and daylight saving changes are the classic traps. A night shift that starts at 22:00 usually gets reported against the date it started, and on the night the clocks go back it runs an hour longer. Both cases deserve their own test.
Here's the event envelope I'd start with. It also carries the fields that mistakes 3 and 4 need:
{ "event_id": "line2-filler-01:cycle:000184223", "schema_version": 2, "asset": "plant-a/packaging/line-2/filler-01", "type": "cycle_completed", "source_ts": "2026-11-02T05:59:58.412Z", "ingest_ts": "2026-11-02T06:00:01.087Z", "context": { "order_id": "PO-48812", "product": "SKU-330ML-CAN", "shift": "night" }, "value": { "count": 1 } } 3. Assuming the network will always be there
Factory networks aren't data center networks. Wi-Fi gets crowded, a switch gets unplugged during maintenance and a remote site's uplink goes quiet for a while. Well-designed edge gateways handle this by buffering messages locally and sending them once the connection is back.
That's good engineering, but it has a consequence. Brokers that use at-least-once delivery will sometimes hand over the same message twice, and a replayed buffer can overlap with messages that have already arrived. Duplicates are normal, so your pipeline has to expect them.
The fix has three parts:
- Store and forward at the edge: Buffer on the gateway so no data is lost while the link is down.
- A stable event ID: Build an idempotency key from the asset and a sequence number set at the source, not at ingest.
- Idempotent writes: Make the sink ignore an event it has already stored.
Here's a minimal version of that last step using SQLite. The same ON CONFLICT clause works in PostgreSQL:
import sqlite3 conn = sqlite3.connect(":memory:") conn.execute(""" CREATE TABLE events ( event_id TEXT PRIMARY KEY, asset TEXT NOT NULL, source_ts TEXT NOT NULL, ingest_ts TEXT NOT NULL, count INTEGER NOT NULL ) """) def write_events(conn, events): conn.executemany( """INSERT INTO events (event_id, asset, source_ts, ingest_ts, count) VALUES (:event_id, :asset, :source_ts, :ingest_ts, :count) ON CONFLICT (event_id) DO NOTHING""", events, ) conn.commit() batch = [ {"event_id": "filler-01:cycle:1", "asset": "line-2/filler-01", "source_ts": "2026-11-02T05:59:58Z", "ingest_ts": "2026-11-02T06:00:01Z", "count": 1}, {"event_id": "filler-01:cycle:2", "asset": "line-2/filler-01", "source_ts": "2026-11-02T05:59:59Z", "ingest_ts": "2026-11-02T06:00:01Z", "count": 1}, ] write_events(conn, batch) write_events(conn, batch) # the gateway replays its buffer after a reconnect total = conn.execute("SELECT SUM(count) FROM events").fetchone()[0] print(total) # 2, not 4 assert total == 2 That replay is also a test case worth keeping in CI. For a deeper look at at-least-once versus exactly-once processing on a streaming platform, this Redpanda Connect tutorial covers the delivery semantics trade-offs well.
4. Hard-coding tag names instead of modeling assets
Early pipelines often subscribe straight to raw tag addresses like PLC3.DB10.W4 and map them to dashboard fields in code. It works until a controller is replaced, a second line is added or someone renumbers the data blocks. Then half your queries quietly return nothing.
In Deloitte's 2025 smart manufacturing survey, only 54% of manufacturers reported having a data standard through a unified data model.
The fix is to model assets, not addresses:
- An asset hierarchy: Name things by site, area, line and machine, in the spirit of the ISA-95 standard, as in the
assetfield of the envelope above. - Mapping in config: Keep the tag-to-asset mapping in a versioned file or table, so swapping a controller is a config change rather than a deploy.
- A schema version: Put
schema_versionon every event so consumers can handle old and new payloads side by side.
You don't have to invent the structure from scratch. OPC Unified Architecture (OPC UA) servers expose browsable information models that describe devices and their variables. If you're weighing how that fits with a lightweight broker, this comparison of MQTT and OPC-UA explains the common pattern of using both.
5. Calculating metrics nobody agreed on
The last mistake is the most human one. Developers need a definition of "downtime" or "good parts" to write a query, so they pick one. Operations already has its own, and the two rarely match.
Overall equipment effectiveness (OEE) is the standard example. It's Availability x Performance x Quality:
- Availability: Run time divided by planned production time.
- Performance: Ideal cycle time multiplied by total count, divided by run time.
- Quality: Good count divided by total count.
A score of 100% means the line made only good parts, at full speed, with no stops. Each factor hides decisions the plant has to make, such as whether breaks count as planned time, how short a stop can be before it's just a slow cycle and which ideal cycle time applies to each product.
These gaps open up when those writing code and the people running the line don't talk. Cisco's 2024 industrial networking report found that 41% of firms say their operational technology (OT) and information technology (IT) teams work independently.
The fix is to write definitions down with operations, then encode them as small, tested functions:
def oee(planned_min, stop_min, ideal_cycle_s, total_count, good_count): """Return (availability, performance, quality, oee) as fractions.""" run_min = planned_min - stop_min availability = run_min / planned_min performance = (ideal_cycle_s * total_count) / (run_min * 60) quality = good_count / total_count return availability, performance, quality, availability * performance * quality def test_oee_for_one_shift(): # 8-hour shift with a 30-minute break agreed as planned time: 450 minutes a, p, q, total = oee(planned_min=450, stop_min=45, ideal_cycle_s=1.5, total_count=14_580, good_count=14_288) assert round(a, 3) == 0.9 assert round(p, 3) == 0.9 assert round(q, 3) == 0.98 assert round(total, 3) == 0.794 test_oee_for_one_shift() print("ok") Add the shift-boundary test from mistake 2 and the replay test from mistake 3 to the same suite. When a definition changes, the tests change with it and everyone can see why.
Wrapping up
The hard part of shop floor data isn't moving bytes. It's keeping their meaning intact on the way from the machine to the dashboard.
Attach context at ingest, keep source and ingest time in UTC, make every write idempotent, model assets instead of tag addresses and agree metric definitions with the plant before you code them.
