For the complete documentation index, see llms.txt. This page is also available as Markdown.

HiveMQ

Use Case: Manufacturing ..

SCADA

Lets take a brief look at a couple of the challenges that face implementing a SCADA system:

  • Data Silos: Brownfield factories will have manufacturing equipment and backend systems from a wide variety of vendors that produce data in proprietary formats. These formats often create data silos that hinder deep level analysis across the entire factory operation.

  • IT/OT Priorities: A successful modernization project needs to include experts from the operations side (OT) and the enterprise IT side (IT).

SCADA

The goal is to connect the various functions of the factory across a standardized IIoT bus:

  • Automation area: Factory machines, sensors and gateways. Data needs to be able to flow between the machines and the sensors and gateways. The gateways are typically used to communicate with other areas in the factory architecture.

  • Manufacturing area: Systems used to control the factory equipment such as SCADA and MES systems.

  • Factory area: Systems used to manage the entire factory such as PLM (Product Lifecycle Management) and OEE (Overall Equipment Effectiveness) systems.

  • Cloud: Connectivity to the enterprise IT systems of the organization that allows for deeper integration between the OT and IT systems.

The majority of SCADA and MES systems on the market come with support for MQTT.

Unified Namespace (UNS) is a novel solution that allows you to collect data from various industrial IoT (IIoT) systems, add context to it, and transform it into a format that other systems can understand.

UNS
Link to HiveMQ documentation

  1. Ensure the Mosquitto Broker has been stopped.

  1. Copy over the required files.

Docker Network

As we're running quite a few containers on the same server, let's ensure that the containers for each How-To are isolated from each other.

HiveMQ Container

  • This HiveMQ deployment is not secure! It's lacking Authentication and Authorization.

  • Right now any MQTT client can connect to the broker with a full set of permissions.

  • For production usage, add an appropriate security extension and remove the hivemq-allow-all extension.

  • You can download security extensions from the HiveMQ Marketplace (https://www.hivemq.com/extensions/).

  1. Run HiveMQ Docker container.

Flag
Description

--ulimit

imits system resource amounts that individual users can consume

nofile

the maximum number of Open Files/File Descriptors this user can have at one time

--name

name of container

-p 9090

mapped container port. Exposes HiveMQ container Control Center on port 8080 to external 9090

-p 9000

mapped container port. Exposes HiveMQ container Websocket on port 9000

-p 1883

mapped container port. Exposes HiveMQ container TCP Listener on port 1883.

--net

name of isolated Docker network: hivemq

hivemq/hivemq4

Docker Hub image

  1. Log into HiveMQ Control Center.

Link to HiveMQ Control Center

User

admin

Password

hivemq

HiveMQ Control Center

➡️ Next: Generate industrial robot sensor data

Let's publish some sensor data to our HiveMQ broker. Based on the factory area, the data needs to processed in a timely manner.

  • Integration of the automation and manufacturing areas (levels 0-3) requires reliable data exchange between various machines, PLCs, and sensors that have very little memory or computing power. The raw data is is used in positive and negative feedbacks to automatically trigger actuators and alerts.

  • Level 4 aggregated data is usually augmented to provide not only OT daily, weekly, monthly OEE reports but also OT across the organisation - for example the number of cars assembled based on engine / area factory output, manufacturing of chassis , and so on ..

  1. Start the HiveMQ Broker.

Link to Portainer
  1. Take a look at:

~/Streaming/HiveMQ4/scripts/sensor.py

The sensor.py script:

  • loads required libraries

  • sets HiveMQ Broker connection details

  • connects to HiveMQ MQTT broker

  • sets client_id

  • generates random sensor data

  • builds message - data dictionary in JSON format

  • publish topic + message every 1 second

Execute sensor.py

  1. Execute sensor.py script.

  1. Check that the sensor data is being successfully published to HiveMQ.

HiveMQ - Dashboard

CTRL + Z will stop the pyhton script.


Execute subscribe.py

  1. Take a look at:

~/Streaming/HiveMQ4/scripts/subscribe.py

  1. Execute sensor.py script.

  1. Take a look at the stats.

Inbound - Outbound messages

➡️ Next: Consume the data stream in PDI

The data will also be processed within different timeframes:

Level 0: This is the level of sensors, signals, machine, and real-time capabilities. At this level, microseconds and milliseconds are extremely important.

Level 1: On the PLC (programmable logic controllers) or control level, sensing and manipulating takes place within seconds. Real-time is also important here for production processes predictability.

Level 2: This level handles process management for monitoring and supervising. Here, SCADA (supervisory control and data acquisition) systems and HMI (human-machine interface) give operators a first visualization of what’s going on within the factory.

Level 3: The next level is for MES (manufacturing execution systems). This is where manufacturing operations management takes place. Here, we move off the factory floor into the top floor and measure activity in hours.

Level 4: Finally, at the top, there are ERP (enterprise resource planning) systems for business planning and logistics. Processes on this level are typically calculated in days and months.

To achieve integration, the data flow must work between systems on the same level as well as between the levels.

Pentaho Data Integration

Lets subscribe to the industrial/robot/sensor topic retained in HiveMQ and use Pentaho Data Integration to process the data.

  1. Start Pentaho Data Integration:

Again we'll use the sensor.py to generate the data and consume in Pentaho Data Integration.

  1. Execute sensor.py script.

  1. Log into HiveMQ Control Center.

Link to HiveMQ Control Center

User

admin

Password

admin

  1. Check the inbound connections and traffic.

HiveMQ Control Center - Connections
  1. You can also view the stream in MQTT Explorer.

MQTT Explorer - industrial / robot / sensor

The PDI client can pull streaming data from an MQTT broker or clients through an MQTT transformation. The parent MQTT Consumer step runs a child transformation that executes according to the message batch size or duration, allowing you to process a continuous stream of records in near real-time. The child transformation must start with the Get records from stream step.

Additionally, from the MQTT Consumer step, you can select a step in the child transformation to stream records back to the parent transformation. This capability allows records processed by an MQTT Consumer step in a parent transformation to be passed downstream to any other steps included within the same parent transformation.

  1. Open the following transformation:

~/Streaming/HiveMQ4/tr_hive_consumer.ktr

  1. Double click on the MQTT Consumer step.

For further details on the settings: MQTT Consumer

MQTT Consumer - industrial/robot/sensor

Transformation

➡️ Next: Process the sensor records

This step returns records that were previously generated by another transformation in a job. The records were passed to this step using either the Copy rows to result step or the Transformation Executor step. You can enter the metadata of the fields you are expecting from the previous transformation in a job.

  1. Open the following transformation:

~/Streaming/HiveMQ4/tr_process_sensor_data.ktr

Get records - industrial/robot/sensor
  1. Double-click on the JSON Input step and configure with the following settings.

JSON Input - Fields
  • Pull the 'message' - records from the stream

  • Add a timestamp

  • Read the JSON stream

  • Append a file - Project/HiveMQ directory

  1. Open the following file:

~/Streaming/HiveMQ4/HiveMQ4/output/robot_sensor.txt

robot_sensor

Notice the records are being appended.

Last updated

Was this helpful?