Skip to content

About

AI-powered predictive maintenance automation using n8n, Machine Learning, Gemini AI, Google Sheets, Telegram, and Power BI.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

๐Ÿญ Industrial Predictive Maintenance Platform

AI-driven failure prediction, automated diagnostics, and real-time maintenance alerting for Industrial IoT systems.

๐Ÿ“Œ Overview

The Industrial Predictive Maintenance Platform predicts industrial machine failures before they happen and automates the entire maintenance response โ€” from sensor reading to technician alert โ€” using a modern data engineering and machine learning stack.

Instead of reactive repairs or fixed maintenance schedules, this system continuously evaluates live sensor data, predicts whether a machine will fail within the next 24 hours, classifies the expected failure type, generates AI-powered maintenance recommendations, and pushes real-time alerts to maintenance teams โ€” with results visualized in a Power BI dashboard.


๐ŸŽฏ Objectives

  • โœ… Predict whether a machine will fail within 24 hours
  • โœ… Identify the expected failure type
  • โœ… Generate automated maintenance recommendations
  • โœ… Send real-time alerts to maintenance teams
  • โœ… Provide operational insights through dashboards

๐Ÿ—๏ธ System Architecture

 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  Industrial Sensors โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚   Google Sheets     โ”‚  โ† Data Source
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚   n8n Workflow      โ”‚  โ† Orchestration
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚   FastAPI Service   โ”‚  โ† Model Serving (via ngrok)
 โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
 โ”‚  โ”‚ Model 1:       โ”‚ โ”‚  Failure Prediction (0/1)
 โ”‚  โ”‚ Random Forest  โ”‚ โ”‚
 โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
 โ”‚          โ–ผ           โ”‚
 โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
 โ”‚  โ”‚ Model 2:       โ”‚ โ”‚  Failure Type Classification
 โ”‚  โ”‚ Random Forest  โ”‚ โ”‚
 โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ–ผ  (if failure predicted)
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  Gemini AI Agent    โ”‚  โ† Condition analysis + recommendation
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚   Telegram Bot      โ”‚  โ† Real-time alert to maintenance team
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  Power BI Dashboard โ”‚  โ† Operational insights & KPIs
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿงฐ Tech Stack

Layer Technology
Data Source Google Sheets
Workflow Orchestration n8n
Machine Learning Python, scikit-learn (Random Forest)
API Layer FastAPI
API Exposure ngrok
AI Analysis Google Gemini AI Agent
Notifications Telegram Bot API
Visualization Power BI

๐Ÿ“Š Dataset

Industrial IoT sensor dataset โ€” 24,042 records across four machine types.

Machine types: CNC ยท Pump ยท Compressor ยท Robotic Arm

Features

Feature Description
machine_type Type of industrial machine
vibration_rms Root-mean-square vibration amplitude
temperature_motor Motor temperature reading (ยฐC)
current_phase_avg Average electrical phase current
pressure_level Operating pressure
rpm Rotational speed
operating_mode Current operational state
hours_since_maintenance Hours elapsed since last maintenance
ambient_temp Ambient environmental temperature

Targets

Target Type Values
failure_within_24h Binary 0 = Normal, 1 = Failure
failure_type Multi-class bearing, electrical, hydraulic, motor_overheat, none

๐Ÿค– Machine Learning Pipeline

  1. Data Cleaning โ€” duplicate removal, missing value imputation, outlier handling
  2. Feature Engineering โ€” thermal delta, vibration-to-RPM ratio, maintenance urgency ratio
  3. Label Encoding โ€” categorical variables encoded for tree-based models
  4. Train-Test Split โ€” 80/20 stratified split
  5. Model Training โ€” Random Forest Classifier (two stages)
  6. Model Evaluation โ€” accuracy, precision, recall, F1-score, ROC-AUC
  7. Model Deployment โ€” served via FastAPI, exposed through ngrok

Model Architecture

  • Model 1 โ€” Failure Prediction: binary classifier โ†’ failure_within_24h
  • Model 2 โ€” Failure Type Classification: multi-class classifier โ†’ failure_type (invoked only when Model 1 predicts failure)

