iot:tutorial:mqtt
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
iot:mqtt [2020/06/12 10:05] – ↷ Links adapted because of a move operation atolstov | iot:tutorial:mqtt [2020/09/21 13:51] – Publisher/Subscriber edit atolstov | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== MQTT Protocol ===== | ===== MQTT Protocol ===== | ||
MQTT today has become an intermediary in IoT communication. | MQTT today has become an intermediary in IoT communication. | ||
- | It is supported by integration controller WebHMI and 7bit brand products such as Synapse, AirPoint and AirGate. | + | It is supported by integration controller WebHMI([[: |
==== What is MQTT? ==== | ==== What is MQTT? ==== | ||
It is a lightweight, | It is a lightweight, | ||
Line 8: | Line 8: | ||
To understand, look at this diagram. | To understand, look at this diagram. | ||
- | {{ iot: | + | {{ iot: |
There is no need in direct connection which is quite fragile and entails overhead. So, the broker is the gamechanger. | There is no need in direct connection which is quite fragile and entails overhead. So, the broker is the gamechanger. | ||
Line 20: | Line 20: | ||
To start, firstly go to “Settings” to make sure that “MQTT Server” is turned on. | To start, firstly go to “Settings” to make sure that “MQTT Server” is turned on. | ||
- | {{ iot: | + | {{ iot: |
- | [[doku>:mqtt|About how to use MQTT on WebHMI]] | + | [[: |
- | ===== WebHMI as MQTT Publisher (Client) ===== | + | ===== WebHMI as MQTT Publisher/ |
There is a possibility to create a WebHMI connection to subscribe or publish MQTT messages. | There is a possibility to create a WebHMI connection to subscribe or publish MQTT messages. | ||
This allows WebHMI register mapping with certain topics on any broker. So editing register value will trigger WebHMI to publish MQTT message and vice versa: if you have an active register, receiving the message from the broker will trigger changing the value. | This allows WebHMI register mapping with certain topics on any broker. So editing register value will trigger WebHMI to publish MQTT message and vice versa: if you have an active register, receiving the message from the broker will trigger changing the value. | ||
Line 42: | Line 42: | ||
TCP Port: 1883 | TCP Port: 1883 | ||
- | {{ iot: | + | {{ iot: |
After that, create a new register into that connection which will represent MQTT topic related to MQTT broker. | After that, create a new register into that connection which will represent MQTT topic related to MQTT broker. | ||
Click "New register" | Click "New register" | ||
Line 51: | Line 51: | ||
Address: iot-test (any name, it is MQTT topic to subcribe and to publish) | Address: iot-test (any name, it is MQTT topic to subcribe and to publish) | ||
Script alias: mqtt_publish | Script alias: mqtt_publish | ||
- | {{ iot: | + | {{ iot: |
Go to “Value” tab to change its type to “String” | Go to “Value” tab to change its type to “String” | ||
- | {{ iot: | + | {{ iot: |
And click " | And click " | ||
- | {{ iot: | + | {{ iot: |
Now, it is time to change registers value manually and check the result response on another client such as Android app, PC clients such as " | Now, it is time to change registers value manually and check the result response on another client such as Android app, PC clients such as " | ||
Let's check the response in MQTT.fx PC client. How to configure it will be shown later. | Let's check the response in MQTT.fx PC client. How to configure it will be shown later. | ||
- | {{ iot: | + | {{ iot: |
In the MQTT.fx will be shown caught changes in the subscribed topics. | In the MQTT.fx will be shown caught changes in the subscribed topics. | ||
- | {{ iot: | + | {{ iot: |
===== Connect to WebHMI MQTT Broker with external client ===== | ===== Connect to WebHMI MQTT Broker with external client ===== | ||
Line 71: | Line 71: | ||
For example, freeware MQTT client “MQTT.fx” will be used. | For example, freeware MQTT client “MQTT.fx” will be used. | ||
---- | ---- | ||
- | {{iot: | + | {{iot: |
\\ | \\ | ||
\\ | \\ | ||
Line 78: | Line 78: | ||
---- | ---- | ||
To do this, let’s create a new connection with the following settings: | To do this, let’s create a new connection with the following settings: | ||
- | {{ iot: | + | {{ iot: |
Click on “+” in the lower left corner and set: | Click on “+” in the lower left corner and set: | ||
Line 89: | Line 89: | ||
Let’s connect to WebHMI Broker by pressing the “Connect” button. | Let’s connect to WebHMI Broker by pressing the “Connect” button. | ||
- | {{ iot: | + | {{ iot: |
If everything is fine than connection will be established, | If everything is fine than connection will be established, | ||
==== From Android client to WebHMI ==== | ==== From Android client to WebHMI ==== | ||
In the Google Play Market, there is a lot of MQTT Client apps. For example, it would be shown the connection with [[https:// | In the Google Play Market, there is a lot of MQTT Client apps. For example, it would be shown the connection with [[https:// | ||
- | {{ iot: | + | {{ iot: |
Line 100: | Line 100: | ||
\\ | \\ | ||
- | {{ iot: | + | {{ iot: |
So, let’s add WebHMI Broker by click “Add first broker” button. | So, let’s add WebHMI Broker by click “Add first broker” button. | ||
Line 110: | Line 110: | ||
- | {{ iot: | + | {{ iot: |
Then, click the “Save” button in the bottom centre position. | Then, click the “Save” button in the bottom centre position. | ||
Line 120: | Line 120: | ||
- | {{ iot: | + | {{ iot: |
To demonstrate how the function works, the " | To demonstrate how the function works, the " | ||
- | {{ iot: | + | {{ iot: |
Pick the “Text” type. | Pick the “Text” type. | ||
- | {{ iot: | + | {{ iot: |
Fill in the “Subscribe topic” form the “iot-test” value and then press “Copy” symbol near “Publish topic” to copy the topics name to this form also. | Fill in the “Subscribe topic” form the “iot-test” value and then press “Copy” symbol near “Publish topic” to copy the topics name to this form also. | ||
Line 135: | Line 135: | ||
- | {{ iot: | + | {{ iot: |
To test the connection, you can try to change the register’s value and check the smartphone' | To test the connection, you can try to change the register’s value and check the smartphone' | ||
- | {{ iot: | + | {{ iot: |
The text message was sent through the MQTT protocol to WebHMI broker and the sent to the Android app. | The text message was sent through the MQTT protocol to WebHMI broker and the sent to the Android app. | ||
- | {{ iot: | + | {{ iot: |
It also works in another direction and can be published from the smartphone. | It also works in another direction and can be published from the smartphone. | ||
iot/tutorial/mqtt.txt · Last modified: 2020/10/21 08:42 by atolstov