5276 questions

6429 answers

10373 comments

6439 members

0 votes
164 views 2 comments
by
Hi,

I simply want to publish the current analog input value over mqtt every [5] seconds, without any interaction/polling from my server. Is this possible?

Previous results on the forum indicate "no", however according to the changelog of the firmware there have been quite some changes over the past months...

Regards,

Dennis

1 Answer

0 votes
by
Yes, you can.

Enable Modbus Tcp Slave at port 502

Add TRB141 as Modbus Slave on Modbus TCP Master

Read 32 bits int / register 142 / length 2 / 1234 order

Data to Server : configure Mqtt JSON Format and remote broker / topic

Option : You can enable TRB Broker on MQTT Tab and Data Sender can publish on it.

That's all.
Best answer
by
Hi,

I'm struggling to follow this / seeing different things on the RUT955

Any chance you could elaborate on the steps (For an idiot... lol )

Thanks
by

Hello,

First read the value at the analog input.
So you must already activate the Modbus TCP Slave service.
https://wiki.teltonika-networks.com/view/RUT955_Modbus#Modbus_TCP

Chapter Modbus TCP Slave > Enable / Port 502 / Device ID 1
See the list of all parameters

>Section Get Parameter: Analog Input Value :
Register Number 142
Length 2
Datatype : 32 bits integer

Chapter Modbus TCP Master
> add a device / Name: MyRUT955 / Slave ID: 1 / IP: Your RUT IP address / Period 5s Timeout 1s
Request Configuration section
> add an instance
> Name: MyAnalog Value / Datatype: 32 bits Integers 1-2-3-4 (byte order)
> Function code 3 (Read)
> First Register : 142
> Number of registers : 2 (ie length)
> Enabled YES

>> Test to visualize your analog value

At this step, the RUT will read its own Modbus registers (here the value of the analog input) every 5s.

Chapter Modbus Data to Server
> Add an instance: Name Analog MQTT / Enable
> Configure how data should be sent
For example: {"ID":"%i", "TS":"%t", "ST":"%s", "VR":"%a"} will give {"ID": "1", "TS": "1603020476", "ST": "142", "VR": "5.000"} (= 5V)
 

Then configure the MQTT protocol, the broker to publish to, the topic (ie analogval) and the period to publish to (5s).
So every 5s, the RUT955 will publish on the topic analogval in MQTT on the chosen broker.

Option: You can publish to the Internal Broker.
To do this, you must already activate it. The Modbus Data Sender will then be able to publish to the broker hosted by your RUT955 (Broker IP: Your IP address, Port 1883).

https://wiki.teltonika-networks.com/view/RUT955_MQTT

This way, your application will be able to subscribe to the topic on which the Modbus Data Sender publishes