02.11.2018, 08:17
Is it a resident or a scheduled script? If it's resident then it will only work once because you are closing the connection via mb:close(). Setting slave id for TCP is optional by standard (255 is used when not set) but some devices might require it.
Start by logging each step return results:
Start by logging each step return results:
Code:
require('luamodbus')
local mb = luamodbus.tcp()
local res, err = mb:open('192.168.201.53')
log('open', res, err)
local res, err = mb:connect()
log('connect', res, err)
local res, err = mb:readinputregisters(54)
log('read', res, err)
mb:close()