DEV Community

Cover image for 5 Mistakes Developers Make When Building Shop Floor Data Pipelines
BugBytes
BugBytes

Posted on

5 Mistakes Developers Make When Building Shop Floor Data Pipelines

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 }
}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 asset field 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_version on 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")
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (10)

Collapse
 
anya_sokolova_a98d60712b5 profile image
Anya Sokolova • • Edited

Anyone who has ever watched half a Grafana dashboard go blank because someone renumbered data blocks on a PLC will appreciate section 4. Decoupling raw tags like PLC3.DB10.W4 into an ISA-95 asset hierarchy via versioned config is a lifesaver.

Collapse
 
bugbytes profile image
BugBytes •

Appreciate it, Anya! Totally agree—once you've had to scramble to remap raw tags after a controller swap, decoupling into an ISA-95 hierarchy feels like the only sane way forward. Glad section 4 resonated!

Collapse
 
belle_baril_e4c5baef52f9a profile image
Belle Baril •

Separating source_ts and ingest_ts in UTC is non-negotiable, especially around 05:59/06:00 shift handovers and DST fall-back nights. Love seeing a concrete JSON event envelope right in the post — super clean and practical.

Collapse
 
bugbytes profile image
BugBytes •

Thanks so much, Belle! Having a concrete event envelope up front saves so many headaches down the line—especially when gateways buffer and flush late around shift changes. Do you usually pair NTP/PTP sync on the edge with alerts when ingest_ts - source_ts drifts past a threshold?

Collapse
 
luna_winona_9071c8aed60cd profile image
Luna Winona • • Edited

Factory Wi-Fi and maintenance switch reboots will humble any pipeline built with data-center assumptions. Using a source-generated sequence key plus ON CONFLICT DO NOTHING is such a crisp, lightweight pattern for handling edge gateway replays without inflating counts.

Collapse
 
bugbytes profile image
BugBytes •

Thanks, Luna! Data-center assumptions definitely don't survive long on a factory floor 😅 Pairing a source-generated sequence key with ON CONFLICT DO NOTHING keeps the sink simple without needing heavy distributed transactions. How do you usually handle edge buffer sizing when a remote site loses its uplink for hours?

Collapse
 
ascendra_ventures_92c21f2 profile image
Ascendra Ventures •

"It isn't a protocol problem. It's a meaning problem" is the line I would put on the wall of any team building an operations dashboard. A count without the order, the shift or the reason for the stop is just a number, and the moment a production manager says it is wrong, trust in the whole screen goes with it. Belle's note about keeping source_ts and ingest_ts separate around a 06:00 handover is the same lesson at the timestamp level.

Ascendra Ventures ran into the non-factory version of this with an egg distribution startup in India. They had asked for a full ERP. What actually moved decisions was one live dashboard of daily sales against target, raw and finished stock, quality batches, complaints, demand and shortfall, with demand versus dispatch broken out by egg type and region so planning could act before a delivery beat ran short, with logistics on the same screen. It handles about 500,000 events a day across 7 regions. The useful test for each figure is whether someone can act on it, which is the same reason production context matters next to a machine count.

If you could only add one piece of production context to a raw machine signal on day one, would it be the order, the shift or the stop reason?

Collapse
 
bugbytes profile image
BugBytes •

Love that example! Especially the rule of thumb that every figure on a dashboard should pass the "can someone act on it?" test. Whether it's 500,000 egg distribution events across regions or machine cycles on a packaging line, decision-ready context always beats building a massive system before anyone trusts the numbers.

To answer your question: if I could only attach one piece of context on day one, I'd pick the active order (and product/SKU), and here's why:

  • Shifts can usually be derived cleanly later as long as your timestamps are stored in UTC alongside the plant's shift calendar.
  • Stop reasons are hugely valuable, but they often rely on human operator input and take longer to standardize cleanly across lines.
  • The active order/SKU instantly gives every single machine count a denominator, you immediately know the target rate, the ideal cycle time, and whether a sudden spike or drop is a real bottleneck or just a product changeover.

Once order/SKU context is solid, stop reasons are a close second because they turn "the line slowed down" into "here's what to fix right now." In your egg distribution build, which single dimension unlocked the fastest decisions for the ops team on day one?

Collapse
 
gia_bruno_fc1bb6d3f1a8c1e profile image
Gia Bruno •

It isn't a protocol problem. It's a meaning problem’—that single sentence sums up almost every painful industrial data project I've worked on. Moving the bytes is the easy part; getting operations and engineering to speak the same language is the real challenge. Great breakdown!

Collapse
 
bugbytes profile image
BugBytes •

Thanks so much, Gia! Couldn't agree more—getting MQTT or OPC-UA packets flowing is rarely what sinks a project; it's aligning IT and floor operations on what those numbers actually represent 🤝 What's been your go-to way for bridging that gap between ops and engineering early on?