08.06.2018, 14:12
Hello,
I have a plain button (non-knx) which I want to control through LM, unfortunately I don't have any analog ports in my LM type. I've read somewhere that I can simply connect the button to RS485 port in the LM (A and gnd). I need a script for that. I've found this script which I modified for me and it does transfer but all I get after pressing the button is 1. There is also a huge delay (when I get 1 I have to wait a while for it to work again, I'm suspecting that this might be because of wrong baudrate. What I need though is to get 1/0 according to the state of that button.
I have a plain button (non-knx) which I want to control through LM, unfortunately I don't have any analog ports in my LM type. I've read somewhere that I can simply connect the button to RS485 port in the LM (A and gnd). I need a script for that. I've found this script which I modified for me and it does transfer but all I get after pressing the button is 1. There is also a huge delay (when I get 1 I have to wait a while for it to work again, I'm suspecting that this might be because of wrong baudrate. What I need though is to get 1/0 according to the state of that button.
Code:
-- open port on first call
if not port then
require('serial')
port = serial.open('/dev/RS485-1', { baudrate = 4800, parity = 'odd', duplex = 'half', databits = 8, stopbits = 1 })
port:flush()
end
-- port ready
if port then
-- read one byte
char = port:read(1, 1)
-- send back if read succeeded
if char then
port:write(char)
end
end
grp.write('30/1/1', char)