โ„น๏ธ Metrics are illustrative of the evaluation methodology โ€” replace with your actual training results.


๐Ÿ”Œ API Reference (FastAPI)

Endpoint Method Description
/predict/failure POST Returns failure_within_24h prediction + probability
/predict/failure-type POST Returns predicted failure_type + class probabilities
/health GET Service health check
/model-info GET Model version & feature schema

โš™๏ธ n8n Workflow

  1. Google Sheets Trigger โ€” polls for new sensor rows
  2. HTTP Request โ†’ /predict/failure
  3. IF Node โ€” branches on failure_within_24h == 1
  4. HTTP Request โ†’ /predict/failure-type (failure branch only)
  5. Gemini AI Agent Node โ€” generates condition analysis & recommendation
  6. Telegram Node โ€” sends alert to maintenance team
  7. Write Node โ€” logs results for Power BI reporting

๐Ÿ“ฒ Sample Telegram Alert

ALERT: Predictive Maintenance System
Machine: CNC-14 | Type: CNC
Status: FAILURE PREDICTED (Probability: 0.91)
Failure Type: Bearing Wear
Recommendation: Replace spindle bearing within 12
hours. Reduce load to 60% until serviced.
Time: 2026-07-19 09:42

๐Ÿ“ˆ Power BI Dashboard

  • KPI cards โ€” machines monitored, active alerts, failures (24h)
  • Failure trend line chart by machine type
  • Failure type distribution (pie chart)
  • Machine health heatmap
  • Recent alerts & recommendations table

๐Ÿ“‚ Project Structure

industrial-predictive-maintenance/
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ sensor_data.csv
โ”œโ”€โ”€ notebooks/
โ”‚   โ”œโ”€โ”€ 01_data_cleaning.ipynb
โ”‚   โ”œโ”€โ”€ 02_feature_engineering.ipynb
โ”‚   โ””โ”€โ”€ 03_model_training.ipynb
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ failure_prediction_rf.pkl
โ”‚   โ””โ”€โ”€ failure_type_rf.pkl
โ”œโ”€โ”€ api/
โ”‚   โ”œโ”€โ”€ main.py
โ”‚   โ”œโ”€โ”€ schemas.py
โ”‚   โ””โ”€โ”€ preprocessing.py
โ”œโ”€โ”€ n8n/
โ”‚   โ””โ”€โ”€ workflow.json
โ”œโ”€โ”€ dashboard/
โ”‚   โ””โ”€โ”€ powerbi_report.pbix
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

๐Ÿš€ Getting Started

1. Clone the repository

git clone https://github.com/<your-username>/industrial-predictive-maintenance.git
cd industrial-predictive-maintenance

2. Install dependencies

pip install -r requirements.txt

3. Run the FastAPI service

uvicorn api.main:app --reload --port 8000

4. Expose the API with ngrok

ngrok http 8000

5. Import the n8n workflow

Import My workflow.json into your n8n instance and configure:

  • Google Sheets credentials
  • FastAPI (ngrok) endpoint URL
  • Gemini AI API key
  • Telegram Bot token & chat ID

6. Open the Power BI dashboard

Open dashboard/powerbi_report.pbix and point it to your results data source.


๐Ÿ”ฎ Future Improvements

  • Replace Google Sheets with a real streaming source (MQTT/Kafka)
  • Deploy FastAPI to a persistent cloud host (AWS/Azure/GCP)
  • Add model drift detection & automatic retraining
  • Support multiple prediction horizons (6h, 24h, 72h)
  • Explore LSTM/TCN models for time-series degradation trends
  • Add authentication & role-based access control
  • Build a technician feedback loop to improve model accuracy

link dashboard https://app.powerbi.com/view?r=eyJrIjoiOWU5YTQ0NTMtYTQ4Mi00OWFiLTlhNDEtOTI1N2UzYzAxMDZkIiwidCI6IjJiYjZlNWJjLWMxMDktNDdmYi05NDMzLWMxYzZmNGZhMzNmZiIsImMiOjl9


About

AI-powered predictive maintenance automation using n8n, Machine Learning, Gemini AI, Google Sheets, Telegram, and Power BI.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages