Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 15133

Scripting • Reading Modbus coils and registers

$
0
0
Hi,

I'm trying to create a script reading Modbus coils and registers with the new command, transceive and publish it with MQTT to a broker.
In the Terminal, the values return as expected using the transceive command, but cannot publish it with MQTT.

This is the line I use for the ModBus query:
Code:
:local modbus ([/iot modbus transceive address=1 function=3 data=00090010]->"values")
Then publish this with MQTT:
Code:
:local message "{$[:tostr $modbus]}"/iot mqtt publish broker=$broker topic=$topic message="{\"Values\":\"$message\"}"
This produces an empty string.
Is there an option to get the values from the ModBus qurery? (The "old" read holding registers is not an option, because I must use other than 3 codes also.)

Thank you!

Statistics: Posted by mrangics — Mon Jan 29, 2024 7:23 pm



Viewing all articles
Browse latest Browse all 15133

Trending Articles