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.

NetworX (Interlogic) Gateway
#3
I've a meter with a P1 port(=serial). To read the data is use this: 

Code:
lastchar = '!'

require('serial')
port = serial.open('/dev/ttyUSB1', {
  baudrate = 115200,             --DSMR 2/3 = 9600        DSMR 4 = 115200
  databits = 8,                    --DSMR 2/3 = 7            DSMR 4 = 8
  stopbits = 1,                    --DSMR 2/3 = 1            DSMR 4 = 1
  parity = 'none',            --DSMR 2/3 = even        DSMR 4 = none
  duplex = 'full'
})

function readdata(port)
  local char, buf

  buf = {}

  while true do
    char = port:read(1)
    -- error (timeout) or newline, stop
    if char == nil or char == lastchar then
      break
    -- ignore cr char
    elseif char ~= '\r' then
      table.insert(buf, char)
    end
  end

  return table.concat(buf)
end

data = readdata(port)
port:flush()

---------------------------------------------------------------

if data then
 
  AphA = data:match'31.7.0%((%d+.%d+)'
  AphA = tonumber(AphA) 
  grp.update('32/1/74', AphA)

-- "more code"

end
Reply


Messages In This Thread
NetworX (Interlogic) Gateway - by gtsamis - 14.12.2018, 09:38
RE: NetworX (Interlogic) Gateway - by cgn - 19.02.2026, 11:37

Forum Jump: