Make production transparent. Try MDCplus
Try it yourself Get guided demoHow Do You Stop AI from Hallucinating When Building IIoT Dashboards?
How Do You Stop AI from Hallucinating When Building IIoT Dashboards?
Short answer: constrain the model's inputs and outputs explicitly — never let it invent field names, protocol behavior, or default values — and add a verification layer that tests generated code against deliberately broken telemetry before it reaches production. The hallucinations that matter in industrial dashboards aren't the obvious ones. A model inventing a fictional Python library fails loudly at import time. A model inventing a plausible-sounding register address, assuming a field is always present, or quietly defaulting a missing value to zero produces working code that displays wrong numbers — which is far more dangerous on a shop floor. This article covers the meta-prompt system and verification practices that prevent both.
Copy this meta-prompt to get started
Prepend this to any prompt that generates IIoT dashboard or integration code (Opus is the safer choice for the initial generation given the constraint-following demands; Sonnet is fine for iteration once the rules are established in context):
You are generating code for an industrial monitoring dashboard where incorrect output causes real operational harm. Follow these rules for every response:
1. Never invent identifiers. Do not guess field names, register addresses, tag names, API endpoints, or protocol semantics. If you need one and I haven't supplied it, stop and ask.
2. Never substitute defaults for missing data. A missing value must propagate as null with a reason, never as 0, 100%, or a last-known value without an explicit staleness flag.
3. Type everything strictly. Validate types at every boundary where external data enters. Do not assume a numeric field is numeric.
4. Distinguish "no data" from "zero." These are semantically different in machine monitoring and must never be conflated.
5. Flag your own uncertainty. If you are unsure whether a library API, protocol detail, or method signature is correct, say so explicitly in a comment rather than writing confident code.
6. List your assumptions. End every response with an "Assumptions made" section. If the list is empty, say so explicitly.
Contents:
- What hallucination actually looks like in IIoT code
- Why industrial context makes it worse
- The constraint rules that do the heavy lifting
- Few-shot industrial context
- Strict data typing at the boundary
- Missing-telemetry edge cases
- Building a verification layer
- Testing with deliberately hostile synthetic data
- What not to delegate to a model at all
- Frequently asked questions
- Conclusion
What hallucination actually looks like in IIoT code
It's worth being specific, because the term gets used loosely. In dashboard-building contexts, hallucinations fall into roughly three tiers by how dangerous they are:
| Tier | Example | Why it matters |
|---|---|---|
| Loud — fails immediately | A nonexistent library, a method that doesn't exist on a real class | Annoying but harmless; you find out in seconds |
| Quiet — fails on real data | Assuming a field is always present; assuming a value is numeric | Works in testing, breaks in production, often intermittently |
| Silent — never fails, just wrong | Invented register address that reads a valid but different value; missing data defaulted to zero | Produces confident, plausible, incorrect numbers indefinitely |
Most prompt-engineering advice implicitly targets the first tier. The third tier is where industrial dashboards actually get hurt, and it requires deliberately different defenses — you can't catch it by running the code and seeing whether it works, because it does work.
Why industrial context makes it worse
- Protocol details are highly specific and sparsely documented publicly. Register maps, tag structures, and vendor-specific behaviors vary by controller model and firmware. A model's training data contains enough industrial protocol material to sound authoritative and not enough to be reliably correct for your specific machine.
- Plausible values are indistinguishable from correct ones. A spindle load of 47% looks exactly as reasonable whether it came from the right register or a neighboring one.
- Nobody cross-checks a dashboard. Once a display is up and looks reasonable, it gets trusted. There's rarely a second source that would reveal a discrepancy.
- The consequences compound. A wrong OEE figure doesn't just misinform — it drives capital allocation, staffing, and improvement priorities, sometimes for months before anyone questions it.
The constraint rules that do the heavy lifting
Of the six rules in the meta-prompt above, two carry most of the weight and are worth understanding rather than just copying.
"Never invent identifiers — stop and ask." Models are strongly biased toward completing a task. Given an incomplete specification, the default behavior is to fill the gap plausibly rather than to halt. Explicitly authorizing the model to stop and ask changes this, because it provides a sanctioned alternative to guessing. Without that permission, the model's only path forward is invention.
"List your assumptions." This one is disproportionately effective. Requiring an explicit assumptions section at the end of every response surfaces the invisible decisions — "I assumed timestamps are UTC," "I assumed the API returns all machines in one call" — that would otherwise be buried in code nobody reads closely. Roughly half the problems this catches are ones you'd never have thought to ask about.
Few-shot industrial context
Zero-shot prompting — describing what you want with no examples — leaves the model to infer your data shapes from its general training. For industrial data specifically, that's exactly where invention creeps in. Supplying two or three real (or realistically messy) examples of your actual data anchors it:
Here are three real responses from our telemetry API, including one from a machine that was offline and one with a partial payload:
[paste actual examples, redacted if needed]
Write the parsing layer against these exact shapes. If you encounter a field in my examples whose meaning is unclear, ask rather than assuming. Do not write code for fields that don't appear in these examples.
That final constraint — "do not write code for fields that don't appear in these examples" — is worth including explicitly. Models frequently add handling for plausible-sounding fields that your system simply doesn't have, which creates dead code paths and, worse, implies to the next reader that those fields exist.
Strict data typing at the boundary
The most reliable structural defense against silent wrongness is to make invalid data impossible to pass through unnoticed. Ask for explicit validation at every point where external data enters the application:
Define a strict schema for the telemetry payload using [Pydantic / TypeScript types / your validation library]. Every field must have an explicit type and nullability. Validate every incoming payload against it before any processing. On validation failure, log the raw payload and the specific field that failed, exclude that record from calculations, and surface it in a data quality panel — do not coerce, do not silently skip.
This turns a class of silent failures into loud ones. A string where a float was expected stops being "0.0 displayed on the dashboard" and becomes "machine 7 excluded, spindle_load was a string" — which is actionable rather than invisible. The same principle underlies the broader practices in our piece on shop floor data quality.
Missing-telemetry edge cases
Missing data is the single most common source of quietly wrong industrial dashboards, and models default to the wrong behavior almost universally. Enumerate the cases explicitly:
- Machine reporting but field absent — exclude from that metric, don't zero it.
- Machine not reporting at all — distinct state, not "stopped." Excluding a machine's downtime from Availability is wrong; counting an outage as downtime is also wrong.
- Stale data still being returned — an API returning a cached last-known value with an old timestamp needs a staleness threshold, or the dashboard shows a frozen machine as running.
- Partial period coverage — a metric computed over a period where telemetry only existed for half of it should say so, not silently report on the half it has.
- Clock disagreement — timestamps from a device with a drifting clock can produce negative durations or events out of order. Ask for explicit handling rather than assuming monotonic time.
Building a verification layer
Prompt constraints reduce hallucination; they don't eliminate it. The second line of defense is verification that doesn't depend on the model having behaved:
- Make it review its own output cold. In a fresh conversation without the generation context: "Review this code for incorrect assumptions about data availability, type safety, and protocol behavior. List anything that would produce wrong values rather than errors." A clean context is meaningfully better at this than continuing the thread that produced the code.
- Assert the constraints in code, not just the prompt. If a factor must never exceed 1.0, write an assertion. Prompt rules are guidance; assertions are enforcement.
- Reconcile against a known reference. Compare output against your monitoring platform's own figures for the same period. Unexplained differences are the signal.
- Verify protocol details against vendor documentation, not the model. Register addresses, tag names, and protocol semantics should be confirmed against the actual documentation for your specific controller — this is the category where model confidence is least correlated with correctness.
Testing with deliberately hostile synthetic data
Clean mock data hides exactly the bugs you're trying to catch. Ask for a generator that's actively adversarial:
Write a synthetic telemetry generator for testing that deliberately produces: null values in numeric fields, a machine that disappears from the feed mid-run and returns later, timestamps out of order, a value 100× larger than physically plausible, an empty response, a malformed JSON payload, and a period of complete silence longer than the polling interval. The dashboard must handle every one of these without crashing and without displaying a misleading value.
Running a dashboard against this for an hour surfaces more real problems than a week of clean-data testing. It's also a reusable asset — the same generator validates every future change.
What not to delegate to a model at all
Some things shouldn't be prompt-generated regardless of how good the constraints are:
- Protocol-specific addressing. Register maps and tag addresses come from vendor documentation, full stop. The protocol guides on this blog — Modbus TCP, OPC UA, FOCAS — all make the same point: the device's own documentation is the only authoritative source for what an address means.
- Metric definitions. What counts as planned production time or a good part is a business decision, not something to let a model infer.
- Anything writing back to equipment. Read-only dashboards are a reasonable place for fast iteration; code that sends commands to machines is not.
- Safety-related logic. Self-evident, but worth stating: nothing where an incorrect output has physical consequences.
Frequently asked questions
Do newer, more capable models eliminate the need for these constraints?
They reduce the frequency of outright fabrication, but the failure mode that matters here — plausible substitution for missing information — is partly a consequence of the model trying to be helpful, not a capability gap. A model that can't know your register map still can't know it. The constraints remain worth applying regardless of model tier.
What's the single highest-value rule if I only add one?
"List your assumptions at the end of every response." It costs nothing, requires no restructuring of how you prompt, and surfaces the invisible decisions that cause most silent errors.
How do I know whether generated code is hallucinating protocol details?
Check against vendor documentation directly. Model confidence is not a signal here — industrial protocol specifics are exactly the area where output sounds authoritative and may be wrong for your particular controller and firmware version.
Is it faster to just write this code manually to avoid the problem?
Usually not. The verification practices above take far less time than writing everything by hand, and they're good practice for hand-written code too — strict typing, hostile test data, and reconciliation against a reference catch human errors just as effectively.
Conclusion
The dangerous hallucinations in IIoT dashboard code are the ones that never throw an error: invented addresses that read real values, missing data quietly rendered as zero, assumptions about data shape that hold until they don't. Defending against them takes two layers — prompt constraints that forbid invention and require explicit assumptions, and verification that doesn't trust the model to have complied, including strict typing, hostile synthetic data, and reconciliation against a known reference. Neither layer alone is sufficient; together they make the failure mode loud instead of silent, which is the whole objective.
Related articles:
- How Do You Prompt-Engineer a Custom OEE Dashboard for Your Machines?
- Data Quality on the Shop Floor: Common Pitfalls
- How Do You Vibe-Code a Real-Time Shop Floor Dashboard with Claude and Python?
- From Raw Signals to Useful Metrics
- MDCplus Machine Connectivity & Integrations
About MDCplus
Our key features are real-time machine monitoring for swift issue resolution, power consumption tracking to promote sustainability, computerized maintenance management to reduce downtime, and vibration diagnostics for predictive maintenance. MDCplus's solutions are tailored for diverse industries, including aerospace, automotive, precision machining, and heavy industry. By delivering actionable insights and fostering seamless integration, we empower manufacturers to boost Overall Equipment Effectiveness (OEE), reduce operational costs, and achieve sustainable growth along with future planning.
Ready to increase your OEE, get clearer vision of your shop floor, and predict sustainably?