Define Data Pushing Model (MQTT)
Now that we have tags data from different OT data sources (PLC, OPC .. etc). We'll configure the system to push this real-time data to other systems including:
- MQTT Broker
- Web services
- Azure IoT Hub
- Google IoT Core
- AWS IoT
- Stream Platform/SCADA/Gateway
In this tutorial, we want to publish the real-time tags data to an MQTT broker and also to a web service.
Let's define the first data pushing model (Publish to MQTT broker).
From Stream Explorer, select Data Pushing under Integration and click on the Add button to add a new data pushing job.
Enter a name for this Data Pushing model.
In Push Trigger, leave the defaults, meaning that tag's data will be send to the MQTT broker when there's a value change (Minimum change is 1.00 by default). Data will also be pushed if there's a status change (e.g. from Normal to Hi or from LoLo to Normal).
The data that need to be pushed are being queued to be send each 5 seconds (as configured by default in Push Interval).
First: For the purpose of testing, We'll use the publicly free version of HiveMQ MQTT Broker for this tutorial. You can use any public or local MQTT broker.
- HiveMQ MQTT Broker
Visit this link http://www.hivemq.com/demos/websocket-client/
- Configure the MQTT connection:
Click on "Manage" to configure the MQTT connection.
Define MQTT Topic
You can specify any topic. Let's use /streamdata in this tutorial.
Lastly, configure the required tags to use this data pushing model
Repeat for PUMP1.RUNTIME and OPC.Ramp
Now these three tags (PUMP1.TRIP, OPC.Ramp) are configured to be pushed to HiveMQ MQTT broker on value change or status change. (According to the integration model).
By default, Tag's data are pushed as array of JSON objects as the following:
[
{
"MsgSource": "PLC1",
"TagName": "PUMP1.TRIP",
"RawValue": "1",
"ScaledValue": "1",
"Status": "Alarm",
"ComStatus": null,
"TimeStamp": "2020-02-03 12:21:14"
},
{
"MsgSource": "KEP_SERVER",
"TagName": "OPC.Ramp",
"RawValue": "88",
"ScaledValue": "88",
"Status": "Normal",
"ComStatus": null,
"TimeStamp": "2020-02-03 12:21:14"
}
]
Check the data on HiveMQ client:
Connect
Subscribe to the topic
See the messages streaming