IoT

Building a Predictive Maintenance System With Off-the-Shelf IoT Hardware

khaled January 8, 2023 4 mins read
Building a Predictive Maintenance System With Off-the-Shelf IoT Hardware

Building a Predictive Maintenance System With Off-the-Shelf IoT Hardware

Industrial predictive maintenance has historically required expensive proprietary platforms, specialists, and long integration timelines. The combination of commodity MEMS sensors, affordable single-board computers, open-source ML frameworks, and cloud IoT services has changed this equation dramatically. A functional predictive maintenance system for rotating machinery can be built and deployed in weeks, not months — for a fraction of the cost of traditional solutions.

What Predictive Maintenance Actually Detects

Predictive maintenance (PdM) uses sensor data to detect degradation before it becomes failure. For rotating machinery (motors, pumps, fans, compressors), the key early-warning signals are:

  • Vibration anomalies: bearing defects, imbalance, and misalignment produce characteristic frequency signatures in vibration spectra before causing audible noise or performance degradation
  • Temperature rise: increased friction from worn bearings or insufficient lubrication raises component temperature
  • Current draw changes: motor current increases as mechanical load increases due to mechanical wear
  • Acoustic emissions: high-frequency sound in the ultrasonic range precedes audible bearing failure by weeks

Hardware Stack

Sensors:

  • MEMS vibration sensor (e.g., ADXL345 or MPU-6050): $2-5 each, 3-axis accelerometer, I²C or SPI interface
  • NTC thermistor or DS18B20 temperature sensor: $1-2, adequate for bearing housing temperature
  • Current transformer (SCT-013): $5-10, clip-on, measures motor current non-invasively

Edge gateway:

  • Raspberry Pi 4 or equivalent: $50-80, capable of running Python, TensorFlow Lite, and MQTT
  • NVIDIA Jetson Nano if you need GPU inference: ~$100

Connectivity:

  • Ethernet or WiFi for the gateway
  • I²C or UART to the sensors (if wired) or BLE/Zigbee for wireless sensor nodes

Total hardware cost per machine: $70-150. Compare this to $5,000-50,000 per machine for enterprise PdM platforms.

Data Collection and Feature Engineering

Vibration signals require high-frequency sampling (typically 1-8 kHz) to capture bearing defect frequencies. From raw time-domain vibration samples, the most useful features are frequency-domain:

  1. FFT (Fast Fourier Transform): converts time-domain vibration to frequency spectrum
  2. RMS amplitude: overall vibration level, simple baseline metric
  3. Kurtosis: statistical measure sensitive to impulsive events typical of bearing spalling
  4. Bearing defect frequencies: BPFO, BPFI, BSF, FTF — calculable from bearing geometry and shaft speed

Store raw data during initial commissioning (minimum 2-4 weeks of normal operation) to establish a baseline.

Building the Anomaly Detection Model

With 2-4 weeks of "healthy" vibration data, you can train an autoencoder anomaly detector:

  1. Compute FFT features from each vibration window (e.g., 1024-sample windows at 4 kHz sampling rate)
  2. Train an autoencoder (encoder → bottleneck → decoder) on healthy-state features
  3. The model learns to reconstruct normal vibration patterns
  4. At inference, compute reconstruction error: high error = anomaly
import numpy as np
from tensorflow import keras

# Build simple autoencoder
input_dim = 512  # FFT feature size
encoder = keras.Sequential([
    keras.layers.Dense(128, activation='relu'),
    keras.layers.Dense(32, activation='relu'),
])
decoder = keras.Sequential([
    keras.layers.Dense(128, activation='relu'),
    keras.layers.Dense(input_dim, activation='linear'),
])
autoencoder = keras.Sequential([encoder, decoder])
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(X_train, X_train, epochs=50, batch_size=32)

Set the anomaly threshold at the 99th percentile of training reconstruction errors.

Deployment and Alerting

Convert the trained model to TensorFlow Lite for edge inference. Run inference on the gateway every 5-10 minutes (not continuously — duty cycle to save CPU). When reconstruction error exceeds the threshold:

  1. Log the anomaly with timestamp and machine ID to a time-series database (InfluxDB)
  2. Publish an MQTT message to an alert topic
  3. Send an email/SMS notification with the magnitude and type of anomaly

Validation and Iteration

The first 30 days of deployment will produce false positives. Track every alert:

  • True positive: maintenance inspection confirms degradation
  • False positive: inspection finds no issue; adjust threshold upward or add more features

As you accumulate labeled fault examples, you can upgrade from unsupervised anomaly detection to a supervised classifier that identifies the failure type (imbalance, misalignment, bearing fault), providing more actionable maintenance guidance.

Conclusion

Off-the-shelf IoT hardware combined with open-source ML tools has democratized predictive maintenance. The barrier is no longer cost or tooling — it is the time to collect baseline data and the operational discipline to respond to alerts. For any organization with rotating machinery, a simple vibration-based PdM system delivers measurable ROI within months.

Keywords: predictive maintenance, IoT, vibration analysis, anomaly detection, MEMS sensors, Raspberry Pi IoT, machine learning maintenance, bearing fault detection