Skip to content

IoT-powered​‍​‌‍​‍‌​‍​‌‍​‍‌ smart factory simulation that combines Kafka, MongoDB, and Flask with machine learning-driven insights for Energy Optimization, Predictive Maintenance, and Operational Safety Monitoring.

License

Notifications You must be signed in to change notification settings

kamlesh0928/energy-track

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Energy Track

This​‍​‌‍​‍‌​‍​‌‍​‍‌ project presents a smart factory IoT monitoring system that achieves energy efficiency, predicts equipment failures, and guarantees safety in operations. It emulates a massive industrial IoT device network, fetches the live data using Kafka, applies machine learning analytics, and presents the results on a dashboard.

The setup is a combination of simulated IoT devices, data stream, ML-driven insights, and real-time visualization to allow factory or manufacturing plant energy-efficient operations and predictive ​‍​‌‍​‍‌​‍​‌‍​‍‌maintenance.


Project Overview

The​‍​‌‍​‍‌​‍​‌‍​‍‌ project is a simulation of a large number of virtual IoT devices that include CNC machines, robotic arms, presses, drills, and conveyor belts. Each device perpetually produces sensor data such as temperature, pressure, and current consumption.

The data is a real-time stream by Apache Kafka, is kept in MongoDB, is analyzed by machine learning models, and is shown on a dashboard through Flask APIs and WebSocket connections.

Such an end-to-end system makes it possible to keep track of the performance of the devices, forecasting malfunctions, and create smart suggestions for enhancing energy efficiency and ensuring safety in ​‍​‌‍​‍‌​‍​‌‍​‍‌operations.


Key Features

  • IoT Device Simulation: Simulates hundreds of factory devices sending continuous sensor data.
  • Data Streaming Pipeline: Uses Apache Kafka for efficient real-time message handling and scalability.
  • MongoDB Storage: Keeps device metrics and also sensor data that are fetched from the devices for monitoring and retraining purposes.
  • Machine Learning Insights: Uses a trained Random Forest model to anticipate the occurrence of failures.
  • Optimization Recommendations: Provides the list of actions that will result in the decrease of power consumption as well as the improvement of energy efficiency.
  • Control Layer Simulation: A device restart and shutdown that is remote is enabled through Flask endpoints.
  • Dashboard: Provides live visualization of metrics and system health.
  • Dockerized Deployment: Simplifies setup and scaling through Docker Compose.

Architecture Components

1. Data Simulation (Producer)

Simulates the sensor data in the factory for more than 100 devices. Writes out the data such as temperature, pressure, and current consumption to a Kafka topic called factory-sensor-data.

2. Kafka Stream Processing

It is the core of the real-time data system, which updates the sensor data streams between producers and consumers. Two Kafka topics are used:

  • factory-sensor-data: Raw sensor readings from simulated devices.
  • ml-insights: ML-generated insights and failure predictions.

3. Machine Learning Service

Using a synthetic and a historical sensor data set, a Random Forest model has been trained to predict device failure probabilities.

Besides, it produces the optimization suggestions such as:

  • High failure risk: Inspect machine within 24 hours.
  • High idle energy usage: Consider scheduled shutdown.

The ML model keeps updating by fetching more historical data from MongoDB and retraining.

4. MongoDB Database

That is where all the device states, sensor readings, and ML insights are saved. The historical data records serve as the source for the retraining and pattern analysis.

5. Flask API and WebSocket Server

Provides REST APIs and WebSocket endpoints, which enable real-time monitoring and control. The default API endpoints are:

  • /api/devices – Fetch all registered devices.
  • /api/restart – Simulate a device restart command.
  • /api/shutdown – Simulate a device shutdown command.

6. Frontend Dashboard

Enables the visualization of energy usage, device status, and failure predictions in a browser. Using Next.js, it displays the metrics and allows you to simulate remote ​‍​‌‍​‍‌​‍​‌‍​‍‌control.


Machine Learning Pipeline

  • Model Type: Random Forest Classifier
  • Training Data: Synthetic data generated to simulate factory sensor degradation and anomalies.
  • Target Variable: A Binary classification that indicates equipment failure (0 = Normal, 1 = Failure).
  • Training File: train_model.py
  • Prediction File: ml_consumer.py

Workflow

1.​‍​‌‍​‍‌​‍​‌‍​‍‌ Synthetic data is generated by the train_model.py script or real device data is fetched from MongoDB.

  1. The training goal of the model is to identify the first signs of the failure.

  2. ml_consumer.py uses the trained model (failure_model.pkl) which makes it possible to load the model for real-time prediction.

  3. The predicted insights and suggestions are written back to ​‍​‌‍​‍‌​‍​‌‍​‍‌Kafka.


Technology Stack

  • Programming Language: Python
  • Streaming Framework: Apache Kafka
  • Database: MongoDB
  • Backend Framework: Flask, Flask-SocketIO, Flask-CORS
  • Machine Learning: Scikit-learn, Pandas, NumPy, Joblib
  • Frontend: Next.js
  • Containerization: Docker, Docker Compose

Contributions

Contributions are welcome! If you'd like to contribute, please fork the repository and create a pull request.


License

This project is licensed under the MIT License. Please see the LICENSE file for more information.


About

IoT-powered​‍​‌‍​‍‌​‍​‌‍​‍‌ smart factory simulation that combines Kafka, MongoDB, and Flask with machine learning-driven insights for Energy Optimization, Predictive Maintenance, and Operational Safety Monitoring.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •