LogicMachine script to turn on off Epson projector

Today I created a small script in a KNX object to turn my Epson projector on off via a serial link.

require('serial')
-- device on the LogicMachine connected to the Epson projector
-- ttyUSB0 is typical for a USB RS-232C
-- tested with adapter based on FT232 or CP210x chip.
device = '/dev/ttyUSB0'
-- opens a serial port using the sugested values of Epson manual
-- https://support.math.unipd.it/sites/default/files/epson_emp_835.pdf
port = serial.open(device, { baudrate = 9600, parity = 'none', stopbits = 1  })

-- get value of KNX object
value = event.getvalue()

if (value == true) then
 -- send power on command with returns to make them stick
 char = "PWR ON\r\n"  
 port:write(char)
else
 -- send power off command
 char = "PWR OFF\r\n"  
 port:write(char)
end

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.