End-to-end automated visual quality inspection pipeline — from edge image capture on Raspberry Pi, through MQTT transport, to cloud ML inference on AWS EC2, returning PASS/FAIL decisions to MES and Ignition SCADA in under 4 seconds.
Visual path of an inspection from sensor trigger to MES record and SCADA update. Total latency <4 seconds.
Project scope: Deployment of an automated visual inspection system across six production lines to replace manual quality checks. End-to-end latency: <4 seconds from capture to MES record.
Five-layer integrated OT/IT pipeline: Edge — Raspberry Pi 4 + HQ Camera captures and preprocesses 224×224 images via OpenCV. Transport — Paho-MQTT to Mosquitto broker (TLS 1.2). Cloud — AWS EC2 runs ResNet50 transfer-learning model for PASS/FAIL. Bridge — RabbitMQ (AMQP) routes results to plant. Execution — MES record entry and Ignition SCADA HMI updates in under 4 seconds.
Single integrated pipeline from sensor trigger to MES write. Messaging brokers (Mosquitto + RabbitMQ) were co-hosted on the Ignition Server — the OT/IT hub and primary single point of failure.
AWS S3 acts as the central repository for ~85K training images, versioned model artifacts (.h5), and live inference archives for quality auditing.
Measured at Station 3, 2021. Total observed: 3.2–4.0 seconds from capture trigger to MES record write.
| # | Stage | Duration | Relative Size | Note |
|---|---|---|---|---|
| 01 | Sensor → GPIO Trigger | 50–100 ms | Photoelectric sensor → RPi GPIO HIGH → camera shutter | |
| 02 | Image Capture + OpenCV Preprocess | 250–400 ms | Full-res capture + resize + blur + equalization + base64 encode | |
| 03 | MQTT Publish → Mosquitto | 100–250 ms | Plant Wi-Fi variability — main jitter source | |
| 04 | Mosquitto Bridge → EC2 Subscribe | 150–300 ms | Mosquitto bridge plugin + Internet round-trip to EC2 | |
| 05 | ML Inference (ResNet50 CPU) | 1.0–1.5 sec | Biggest consumer — CPU-only EC2, no GPU. SageMaker GPU endpoint → ~200ms. | |
| 06 | AMQP Publish → RabbitMQ | 80–150 ms | EC2 AMQP client → RabbitMQ on Ignition Server | |
| 07 | MES Adapter Consume + Write | 400–800 ms | Biggest variability — MES DB stored procedure write time | |
| 08 | SCADA / Ignition Update | 30–80 ms | OPC-UA tag update + operator HMI refresh (step 8 in decision flow) |
Measured impact from Phase 1 deployment across 6 inspection stations during the first year of operation.
An honest assessment of the 2020–21 design decisions and their operational consequences. These limitations directly motivated the next-generation architecture.
Next-generation architecture addressing every 2020–21 limitation. Each change maps directly to a known gap in the legacy system.
| Legacy (2020–21) | Next-Generation | |
|---|---|---|
| Mosquitto on Ignition Server | → | AWS IoT Core |
| EC2 persistent MQTT process | → | IoT Core + Lambda trigger |
| EC2 Flask + ResNet50 (CPU) | → | SageMaker Real-Time Endpoint |
| Base64 image in MQTT payload | → | Image → S3, URL in MQTT |
| RabbitMQ on Ignition Server | → | RabbitMQ in dedicated DMZ |
| MES adapter (Python script) | → | MES microservice + retry queue |
| Manual model retraining | → | SageMaker Pipelines CI/CD |
| No S3 lifecycle policy | → | S3 + Kinesis Firehose data lake |
| No OT/IT segmentation | → | DMZ + IoT Core + VPN gateway |
Raspberry Pi 4 · OpenCVS3 image upload → MQTT URL message
AWS IoT Core · X.509 mTLS
Device Shadow · Rules Engine → Lambda
SageMaker Endpoint (GPU)
Model Monitor + Pipelines
Kinesis Firehose → S3 data lake
RabbitMQ (DMZ dedicated)
AMQP → REST / OPC-UA
MES microservice + retry queue
Ignition SCADA + SPC
Power BI DirectQuery
Five-layer architecture and the components in each layer. Data flows left to right: Edge → Transport → Cloud → Bridge → Plant.
| Category | Component | Role |
|---|---|---|
| Edge Hardware | Raspberry Pi 4 Model B (4GB) | Image capture + GPIO I/O at each station · Plant floor |
| Camera | RPi HQ Camera Module (12MP) | Inspection image capture mounted on fixture · Plant floor |
| Edge Software | Python 3.8 + OpenCV 4.x | Image preprocessing pipeline + GPIO control · Raspberry Pi local |
| MQTT Client | Paho-MQTT 1.5.x | Publish images to Mosquitto broker · Raspberry Pi local |
| MQTT Broker | Eclipse Mosquitto 1.6.x | Receive RPi images, bridge to AWS EC2 · Ignition Server (on-premise) |
| Cloud Platform | AWS EC2 t3.large (Ubuntu 20.04) | MQTT subscriber + ML inference engine · AWS Cloud — single instance |
| ML Framework | TensorFlow 2.x / Keras | ResNet50 transfer learning + inference · AWS EC2 |
| ML Model | ResNet50 CNN (.h5) | Fine-tuned on ~85K labeled images (pass + defect classes) · AWS EC2 + S3 |
| Storage | AWS S3 | Training data, model artifacts, inference images · AWS Cloud |
| Result Broker | RabbitMQ 3.8.x (AMQP) | Route JSON result → MES + SCADA · Ignition Server (on-premise) |
| SCADA Platform | Ignition 8.0.x (Inductive Automation) | Operator dashboards + OPC-UA gateway · Ignition Server (on-premise) |
| MES | SAP ME / Ignition Sepasoft | Quality records, NCR creation, OEE quality · Plant data center |
How the ResNet50 model was built, evaluated, versioned, and deployed to EC2 — from raw labeled images to live inference in 2020–2021.
model_v{N}.h5 + metadata JSONmodel_version field written to every MES inspection record from this pointWhat security controls were in place in 2020–21, and where the architecture fell short against modern OT/IT security standards. Understanding the gaps is the foundation for the next-generation redesign.