02.05.2020, 18:17
I want to read the dutch smart meter, the p1 meter script is perfect for that.
but the only thing is the my LM is not near the smart meter.
I have a raspberry-pi next to the smartmeter with ser2net installed. how can I change this part of the script to use the ser2net?
Thanks,
Mischa
but the only thing is the my LM is not near the smart meter.
I have a raspberry-pi next to the smartmeter with ser2net installed. how can I change this part of the script to use the ser2net?
Code:
lastchar = '!'
require('serial')
port = serial.open('/dev/ttyUSB0', { -- Let op type van de slimme meter voor de onderstaande instellingen.
baudrate = 9600, --DSMR 2/3 = 9600 DSMR 4 = 115200
databits = 7, --DSMR 2/3 = 7 DSMR 4 = 8
stopbits = 1, --DSMR 2/3 = 1 DSMR 4 = 1
parity = 'even', --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()
---------------------------------------------------------------
Mischa