Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Reading MODBUS data using RouterOS

As of right nowthis moment, you can only read function code "3" output values. So if the connected MODBUS device can give a response to a Function Code 3 (read Analog Output Holding Registers) command → you can get/print it in the RouterOS terminal, like so:

Code Block
languageros
[admin@device] > {:local output [/iot modbus read-holding-registers slave-id=0x03 num-regs=0x1 reg-addr=0x0 as-value once];:put [($output->"values")]}
2349
[admin@device] > {:local output [/iot modbus read-holding-registers slave-id=0x03 num-regs=0x5 reg-addr=0x0 as-value once];:put [($output->"values")]}
2353;3;500;75;38

Parameters that can vary are "reg-addr","num-regs" and "slave-id". All of them depend on what which values are supported by the MODBUS-connected device.

...