15.09.2025, 10:06
You can read multiple registers via a profile but this decimal data type is not supported.
First, use read test to find the correct register address. It can be 40001, 40000 or 0.
Use this script for reading. Keep the relevant RTU port enabled in the Modbus tab. Change device id (2) and address (40001) as needed.
First, use read test to find the correct register address. It can be 40001, 40000 or 0.
Use this script for reading. Keep the relevant RTU port enabled in the Modbus tab. Change device id (2) and address (40001) as needed.
Code:
mbproxy = require('mbproxy')
mb = mbproxy.new()
mb:setslave(2)
r1, r2, r3, r4 = mb:readregisters(40001, 4)
-- read ok
if r1 then
consumption = r1 + r2 / 10000
flowrate = r3 + r4 / 10000
log(consumption, flowrate)
else
log('read failed', r2)
end