5 minute read
Advantages:
Disadvantages:
We will do this in four steps. You can also download our example flows.json, where you just need to change your authentication parameters (certificates or username / password, host, etc.) and you are ready to go.
MQTT-In node in Node-RED
As a first step we take all relevant data out of the MQTT broker and thereby starting a Node-RED flow. Add a MQTT-In node. The MQTT broker details should already been set if you have used our recommended installation method (see also Getting Started).
If not, you can connect on factorycube-edge with the URL: factorycube-edge-emqxedge-service
under the port 1883.
In the Topic section you can specify what messages from which asset you want to send to Azure IoT Hub using wildcards. If you want to send all messages you can use ia/#
as a topic. If you just want to send process values of all machines in plant3
of customer factoryinsight
you can use:
ia/factoryinsight/plant3/+/processValue
MQTT-In node in Node-RED - detailed view
You can test the flow by adding a debug node and connecting it the MQTT-In node with it.
Azure by default does not support the topic structure of the United Manufacturing Hub. As it contains important infortmation, e.g., the asset that the message is about, we will put that into the payload as well.
json and function node in Node-RED
Add a json node AND a function node with the following content and connect it to the MQTT-In node that we previously created:
msg.payload = {
"topic": msg.topic,
"payload": msg.payload
}
msg.topic = ""
return msg;
Code pasted into Node-RED
Verify by connecting it with the debug node.
We recommend following the steps in the article Connecting Node-Red to Azure IoT Hub using MQTT nodes from Nikhil Kinkar. He is using symmetric encryption. For asymmetric encryption edit the TLS configuration and upload there your certificates.
MQTT-out node for connecting Node-RED with Azure IoT
You should have the connection parameters (username, host, port, etc.) already available, if not go to Prerequisites
If necessary: as root CA you need to use the Baltimore CyberTrust Root
Do not forget to set the topic as well (see also the tutorial above):
MQTT-out node - topic and server
MQTT-out node - MQTT broker (1/2)
MQTT-out node - MQTT broker (2/2)
Connect it with the previously created function node and test it. If everything went well the messages should now appear in the device explorer in Azure IoT Hub.
The entire flow
Finding the iothubowner SAS token in Azure
Open the Azure IoT Explorer and connect using your iothubowner SAS token (see image above). If everything went well you should see messages coming up (assuming that there are messages in the local MQTT broker. If not, try to send some debug messages to test the connection).
Messages arriving in the Azure IoT Hub Explorer
For more information about how to use the Azure IoT Explorer, take a look into the official documentation
Currently specifying the username, which is required for Azure IoT Hub, is still in development. See also GitHub issue #569 for more information
Advantages:
Disadvantages:
In the setup script or in the Helm chart adjust the following values with the corresponding certificates:
As mqttBridgeCACert you need to use the Baltimore CyberTrust Root
Furthermore, please set username
, host
, port
, etc. accordingly
If you do not know where to get the certificates or the connection parameters, please go back to Prerequisites
Now we send the data to Azure IoT Hub. But what to do now? Here are some ideas:
factorycube-server
on Azure Kubernetes Service. You would then be able to immediately start creating dashboard while leveraging Azure’s scalability