Skip to main content
Loading navigation

Build a Sparkplug B Sensor Drift Calibration Rebalancer — implementation

Prompt source

implementation67 lines11 sectionsNo variables1 code block
## Build
Evaluate normalized Sparkplug B dataset metrics against sensor calibration thresholds to detect measurement drift. Synthesize a recalibration and replacement schedule for instrumentation technicians.

## User
Instrumentation Lead

## Workflow
1. Ingest normalized Sparkplug B device metric records containing calibration dates and drift standard deviations.
2. Compare sensor variance against published allowable tolerance thresholds.
3. Generate a prioritized recalibration schedule grouped by line and technician specialization.
4. Export a simulated maintenance dispatch record for supervisor sign-off.

## Interface
Terminal dashboard showing sensor drift variance and calendar calibration rosters.

## Data
Generate local synthetic JSON mock streams containing normalized Sparkplug B metric records with sensor serials and baseline offsets.
Starter examples below are synthetic. They are not downloaded records.

## Source
[Eclipse Sparkplug](https://raw.githubusercontent.com/eclipse-sparkplug/sparkplug/master/README.md)
Utilizes Sparkplug B metric property metadata, dataset types, and device lifecycle states outlined in Source 2.

## Tools
pydantic-ai, fastapi.
Pydantic AI provides strict schema enforcement on nested metric records and validation of calibration schedules.
Local small LLM (e.g., Llama 3 8B) or hosted Claude via API for schedule synthesis.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Correctly flags sensors exceeding tolerance thresholds.
- Calculates replacement due dates based on historical calibration intervals.
- Emits valid JSON schedule artifacts matching the schema.

## Starter Examples
```json
[
  {
    "input": {
      "device_id": "EDGE-NODE-01/DEV-TEMP-99",
      "metric_name": "FurnaceTemp",
      "last_calibrated_days": 190,
      "drift_deviation_pct": 4.2,
      "max_allowed_drift_pct": 2.5
    },
    "expected_output": {
      "device_id": "EDGE-NODE-01/DEV-TEMP-99",
      "action_required": "RECALIBRATE",
      "priority": "HIGH",
      "estimated_labor_hours": 1.5,
      "recommended_window": "NEXT_DOWNTIME_SHIFT"
    }
  },
  {
    "input": {
      "device_id": "EDGE-NODE-02/DEV-PRESS-04",
      "metric_name": "HydraulicPressure",
      "last_calibrated_days": 45,
      "drift_deviation_pct": 0.8,
      "max_allowed_drift_pct": 3
    },
    "expected_output": {
      "device_id": "EDGE-NODE-02/DEV-PRESS-04",
      "action_required": "MONITOR",
      "priority": "LOW",
      "estimated_labor_hours": 0,
      "recommended_window": "ROUTINE_CYCLE"
    }
  }
]
```

## Safety
Read-only advisory tool; produces draft maintenance calendars without commanding field instrumentation.
Use mock external writes. Require human review before any real deployment.