Modbus TCP to Data to Server

Dear Teltonika Team,

I’m trying to get data from hvac controller to mqtt broker via TRB140 (TRB1_R_00.07.06.4)

I have set up 3 modbus clients to different IP from NAT table
iptables -t nat -A OUTPUT -p tcp --dport 502 -d 192.168.2.101 -j DNAT --to-destination 192.168.2.2:502
iptables -t nat -A OUTPUT -p tcp --dport 502 -d 192.168.2.102 -j DNAT --to-destination 192.168.2.2:502
iptables -t nat -A OUTPUT -p tcp --dport 502 -d 192.168.2.103 -j DNAT --to-destination 192.168.2.2:502


I read data from controller each 5sec

For each client I created Data to Server collection, which sends data each 5sec, with Data filtering by Server IP address

All works ok if I have only one ‘pair’ enabled - client + data sender, Modbus data is sent in period of 5sec
image

But if I enable all 3 clients and senders, than strange things happen, I got multiple mqtt messages
image
with different timestamps, see dots = mqtt messages

Did also a small test…
If i enable 2 Modbus TCP devices, I have multiple mqtt messages for same topic and with same data


looks like mqtt messages are filtered by server IP, but send quantity is equal to overall modbus request count (from 2 devices or more)

What is wrong with this setup ??
@AndzejJ, @anon74548148 - could you advise ??

Any help is appreciated, regards Michal

Hello,

Each collection creates a separate connection to the broker. So if you have 3 collections configured with the same broker, the broker will receive 3 separate messages from each collection.

Perhaps I misunderstood your issue?

Kind Regards,

Correct, each collection makes separate connection
image

But each topic should receive only single message per 5 sec
image
image

But I have multiple messages in ‘single’ timestamp - marked red


with few different ts marks

After I add devices - message count is equal to
number of enabled Data To Send collections (3) times sum of all Modbus requests (6)
3x6 = 18 each 5 sec
image
image
image

Hope this is clear now.

Hello,

How many registers are you reading? What is the ‘segment count’ for Modbus in Data to Server configuration?

Also, could you please try setting Modbus TCP devices (in Modbus TCP client config) to have different delay (0/300/600) and period (3/5/7) times for each device, so that they do not overlap?

What are the results?

It’s a workaround method, so yes, it may not work properly and there can be issues.

Kind Regards,

Andzej

How many registers are you reading? What is the ‘segment count’ for Modbus in Data to Server configuration?
I read 6 registers for 3 devices, each segment count is set to 1 (I tried with Send As Object, same result) to send just one register at once, if count is set to 2 sometimes I get JSON with 2 registers and quicky after is send JSON with one register.

Also, could you please try setting Modbus TCP devices (in Modbus TCP client config) to have different delay (0/300/600) and period (3/5/7) times for each device, so that they do not overlap?
I did several configurations … reconnect enabled, period, start delay, always same result, no change.

In my opinion this must be some bug in firmware, which takes out modbus data from database (sqlite i guess), it takes data out properly with filtering by IP, but a wrong count of readout.

p.s.
in case of Modbus TCP you can specify same IP address for all devices but different Server Id (like Modbus RTU) and still you are able to filter out by this Id. So no need to configure additiona NAT rules to forward IPs

Regards

This topic was automatically closed after 15 days. New replies are no longer allowed.