Pre-installed application - receiving control commands via MQTT
MQTT messages can be used to change the running direction of the counter (see here) or reset it.
Configuration of the running direction
The running direction is defined by the flag flag4 - Counter_Direction. If the flag has the value 1, the counter will be increased each second by 1; if the flag has the value 0, the counter is stopped; if the flag has the value -1, the counter will be decreased each second by 1.
MQTT is used to set the value of the flag.
A HiveMQ MQTT broker is configured for this. Moreover, three events have been added that subscribe to a certain topic. If messages with the appropriate payload are sent for this topic, the flag flag4 - Counter_Direction will either be set to 1 (payload up to increase the counter), 0 (payload stop to stop the counter) or -1 (payload down to decrease the counter).
Menu Messages → MQTT → edit mqttBrkr1 - HiveMQ_Broker ()
The MQTT broker HiveMQ is configured here. HiveMQ is a public MQTT broker (more information). This broker can then be used to send messages for setting the running direction of the counter.
Menu Events → edit HiveMQ_Counter_Up_Event ()
An event is added here, which subscribes to the topic iot_togo_starterkit/$(SERIALNUMBER)/counter_direction of above added MQTT broker and triggers an action when receiving the payload up, which sets the value of data point flag4 - Counter_Direction to the value 1.
Menu Events → edit HiveMQ_Counter_Down_Event ()
An event is added here, which subscribes to the topic iot_togo_starterkit/$(SERIALNUMBER)/counter_direction of above added MQTT broker and triggers an action when receiving the payload down, which sets the value of data point flag4 - Counter_Direction to the value -1.
Menu Events → edit HiveMQ_Counter_Stop_Event ()
An event is added here, which subscribes to the topic iot_togo_starterkit/$(SERIALNUMBER)/counter_direction of above added MQTT broker and triggers an action when receiving the payload stop, which sets the value of data point flag4 - Counter_Direction to the value 0.
Configuration of the reset
MQTT is used to reset the counter.
A HiveMQ MQTT broker is configured for this. HiveMQ is a public MQTT broker (more information). Moreover, an event has been added that subscribe to a certain topic. If a message with the payload reset is sent for this topic, the flag _flag3 - Counter will be (re)set to 0.
Menu Messages → MQTT → edit mqttBrkr1 - HiveMQ_Broker ()
The MQTT broker HiveMQ is configured here. This broker can then be used to send messages for resetting the counter.
Menu Events → edit HiveMQ_Counter_Reset_Event ()
An event is added here, which subscribes to the topic iot_togo_starterkit/$(SERIALNUMBER)/counter_reset of above added MQTT broker and triggers an action when receiving the payload reset, which sets the value of data point flag3 - Counter to the value 0.
$(SERIALNUMBER) is a fix variable for the serial number of the router here that will be inserted into the topic automatically. For further information to this, refer to the online help of the icom Data Suite under Inserting values in messages. |