Skip to content

ShivamMaurya14/Industrial-IoT-Anomaly-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ AI Based Industrial-IoT-Anomaly-Detector

Open in Streamlit Python 3.8+ License: MIT

A robust, AI-driven application designed to predict equipment failures before they occur. This project leverages machine learning (Random Forest) to analyze sensor data in real-time, helping industries optimize maintenance schedules, reduce downtime, and cut operational costs.

๐Ÿ”ด Live Demo: Click Here

๐Ÿ“ธ Dashboard Previews

1. Manual Diagnostics Mode

Manual Mode Preview

2. Automatic Fleet Monitoring Mode

Automatic Mode Preview

๐Ÿš€ Key Features

  • Quadruple Operation Modes:
    • ๐Ÿ“ˆ Historical Analytics (v4): NEW - Interactive Plotly dashboards charting massive historical timelines of sensor logs and offering direct CSV dataset exports.
    • ๐Ÿ“ก Live IoT Sensor (v3): Connects directly to hardware (ESP32) via a local FastAPI backend. Ingests real-time physical telemetry.
    • ๐Ÿญ Simulation Diagnostics (v2): Real-time dashboard simulating a fleet of 9+ industrial machines. Tracks live telemetry, failure risks, and operational status simultaneously.
    • ๐Ÿ› ๏ธ Manual Diagnostics (v1): Deep-dive analysis for single units. Input sensor parameters manually to stress-test specific scenarios and visualize failure probabilities.
  • Intelligent Prediction Engine: Powered by a trained Random Forest Classifier (models/model.joblib), achieving consistently high accuracy (>98%) in detecting potential failures.
  • Real-time Feature Engineering: Automatically calculates critical derived metrics like Temperature Difference and Mechanical Power on the fly.
  • Professional UI/UX: Dark-mode enabled, responsive design built with Streamlit, featuring interactive metric cards, visual health indicators, and dynamic alerts.

๐Ÿง  Model & Data

The predictive model is trained on a synthetic dataset mirroring real-world industrial sensor data (based on the AI4I 2020 Predictive Maintenance Dataset).

Input Parameters (Sensors)

Feature Unit Description
Air Temperature [K] Ambient room temperature.
Process Temperature [K] Temperature of the manufacturing process.
Rotational Speed [rpm] Speed of the spindle/drive.
Torque [Nm] Torque applied during operation.
Tool Wear [min] Cumulative tool wear time.
Type L/M/H Quality variant (Low, Medium, High).

Output (Prediction)

  • No Failure: โœ… System Healthy
  • Failure: ๐Ÿšจ Maintenance Required (Probability > 50%)

๐Ÿ› ๏ธ Installation & Setup

Follow these steps to set up the project locally.

1. Clone the Repository

git clone https://github.com/ShivamMaurya14/Predictive-Maintenance-System.git
cd Predictive-Maintenance-System

2. Create a Virtual Environment (Optional but Recommended)

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

Ensure you have Python 3.8+ installed.

pip install -r requirements.txt

Note: If requirements.txt is missing, install the core libraries: pip install streamlit pandas numpy scikit-learn joblib

4. Training the Model (Optional)

The project comes with a pre-trained model (models/model.joblib). If you wish to retrain it:

python train.py

This will create a fresh model.joblib file in your models/ directory.

5. Run the Application

The application now features a decoupled microservice architecture (Backend + Frontend). You will need two terminal windows.

Terminal 1 (Backend API):

uvicorn api:app --reload

Terminal 2 (Frontend Dashboard):

streamlit run app.py

๐Ÿ“‚ Project Structure

โ”œโ”€โ”€ api.py                 # FastAPI Backend Server (IoT Data Ingestion)
โ”œโ”€โ”€ app.py                 # Main Streamlit Application (Frontend)
โ”œโ”€โ”€ esp32_firmware/        # C++ firmware for the ESP32 microcontroller
โ”œโ”€โ”€ train.py               # ML Model Training Script (Backend logic)
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ model.joblib       # Serialized Random Forest Model
โ”œโ”€โ”€ dataset/
โ”‚   โ””โ”€โ”€ ai4i2020.csv       # Training Dataset
โ”œโ”€โ”€ nb/
โ”‚   โ””โ”€โ”€ ml-powered-maintenance-smarter-proactive.ipynb  # exploration
โ”œโ”€โ”€ resources/             # Preview images & assets
โ”œโ”€โ”€ requirements.txt       # Python Dependencies
โ”œโ”€โ”€ Makefile               # Automation commands
โ”œโ”€โ”€ LICENSE                # MIT License
โ””โ”€โ”€ README.md              # Project Documentation

๐Ÿญ Industry Applications

This predictive maintenance solution is versatile and can be adapted across various high-stakes industries:

  • Manufacturing & Assembly Lines: Monitor robotic arms, conveyor motors, and CNC machines to prevent production bottlenecks.
  • Energy & Utilities: Track turbine health in wind farms or pumps in hydroelectric plants to avoid catastrophic failures.
  • Transportation & Logistics: Fleet management for heavy trucks or railway rolling stock, ensuring safety and reliability.
  • Oil & Gas: Predictive analytics for drilling equipment and pipeline pressure valves in remote locations.
  • Data Centers: Monitor cooling systems and power generators to maintain 99.9% uptime.

๐Ÿ”ฎ Future Scope & Roadmap

We are constantly evolving to meet Industry 4.0 standards. Here is our vision for the future:

๐Ÿ”— Phase 1: Real-Time Integration

  • IoT & MQTT Connectivity: Direct integration with industrial IoT standards (MQTT/OPC UA) to ingest live sensor streams from PLC controllers.
  • Edge Deployment: Optimizing the model to run on edge devices (Raspberry Pi/Jetson Nano) for ultra-low latency predictions without cloud dependency.

๐Ÿ’พ Phase 2: Enterprise Scalability

  • Time-Series Database (InfluxDB): High-performance storage for historical sensor data to enable long-term trend analysis.
  • API Gateway: Expose prediction results via a RESTful API for integration with existing ERP (SAP/Oracle) or MES systems.

๐Ÿง  Phase 3: Advanced Intelligence

  • Deep Learning (LSTM/GRU): Experimenting with Recurrent Neural Networks to capture complex temporal dependencies in sensor patterns.
  • Root Cause Analysis: Automatic identification of which sensor triggered the failure alert (e.g., "High vibrations caused bearing failure").
  • Digital Twin: Creating a fully interactive 3D digital twin of the factory floor using Unity or Three.js linked to this backend.

๐Ÿค Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any enhancements, bug fixes, or new feature ideas.


Developed with โค๏ธ by Shivam Maurya

About

An Industrial-IoT-Anomaly-Detector . Features a real-time Streamlit dashboard, a Random Forest ML model to detect equipment failures, and a FastAPI backend with SQLite for live ESP32 IoT sensor ingestion.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors