Industrial IoT
25 min read
Industrial Predictive Maintenance System with IIoT
Build a complete Industry 4.0 solution for machine health monitoring using vibration analysis, edge computing, and machine learning for failure prediction.
Table of Contents
1. Project Overview
Predictive maintenance reduces unplanned downtime by 30-50% and increases machine life by 20-40%. This project builds a complete IIoT system for monitoring industrial equipment health through vibration analysis.
Key Benefits:
- Detect bearing failures 30+ days in advance
- Reduce maintenance costs by 25-30%
- Eliminate unnecessary scheduled maintenance
- Prevent catastrophic equipment failures
- Optimize spare parts inventory
2. System Architecture
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββ
β Vibration β β Edge Gateway β β Cloud β β Dashboardβ
β Sensors βββββββΆβ (Raspberry βββββββΆβ Platform βββββββΆβ & Alerts β
β (ADXL345/MPU6050)β β Pi + FFT) β β (AWS/Azure) β β β
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββ ββββββββββββ
β β β
ββββββββββββββββββββββββββ΄ββββββββββββββββββββββββ
MQTT/Modbus TCP/IP
3. Hardware Components
| Component | Specification | Purpose |
|---|---|---|
| Accelerometer | ADXL345 or MPU6050 | Vibration measurement (Β±16g) |
| Edge Gateway | Raspberry Pi 4 | FFT analysis & data aggregation |
| Microcontroller | ESP32 or Arduino | Sensor data acquisition |
| Temperature Sensor | DS18B20 | Motor temperature monitoring |
| Current Sensor | SCT-013 | Power consumption tracking |
| Enclosure | IP65 NEMA | Industrial protection |
4. Vibration Sensor Setup
// ESP32 Vibration Data Acquisition
#include <SPI.h>
#include <WiFi.h>
#include <PubSubClient.h>
#include "ADXL345.h"
ADXL345 adxl;
const char* mqtt_server = "192.168.1.100";
const char* machine_id = "MOTOR_001";
void setup() {
Serial.begin(115200);
adxl.powerOn();
adxl.setRange(ADXL345_RANGE_16_G);
adxl.setDataRate(ADXL345_DATARATE_3200_HZ);
WiFi.begin("factory_wifi", "password");
client.setServer(mqtt_server, 1883);
}
void loop() {
// Read vibration at 3200 Hz
double x, y, z;
adxl.getAcceleration(&x, &y, &z);
// Calculate overall vibration magnitude
double magnitude = sqrt(x*x + y*y + z*z);
// Publish to MQTT
char payload[64];
sprintf(payload, "{\"machine\":\"%s\",\"vibration\":%.2f}",
machine_id, magnitude);
client.publish("factory/vibration", payload);
delay(10); // 100 Hz sampling
}
5. Edge Computing Layer
Perform FFT (Fast Fourier Transform) at the edge to reduce cloud bandwidth:
# Python FFT on Raspberry Pi
import numpy as np
from scipy import fft
import paho.mqtt.client as mqtt
def on_message(client, userdata, msg):
vibration_data = json.loads(msg.payload)
# Collect 1024 samples
samples.append(vibration_data['vibration'])
if len(samples) >= 1024:
# Perform FFT
fft_result = fft.fft(samples)
frequencies = fft.fftfreq(len(samples), 1/100)
# Extract dominant frequencies
dominant_freqs = extract_peaks(frequencies, fft_result)
# Send to cloud
publish_to_cloud(dominant_freqs)
samples.clear()
client = mqtt.Client()
client.connect("cloud.broker.com", 8883)
client.subscribe("factory/vibration")
client.loop_forever()
6. FFT Vibration Analysis
Identify machine faults by frequency signatures:
| Fault Type | Frequency Signature | Severity |
|---|---|---|
| Unbalance | 1Γ RPM | Medium |
| Misalignment | 2Γ RPM, 3Γ RPM | High |
| Bearing Defect | BPFO, BPFI frequencies | Critical |
| Looseness | Multiple harmonics | Medium |
| Electrical Fault | Line frequency (50/60 Hz) | High |
7. Machine Learning Model
# Anomaly Detection with Isolation Forest
from sklearn.ensemble import IsolationForest
import pandas as pd
# Load historical vibration data
data = pd.read_csv('vibration_history.csv')
features = ['rms', 'peak', 'kurtosis', 'skewness']
# Train model on normal operation data
model = IsolationForest(contamination=0.1, random_state=42)
model.fit(data[features])
# Predict anomalies
def predict_fault(current_features):
prediction = model.predict([current_features])
score = model.score_samples([current_features])[0]
if prediction[0] == -1:
if score < -0.5:
return "CRITICAL_FAULT"
else:
return "WARNING"
return "NORMAL"
8. Cloud Platform Integration
AWS IoT Core setup:
# AWS IoT Rule (SQL)
SELECT
machine_id,
timestamp,
vibration_level,
temperature,
anomaly_score
FROM 'factory/+/telemetry'
WHERE vibration_level > 7.0
# Lambda function for alerting
def lambda_handler(event, context):
if event['anomaly_score'] < -0.5:
send_sns_alert(
subject=f"CRITICAL: {event['machine_id']}",
message=f"Vibration anomaly detected!"
)
create_maintenance_ticket(event['machine_id'])
9. Monitoring Dashboard
Grafana dashboard configuration:
- Real-time vibration trend charts
- FFT spectrum waterfall plots
- Machine health score (0-100%)
- Remaining Useful Life (RUL) estimate
- Maintenance history timeline
10. Predictive Alerts
// Alert thresholds
const ALERT_THRESHOLDS = {
WARNING: { vibration: 5.0, temperature: 75 },
CRITICAL: { vibration: 7.5, temperature: 90 },
SHUTDOWN: { vibration: 10.0, temperature: 105 }
};
function checkAlerts(sensorData) {
if (sensorData.vibration > ALERT_THRESHOLDS.SHUTDOWN.vibration) {
triggerEmergencyShutdown(sensorData.machineId);
sendSMSAlert("EMERGENCY: Immediate shutdown required");
} else if (sensorData.vibration > ALERT_THRESHOLDS.CRITICAL.vibration) {
scheduleMaintenance(sensorData.machineId, "24h");
sendEmailAlert("CRITICAL: Maintenance required within 24h");
} else if (sensorData.vibration > ALERT_THRESHOLDS.WARNING.vibration) {
sendEmailAlert("WARNING: Monitor closely");
}
}
11. Industrial Deployment
Safety Requirements:
- Use intrinsically safe sensors in hazardous areas
- Install surge protection on all cables
- Ensure proper grounding (β€1 ohm)
- Follow lockout/tagout procedures during installation
- Use shielded cables for analog signals
12. ROI Calculation
Cost Savings Example (100 motors):
βββββββββββββββββββββββββββββββββββββ
Unplanned Downtime Reduction:
Before: 10 failures/year Γ $50,000 = $500,000
After: 3 failures/year Γ $50,000 = $150,000
Savings: $350,000/year
Maintenance Cost Reduction:
Before: 100 motors Γ 4Γ/year Γ $500 = $200,000
After: 100 motors Γ 2Γ/year Γ $500 = $100,000
Savings: $100,000/year
System Cost: $150,000 (one-time)
Annual Savings: $450,000
Payback Period: 4 months
ROI (3 years): 800%
Next Steps
Expand your IIoT system:
- Add acoustic emission sensors
- Implement digital twin modeling
- Integrate with CMMS (SAP, Maximo)
- Add oil analysis monitoring
- Deploy across multiple production lines
Related Articles:
MQTT Protocol Guide |
PLC & SCADA Integration