Back to IoT Blog
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.

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

ComponentSpecificationPurpose
AccelerometerADXL345 or MPU6050Vibration measurement (Β±16g)
Edge GatewayRaspberry Pi 4FFT analysis & data aggregation
MicrocontrollerESP32 or ArduinoSensor data acquisition
Temperature SensorDS18B20Motor temperature monitoring
Current SensorSCT-013Power consumption tracking
EnclosureIP65 NEMAIndustrial 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 TypeFrequency SignatureSeverity
Unbalance1Γ— RPMMedium
Misalignment2Γ— RPM, 3Γ— RPMHigh
Bearing DefectBPFO, BPFI frequenciesCritical
LoosenessMultiple harmonicsMedium
Electrical FaultLine 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:

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