In this guide, the MQTT Serial Gateway function will be configured using third-party MQTT Broker services (in this example, ''Flespi.io'').
This article contains instructions on how to send M-Bus data to the server using various protocols.
==Configuration overview & prerequisites==
==Configuration overview & prerequisites==
*Two devices with serials ports - one acts as Modbus RTU Master, another as Modbus RTU Slave;
Before we begin, let's take a look at the configuration that we are attempting to achieve and the prerequisites that make it possible.
*Flespi.io account to act as an MQTT Broker/Publisher/Subscriber (for first configuration example);
[[File:MQTT Serial gateway topology v2.png|border|center|class=tlt-border|847x279px]]
'''Prerequisites''':
* TRB143;
* M-Bus device;
* Server;
* An end device (PC, Laptop, Tablet, Smartphone) for configuration;
RUT2 will act as a Modbus RTU slave and RUT1 as a Modbus RTU Master. On RUT1, MQTT Serial Gateway will be configured to transfer Modbus data over MQTT. Flespi.io platform will serve as an MQTT Broker
|a string used to identify a serial device. Must match with <u>Device ID</u> field in MQTT Gateway page Serial gateway configuration section
|-
|4. Timeout
|timeout for Modbus connection, in seconds. Range [1..999].
|-
|5. Slave ID
|Indicates to which slave request is sent
|-
|6. Modbus function
|Modbus task type that will be executed. Possible values are:
<ul>
<li><b>1</b> - read coils;</li>
<li><b>2</b> - read input coils;</li>
<li><b>3</b> - read holding registers;</li>
<li><b>4</b> - read input registers;</li>
<li><b>5</b> - set single coil;</li>
<li><b>6</b> - write to a single holding register;</li>
<li><b>15</b> - set multiple coils;</li>
<li><b>16</b> - write to multiple holding registers.</li>
</ul>
|-
|7. First register
|number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.
|-
|8. Registry count
| <li><b>1</b> - <u>coil count</u> (in range [1..2000]); must not exceed the boundary (first coil number + coil count <= 65537);</li>
<li><b>2</b> - <u>input count</u> (in range [1..2000]); must not exceed the boundary (first input number + input count <= 65537);</li>
<li><b>3</b> - <u>holding register count</u> (in range [0..125]); must not exceed the boundary (first register number + holding register count <= 65537);</li>
<li><b>4</b> - <u>input register count</u> (in range [0..125]); must not exceed the boundary (first register number + input register count <= 65537);</li>
<li><b>5</b> - <u>coil value</u> (in range [0..1]);</li>
<li><b>6</b> - <u>holding register value</u> (in range [0..65535]);</li>
<li><b>15</b> - <u>coil count</u> (in range [1..1968]); must not exceed the boundary (first coil number + coil count <= 65537); and <u>coil values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with coil count); each value must be in the range of [0..1].
|}
====Examples====
----
{| class="wikitable"
|Setting relay (on) (Relay address is 202, which means 'Number of first register will be 203)
|'''1 1 1 1 1 6 203 1'''
|-
|Getting temperature
|'''1 1 1 1 1 3 6 2'''
|}
Modbus parameters are held within registers. The register numbers and corresponding system values can be found [[RUT955_Monitoring_via_Modbus#Get_Parameters|'''in this article''']].
==Testing MQTT Publisher and Subscriber on flespi.io==
====Adding Flespi Subscriber====
----
To test the Modbus Serial Gateway functionality, '''log into''' your '''Flespi account''' → '''MQTT Board''' and '''add a Subscriber''':
#Press '''''<nowiki/>'+'''''' button on the top right corner
#Select '''''<nowiki/>'Subscriber''''''
# In the topic field enter '''''<nowiki/>'response''''''
In the output, we can see that router's '''temperature''' is '''44 degrees Celsius'''.
==See Also==
==See Also==
Revision as of 10:49, 24 July 2024
The information on this page is updated in accordance with the 00.07.4 firmware version .
Summary
This article contains instructions on how to send M-Bus data to the server using various protocols.
Configuration overview & prerequisites
Before we begin, let's take a look at the configuration that we are attempting to achieve and the prerequisites that make it possible.
Prerequisites:
TRB143;
M-Bus device;
Server;
An end device (PC, Laptop, Tablet, Smartphone) for configuration;
If you're having trouble finding this page or some of the parameters described here on your device's WebUI, you should turn on "Advanced WebUI" mode. You can do that by clicking the "Advanced" button, located at the top of the WebUI.
Adding M-Bus devices
To add a new device to the configuration press button which is shown below.
Configure your device accordingly:
Name: Enter the desired name of the M-Bus device
Address type: select which M-Bus address will be used
Primary/Secondary address: specify M-Bus address
Test if the M-Bus device is reachblae by specify address. To do so click on . You migth get two outputs: