This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

F&F LE-03MQ Modbus energy counter
#17
Hi,

Try this: ( i think your second port is RS485-2 but please check this )

Code:
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485-2', 9600, 'N', 8, 1, 'H')
mb:connect()
mb:setslave(1)

-- L1 - N
r1, r2 = mb:readinputregisters(0, 2) 
if r1 then 
  value = lmcore.inttohex(r1, 2) .. lmcore.inttohex(r2, 2) 
  value = knxdatatype.decode(value, dt.float32)  
 currentvalue = grp.getvalue('32/1/1') 
  if currentvalue ~= value then
    grp.update('32/1/1', value)
  end
end

-- L2 - N
r1, r2 = mb:readinputregisters(2, 2) 
if r1 then 
  value = lmcore.inttohex(r1, 2) .. lmcore.inttohex(r2, 2) 
  value = knxdatatype.decode(value, dt.float32)  
  currentvalue = grp.getvalue('32/1/2') 
  if currentvalue ~= value then
    grp.update('32/1/2', value)
  end
end

-- L3 - N
r1, r2 = mb:readinputregisters(4, 2) 
if r1 then 
  value = lmcore.inttohex(r1, 2) .. lmcore.inttohex(r2, 2) 
  value = knxdatatype.decode(value, dt.float32)  
  currentvalue = grp.getvalue('32/1/3') 
  if currentvalue ~= value then
    grp.update('32/1/3', value)
  end
end

mb:close()

BR,

Erwin
Reply


Messages In This Thread
RE: F&F LE-03MQ Modbus energy counter - by Erwin van der Zwart - 23.09.2017, 08:10

Forum Jump: