I am looking for an example for a serial input.
The data is comming from an ip-adapter
I get data in (only the last digit of the message is visible) so i am looking for a example to process the data
any idea or guidance
rgds
Huib
I am looking for an example for a serial input.
The data is comming from an ip-adapter
I get data in (only the last digit of the message is visible) so i am looking for a example to process the data
any idea or guidance
rgds
Huib
Hi,
Almost a year ago I developed a program to monitor a Dutch Remeha Quinta boiler.
I use a IP to serial adapter and the serial side is converted to RS485 to communicate with the Remeha.
I copy in the I_RemehaQuinta.xml so you can have a look how serial data should be handled (at least, how I handle the data)
Good luck
<?xml version="1.0"?> rs232 raw bit = require("bit"); reken = require("math"); serialData = {}; remehaTable = {}; remehaTable [1] = {}; remehaTable [2] = {}; curTable = 0; --0 = remehaTable[1] of 1 = remehaTable[2] getRemehaIndentification = "\007\066\160\000\005\064\210"; getRemehaTable0 = "\006\064\174\000\008\004"; getRemehaTable1 = "\006\064\174\008\008\252"; getRemehaTable2 = "\006\064\174\016\008\244"; getRemehaTable3 = "\006\064\174\040\008\220";–Remeha constante voor berekening van toerental
constant = 7500000;
–Remeha Table 0 content (BYTES NA EERSTE 4)
aanvoerTemp = -1; --Byte 0
retourTemp = -1; --Byte 1
boilerTemp = -1; --Byte 2
buitenTemp = -1; --Byte 3
rookgasTemp = -1; --Byte 4
toerentalDeel1 = -1;–Byte 5
toerentalDeel2 = -1;–Byte 6
setPoint = -1; --Byte 7
–Remeha Table 1 content
–Remeha statuscode en strings
ketelStatus = {
“0: Rust geen warmtevraag”,
“1: Voorventileren/naventileren”,
“2: Ontsteking”,
“3: Branden op CV”,
“4: Branden op warmwater”,
“5: Wacht op luchtdrukschakelaar”,
“6: Ketel uit in CV stand”,
“7: Nadraaien pomp in CV-stand”,
“8: Nadraaien pomp in ww-stand”,
“9: Brander uit bij aanvang T1set”};
serialByteIndex = tonumber(0);
function lug_startup (lul_device)
luup.log ("Started polling Remeha Quinta");
luup.call_timer("doPollRemeha", 1, "1", "");
end;
function table0_changed()
--aanvoerTemp = remehaTable[1] [5];
--retourTemp = remehaTable[1] [6];
--boilerTemp = remehaTable[1] [7];
--buitenTemp = remehaTable[1] [8];
--rookgasTemp = remehaTable[1] [9];
toerentalDeel1 = remehaTable[1] [10];
toerentalDeel2 = remehaTable[1] [11];
--setPoint = remehaTable[1] [12];
toeren = (bit.lshift(remehaTable[1] [10], 8) + remehaTable[1] [11]);
if (toeren > 0) then
toeren = math.floor(constant / toeren);
else
toeren = 0;
end;
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQAanvoer", remehaTable[1] [5], lul_device);
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQRetour", remehaTable[1] [6], lul_device);
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQToeren", toeren, lul_device);
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQSetPoint", remehaTable[1] [12], lul_device);
end;
function table1_changed()
if (bit.band(remehaTable[2] [6], 1) == 1) then
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQBvraag", "Ja", lul_device);
else
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQBvraag", "Nee", lul_device);
end;
if (bit.band(remehaTable[2] [6], 4) == 4) then
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQLds", "Gesloten", lul_device);
else
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQLds", "Geopend", lul_device);
end;
if (bit.band(remehaTable[2] [6], 8) == 8) then
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQWvraag", "Ja", lul_device);
else
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQWvraag", "Nee", lul_device);
end;
if (bit.band(remehaTable[2] [6], 64) == 64) then
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQGasDruk", "Nee", lul_device);
else
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQGasDruk", "Ja", lul_device);
end;
if (bit.band(remehaTable[2] [6], 128) == 128) then
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQIonisatie", "Nee", lul_device);
else
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQIonisatie", "Ja", lul_device);
end;
if (bit.band(remehaTable[2] [7], 1) == 1) then
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQGasKlep", "Gesloten", lul_device);
else
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQGasKlep", "Geopend", lul_device);
end;
if (bit.band(remehaTable[2] [7], 4) == 4) then
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQKlep", "Stand WW", lul_device);
else
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQKlep", "Stand CV", lul_device);
end;
if (bit.band(remehaTable[2] [7], 64) == 64) then
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQPomp", "In Bedrijf", lul_device);
else
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQPomp", "Uit Bedrijf", lul_device);
end;
luup.variable_set ("urn:micasaverde-com:serviceId:RemehaQuinta1", "RQStatus", ketelStatus[remehaTable[2] [11] + 1], lul_device);
luup.variable_set("urn:schemas-JS:serviceId:Messenger1", "newMessage", "RQ" .. ketelStatus[remehaTable[2] [11] + 1], 39);
end;
function doPollRemeha()
cleanUp();
luup.call_delay("dataCheck", 2, "Johannes");
if (curTable == 0) then
luup.io.write(getRemehaTable0);
end;
if (curTable == 1) then
luup.io.write(getRemehaTable1);
end;
curTable = curTable + 1;
if (curTable > 1) then
curTable = 0;
end;
luup.call_timer("doPollRemeha", 1, "5", "");
end; --doPollRemeha
function cleanUp()
for i = 1, #serialData do
table.remove(serialData, 1);
end;
serialByteIndex = 0;
end;
function dataCheck()
local Chk = tonumber(0);
local dataChanged = tonumber(0);
if (#serialData ~= 13) then
return;
end;
for i = 1, 13, 1 do
Chk = Chk + tonumber(serialData[i]);
if (Chk > 255) then
Chk = Chk - 256;
end;
end;
if (Chk ~= 0) then
return;
end;
if (serialData[4] == 0) then
tableIndex = tonumber(0);
else
tableIndex = tonumber(1);
end;
for i = 1, 13, 1 do
if (serialData[i] ~= nil) then
if (remehaTable[tableIndex + 1] [i] ~= serialData[i]) then
remehaTable[tableIndex + 1] [i] = serialData[i];
dataChanged = 1;
end;
end;
end;
if (dataChanged == 1) then
if (tableIndex == 0) then
table0_changed();
end;
if (tableIndex == 1) then
table1_changed();
end;
end;
end; --dataCheck
</functions>
<incoming>
<lua>
serialByteIndex = serialByteIndex + 1;
serialData[serialByteIndex] = string.byte(lul_data);
</lua>
</incoming>
<startup>lug_startup</startup>
<actionList>
</actionList>
two questions; one of my future things to develop is the boiler part, so if you are willing to share your files it would be appriciated very much. I have my self a remehe avant boiler, and the protocol looks the same.
second querrie;
<lua>
serialByteIndex = serialByteIndex + 1;
serialData[serialByteIndex] = string.byte(lul_data);
</lua>
does this make the one by one data in to one string
I see that the data is seen but only digit by digit
rgds and thanks
Huib
same querrie for
<commUse>rs232</commUse>
<protocol>raw</protocol>
i know the raw notation, but what does rs232 do?
and
bit = require(“bit”);
reken = require(“math”);
do i have to install this programs?
rgds
Huib
Hi,
About:
serialByteIndex = serialByteIndex + 1;
serialData[serialByteIndex] = string.byte(lul_data);
Every time a character is recieved, it is appended to serialData.
About:
i know the raw notation, but what does rs232 do?
This tells Vera to use rs232 for input/output
About:
bit = require(“bit”);
reken = require(“math”);
As far as I remember these libraries are already on your Vera.
Just type the lines into your program and you can use these libraries.
I attached a zip file, containing all the files you need to create the RemehaQuinta device.
Best Home Automation shopping experience. Shop at Ezlo!
© 2024 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules