An advanced industrial IoT simulator that emulates three production lines (pressing, welding, painting) with sensors compliant with Industry 4.0 standards. It generates realistic data on vibration, temperature, and quality, transmitted via MQTT to a control center with predictive alert logic.
- Production lines publish data with different QoS levels
- The Control Center processes alerts and can integrate with external systems (ERP/SCADA)
- Continuous cycle of generation-transmission-analysis
- Alert logic based on industrial standards
- The JSON file controls operational parameters
- Python classes implement the industrial logic
- Clear separation between configuration and implementation
- Docker and Docker Compose
- Python 3.10+ (for local development only)
# 1. Clone the repository
git clone [https://github.com/fillol/industrial-iot-simulator.git](https://github.com/fillol/industrial-iot-simulator.git)
# 2. Start the infrastructure (and build it)
docker-compose up --build
# 3. Monitor the logs
docker-compose logs -f production-line-1 control-center
# 4. Monitor performance
docker-compose stats.
βββ compose.yml # Defines 4 services: 3 lines + control center
βββ control-center/ # Central monitoring system
β βββ Dockerfile # Image based on Python slim
β βββ main.py # Real-time analysis logic
β βββ requirements.txt
βββ mosquitto/ # High-performance MQTT broker
β βββ Dockerfile # Optimized configuration
β βββ mosquitto.conf # Supports 10K+ msg/sec
βββ publisher/ # Core of the production lines
βββ config/ # Customizable JSON profiles
β βββ line1.json # Pressing (high frequency)
β βββ line2.json # Welding (mixed QoS)
β βββ line3.json # Painting (large payload)
βββ sensors/ # Industry 4.0 sensor library
β βββ base_sensor.py # Abstract class with payload generation
β βββ VibrationSensor.py # Machine health monitoring (ISO 10816)
β βββ TemperatureSensor.py # Thermal management (ISO 13732)
β βββ QualitySensor.py # Quality control (AI-driven)
βββ requirements.txt
-
Implementation: The business logic of each sensor is implemented in a separate Python class.
-
Configuration: Each line is defined in a JSON file (
line1.json, etc.) with:{ "line_id": "PRESS-LINE-1", "sensors": [ { "type": "vibration", "interval": 0.5, // Frequency in seconds "payload": "small", // Payload size (small/medium/large) "qos": 2 // MQTT Quality of Service level } ] } -
Data Generation:
- VibrationSensor: 3D accelerations (x,y,z), FFT data, spectral metadata.
- TemperatureSensor: Motor/bearing/coolant temperatures with time trends.
- QualitySensor: Defect count, defect coordinates, simulated image hash.
- Subscription: Monitors all
factory/#topics. - Alert Logic:
if payload.get('x', 0) > 8.0: # Vibration above 8 mm/s logger.warning(f"High vibration! {payload['x']} mm/s") if payload.get('defect_count', 0) > 3: # More than 3 defects logger.error("Quality alert!")
- Optimized configuration for high traffic:
allow_anonymous true max_connections 1000 message_size_limit 0 # Payloads up to 256MB (configurable)
| Category | Size | Frequency | Use Case | Example Line |
|---|---|---|---|---|
| Small | 1-10 KB | 0.5-2 sec | Real-time monitoring | PRESS-LINE-1 |
| Medium | 10-100 KB | 2-5 sec | Historical trends | WELDING-LINE-2 |
| Large | 100 KB - 1 MB | 5-10 sec | Big Data/Analytics | PAINT-LINE-3 |
Configuration Example (line2.json & line1.json):
{
"sensors": [
{
"interval": 10.0, // Aligned with inspection cycles
"payload": "large", // High-resolution image details
"qos": 2 // Guaranteed for traceability
},
{
"interval": 0.5, // Aligned with fast production cycles
"payload": "small", // Optimized for latency <100ms
"qos": 2 // Guaranteed for critical data
}
]
}- Reference Standard: ISO 10816-3 (Vibrations in industrial machinery)
- Key Parameters:
{ "x": random.uniform(2.0, 15.0), # Typical range for CNC [mm/sΒ²] "fft": [random.random() for _ in range(100)], # Frequencies 0-1kHz "metadata": { "samples": size//1000 # Simulates 24-bit acquisition } }- Alarm Thresholds:
- Warning: >8 mm/sΒ² (imminent damage)
- Critical: >15 mm/sΒ² (failure within 24h)
- Alarm Thresholds:
- Reference Standard: ISO 13732-1 (Thermal contact)
- Technical Data:
{ "motor_temp": random.uniform(30.0, 90.0), # Class F insulation "bearing_temp": random.normalvariate(60.0, 5.0), # Gaussian distribution "trend": [...] # Data for thermographic analysis }- Critical Thresholds:
- Motor: >85Β°C (efficiency loss)
- Bearings: >70Β°C (accelerated wear)
- Critical Thresholds:
- AI-driven Metrics:
{ "defect_count": random.randint(0, 5), # Defect density/mΒ² "image_meta": { "size_kb": target_size//1024, # Simulates 1-5MP images "defect_coordinates": [...] # XY system 1000x1000 } }- Alert: >3 defects/batch (automotive production limit)
Modify the line's JSON file (e.g., line1.json) without touching the Python code:
- Add a new sensor to the
sensorsarray:{ "type": "temperature", // Type corresponding to an existing Python class "interval": 3.0, // New frequency (seconds) "payload": "medium", // Data size (small/medium/large) "qos": 1 // MQTT priority (0/1/2) } - Restart the container:
docker-compose up --build production-line-1
- Create a new JSON file in
publisher/config/(e.g.,line4.json):{ "line_id": "ASSEMBLY-LINE-4", // Unique ID "sensors": [ { "type": "vibration", // Must correspond to an implemented sensor (VibrationSensor.py) "interval": 1.5, "payload": "medium", "qos": 2 }, { "type": "quality", "interval": 5.0, "payload": "large", "qos": 2 } ] } - Add a new service in
compose.yml:production-line-4: build: ./publisher volumes: - ./publisher/config/line4.json:/app/config/line4.json # Mount the new file environment: - CONFIG_FILE=line4.json # Specify the configuration networks: - industry-net depends_on: - mosquitto
- Start the new line:
docker-compose up --build production-line-4
- Dynamic Binding: The Python code looks up sensor types in the JSON and maps them to the corresponding classes (e.g.,
"type": "vibration"βVibrationSensor.py). - Docker Volumes: JSON files are mounted as volumes, allowing "hot" modifications without rebuilding images.
- Separation of Concerns: Logic (Python) and configuration (JSON) are decoupled, following the ISA-95 standard for industrial control systems.
π Note: To add a completely new sensor type (e.g., PressureSensor), you will need to:
- Create a new Python class in
sensors/(e.g.,PressureSensor.py). - Register it in
sensors/__init__.py. - Reference it in the JSON with
"type": "pressure".
-
Custom Alert Rules Modify
control-center/main.py:# Example: Alert for motor temperature >85Β°C if payload.get('motor_temp', 0) > 85.0: logger.critical(f"Motor overheating: {payload['motor_temp']}Β°C")
-
Payload Sizes Modify the ranges in
base_sensor.py:{ "small": (1024, 10240), # 1KB-10KB "medium": (10240, 102400), # 10KB-100KB "large": (102400, 1048576) # 100KB-1MB }
-
Simulating specific environments:
# In TemperatureSensor.py def _generate_specific_data(self, size): return { "motor_temp": random.uniform(40.0, 110.0), # Simulate overheating "bearing_temp": random.normalvariate(60.0, 5.0) # Gaussian distribution }
-
Simulating scheduled failures:
# In TemperatureSensor.py def _generate_specific_data(self, size): if random.random() < 0.01: # 1% failure probability return {"motor_temp": 95.0, "status": "CRITICAL"}
-
Optimizing MQTT Performance:
# mosquitto.conf max_packet_size 268435456 # 256MB for image payloads message_size_limit 0 # Disable single message limit -
Adapting to ISO specifications:
# In VibrationSensor.py ISO_10816_THRESHOLDS = { "class_II": {"warning": 8.0, "critical": 12.0} # Medium-large machines }
This simulator provides a comprehensive framework for:
- Testing scalable IIoT architectures
- Validating QoS policies in real-world scenarios
- Developing predictive maintenance algorithms
- Integrate a Grafana dashboard to visualize data in real-time
- Support TLS authentication for MQTT
- Implement a centralized logging system (ELK Stack)