Sending Data Through MQTT
Setting Up The Function Node
This is an optional step. The Function Node is used to transform the
’msg’ object sent by the Client node. The MQTT node sends out the
’msg.payload’ field of the ’msg’ object. This means that it only sends
the value it just read but doesn’t indicate which Item node this value
is connected to. To address this, we will take the ’msg’ object and
create a new one, where ’msg.payload’ contains four fields: timeStamp,
topic (which corresponds to the item
field in the Item Nodes),
browseName and payload as seen in #fig:function-node[2.6].
Setting Up The MQTT Out Node
First, we need to set up the Server
field. To do this, click the pen
icon located to the right of the field#fig:mqtt-merge[2.7]. This action
opens a tab for configuring the broker.
Setting up the broker:
-
Server
field: Here, we enter the IP and PORT of the MQTT broker. -
Other fields can be left at their default values.
Afterward, we configure the Topic
field, to the topic which we wish to
publish on. Other fields can be left at their default settings.
image::step2-mqtt.png[Left side: Properties of the MQTT Broker. Right side: Properties of the MQTT Out node]
Now we connect the Client node to the Function node and the Function node to the MQTT out node#fig:client-func-mqtt[2.8].