Controlling Epson Projector via RS-232

I’m trying to use the RS-232 Serial port on my raspberri pi to simply turn on and off my Epson projector. For hardware, I’m using a MAX3232 based RS-232 module with the RX and TX crossed. When I run the following python code I can see a ‘status’ LED blink… so something is happening but there is absolutely no response. Just throwing this out there since someone must have been successful doing something similar. Does anyone see any boneheaded mistakes or have any suggestions? Thanks so much!

> import time
> import serial
>           
>       
> import time
> import serial
>           
>       
> ser = serial.Serial(             
>     port='/dev/ttyAMA0',
>     baudrate = 9600,
>     parity=serial.PARITY_NONE,
>     stopbits=serial.STOPBITS_ONE,
>     bytesize=serial.EIGHTBITS,
>     timeout=1
>      )
> 
>           
> 
> if ser.isOpen():
>     ser.close()
> ser.open()
> ser.isOpen()
> 
> ser.write("PWR OFF \r".encode())
> 
> out = ''
> # let's wait one second before reading output (let's give device time to answer)
> time.sleep(1)
> 
> while ser.inWaiting() > 0:
>     out += ser.read(40)
> 
> 
> if out != '':
>     print(">>" + out)
> 
> ser.close()

Can you get the projector to turn on outside of home-assistant? I did similar with a ViewSonic projector and a usb-serial adapter, I wound up just calling a pair of bash scripts, but if you can get this to work as a component, maybe you can help me get the ViewSonic working.

Good idea. I’ll have to order a usb to comm converter but it makes sense to try with pc first. By the way, I’m also cheating here. The code is python that I just plan to launch through HomeAssistant… had no success setting the projector up as a component. Thanks.

Are connected via SSH and launching from there? What set-up are you using software wise?

For now I’m launching the code via a putty connection to the pi… not using homeassistant at all. Running hassbian on pi.

here’s what i’m using, it may help you:
import serial

with serial.Serial('/dev/ttyUSB0', 19200, timeout=1) as ser:

        ser.write(b"\xBE\xEF\x10\x05\x00\xC6\xFF\x11\x11\x01\x00\x01\x00")

can you connect to something you know the serial settings for and see if you can get anything out of it? are you sure you need the wires crossed the way you have them?

To make things easy i just installed openhab 1.9 for this as it has a native component. Than control it via mqtt from home assistant. Get all kinds of stuff like lamp hours, color mode e.t.c

@moskovskiy82 it would be nice to get home-assistant native components for these things as often as possible.

Well can’t argue with that. But i’ve tried several python projects with no luck. So OH is a heavyweight alternative (takes up quite some resources) in case a more lightweight HA integrated solution doesn’t work

Haven’t tried but may be worth a try

Awesome… lots of stuff to try. I ordered some cables and a usb-rs232 adapter so that I can try communicating between pc and projector and also verify the rs-232 port on the pi. I’m also going to look into openHAB since it has native rs-232 support. Thanks everyone… I really appreciate all the help! I’ll update post when I finally have some level of success.

Just to share. Installed OH2 than via the paper ui added the epson binding and mqtt

Than into /etc/openhab2/services
add an epsonprojector.cfg with just one line

projector.serialPort=/dev/ttyUSB0

And to rule the stuff via the mqtt add the mqtt.cfg for broker and mqtt-eventbus.cfg (below)

#Broker name from mqtt.cfg
broker=xxx
statePublishTopic=/openhab/out/${item}/command
commandSubscribeTopic=/openhab/in/${item}/command

Than for the items

# cat default.items
Switch epsonPower                          { epsonprojector="projector:Power:60000" }
Switch epsonMute                           { epsonprojector="projector:Mute:ON,360000" }

String epsonColorMode           "ColorMode [%s]"                { epsonprojector="projector:ColorMode:ON,60000" }
Number epsonColorTemperature    "Color Temperature [%d]"        { epsonprojector="<projector:ColorTemperature:ON,160000" }
String epsonLuminance "Luminance [%s]"    { epsonprojector="projector:Luminance:ON,160000"}
Number epsonLampTime    "Lamp Time [%d h]"  <switch>       { epsonprojector="<projector:LampTime:ON,360000" }
Number epsonErrCode     "ErrCode [%d]"      <"siren-on">   { epsonprojector="<projector:ErrCode:ON,160000" }

In HA - example of sensor

- platform: mqtt
  name: "epson_luma"
  state_topic: "/openhab/out/epsonLuminance/command"

And example of a switch

  - platform: mqtt
    name: "epson_projector"
    command_topic: "/openhab/in/epsonPower/command"
    state_topic: "/openhab/out/epsonPower/command"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
1 Like

@txmarsh, seems you have some python code skills. Maybe look at this one to create a component?

There is a python lib here

So what i did is pip install pyjector
Than download the cli script https://github.com/JohnBrodie/pyjector/blob/master/pyjector_controller

Then adapt the benq.json to epson projector located below
/usr/local/lib/python2.7/dist-packages/pyjector/projector_configs# cp benq.json epson.json

Here is the handshake part


    "handshake": {
            "send": "\r",
            "wait": 1,
            "expect": ":"
    },
    "left_surround": "",
    "right_surround": "\r",
    "seperator": " ",
    "wait_time": 1,
    "command_failed_message": "*Block item#",
    "exception_message": "*Illegal format#",
    "serial": {
        "baudrate": 9600,
        "parity": "none",
        "stopbits": 1,
        "bytesize": 8
    },

And here is commands exmple for epson

"command_list": {
    "power": {
        "command": "PWR",
        "actions": {
            "on": "ON",
            "off": "OFF",
            "status": "?"
        }
    },

    "picture_mode": {
        "command": "CMODE",
        "actions": {
            "dynamic": "06",
            "cinema": "15",
            "status": "?"
        }

So everything works like this
./pyjector_controller epson -v "/dev/ttyUSB0" -v picture_mode dynamic

Can dump mem hungry OH2 now. But hopefully someone with programming skills can look into this and write a full blown projector component

Wow this is basically what I’m looking to do except using a rs-232 to IP converter. The skills to implement are a tad above my head. Yes it would be great if there were a component that was a little easier to implement. I miss having the epson control and info as I did in openhab.

Did you ever get further with this? I’m lost but would kind of like to do it without putting openhab into the mix.