Hardware for connecting an RS232 serial device to wifi

I’d like to control my BenQ X3100i projector using HASS. It doesn’t support network connections directly, and I’m not using the included streaming stick, so the RS232 serial port (DB9) seems like my best option.

Based on my research, I think a device running esp-link combined with @rrooggiieerr 's HACS integration will deliver the desired functionality. However, the extent of my knowledge in the electrical engineering space is just a few basic Arduino breadboard projects from a starter kit back in 2019. So this newbie would appreciate some guidance on hardware selection :slight_smile:

The description in @rrooggiieerr’s repo says I need a serial to TTL converter (perhaps this one?) plus a Wemos C3 mini. Will these two work together? How should I connect and power them? Is there a better, simpler option?

==EDIT==
For posterity, here are the steps to take:

  • In the BenQ projector settings, set baud rate to 9600
  • In esp-link, set baud rate to 9600
  • Wiring between the ESP-12F and the serial bridge is: TX to TX, RX to RX.
  • Assign a static local IP address to the esp-link device
  • In the HACS setup flow, select “network”, then enter the above static local IP address and port 23.

This may help:

Though you will have to change the serial commands to whatever your projector uses.

And yes that serial RS232-TTL converter is the one you want.

1 Like

Hardware arrived today:

I successfully flashed the ESP8266 with esp-link, then connected to its webserver and got it set up on my wifi. Assigned it a static IP address, and I’m able to ping it from within the container where HASS is running.

Connected the serial bridge’s RX pins to TX on the ESP, and vice versa for TX & RX. 5V and ground are both connected to the ESP. I can draw up a quick wiring diagram if necessary. The LED on the serial bridge lights up when everything is hooked up, so I assume that means it’s at least turning on okay.

So with everything hooked up, I aimed for the fence and … promptly struck out:

Not really seeing anything helpful in the esp-link debug logs. How do I troubleshoot this?

Check your homeassistant logs - that’ll probably have more information on why it can’t connect.

Connection refused. Wondering if that’s the connection to esp-link.

Logger: custom_components.benqprojector.config_flow
Source: custom_components/benqprojector/config_flow.py:163
integration: BenQ Projector (documentation, issues)
First occurred: 19:49:44 (7 occurrences)
Last logged: 20:10:18

Unexpected exception: [Errno 111] Connection refused
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/benqprojector/benqconnection.py", line 212, in open
    connection = telnetlib.Telnet(self._host, self._port, _TELNET_TIMEOUT)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/telnetlib.py", line 221, in __init__
    self.open(host, port, timeout)
  File "/usr/local/lib/python3.12/telnetlib.py", line 238, in open
    self.sock = socket.create_connection((host, port), timeout)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/socket.py", line 852, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/socket.py", line 837, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/benqprojector/config_flow.py", line 163, in async_step_setup_network
    info = await self.validate_input_setup_network(user_input, errors)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/benqprojector/config_flow.py", line 204, in validate_input_setup_network
    if not await self.hass.async_add_executor_job(projector.connect):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/benqprojector/benqprojector.py", line 264, in connect
    if not self._connect():
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/benqprojector/benqprojector.py", line 253, in _connect
    self._connection.open()
  File "/usr/local/lib/python3.12/site-packages/benqprojector/benqconnection.py", line 217, in open
    raise BenQConnectionError(str(ex)) from ex
benqprojector.benqconnection.BenQConnectionError: [Errno 111] Connection refused

Yes it is.


A bit confused about the 8000 here…is that a port number?

Esp-Link is hardcoded to use port 23 which is the default port for telnet.
You can also use the secondary port 2323. :thinking:

I have made the esp-link installer available on the web, and for my purposes i recompiled it to use port 23 and 2000 (as my application is stuck on 2000) :wink:

1 Like

The instructions say to enter the serial port and baud rate not an IP address.

It’s a bit confusing…It does describe how to set up a direct serial port, but not how to use a serial bridge…

However, it does seem to support it:

Home Assistant BenQ projector integration

Home Assistant integration that supports sending commands to BenQ projectors over the serial interface or serial to network bridges like esp-link.

PS, Searched some more and came up with these:

But I am not sure you can use socat on HAOS :thinking: PJLink shouldn’t be an issue though :wink:

@nickrout
It is very confusing, as his currernt configuration does seem to understand it needs to use a telnet connection :thinking:

So maybe it is either serial port + baudrate or ip-address + port ?

edit…just checked the source, and indeed it accept both serial port + baudrate as well as ip-address + port:

    conf_type = CONF_TYPE_SERIAL
    if CONF_TYPE in entry.data:
        conf_type = entry.data[CONF_TYPE]

    if conf_type == CONF_TYPE_TELNET:
        host = entry.data[CONF_HOST]
        port = entry.data[CONF_PORT]

        # Test if we can connect to the device.
        projector = BenQProjectorTelnet(host, port)

        # Open the connection.
        if not await hass.async_add_executor_job(projector.connect):
            raise ConfigEntryNotReady(f"Unable to connect to device {host}:{port}")
    else:
        serial_port = entry.data[CONF_SERIAL_PORT]
        baud_rate = entry.data[CONF_BAUD_RATE]

        # Test if we can connect to the device.
        try:
            projector = BenQProjectorSerial(serial_port, baud_rate)

So I guess if he changes the 8000 to 23 (or 2323), it should work :ok_hand:

That seems to make sense.

It also seems we miss the first screenshot :smiley:
image

With this one, everything makes sense :thinking:

Serial:
image

Network:
image

1 Like

Perhaps someone should submit a PR for the readme.

1 Like

I used your tool to flash esp-link! You made it very easy :slight_smile:

When ports are auto-filled, I typically defer to the default. When I get home I’ll try 23, then try 2323 if that fails. Fingers crossed :smiley:

Indeed, the instructions could use some clarification. Once I get everything settled here, I’ll submit a readme PR to clarify what’s needed for others in the future.

Hehe…that was they general idea behind it, good to know it works!!
:smiley:

if you are using mine the port are 23 and 2000 (i changed the port as the app i use is stuck on port 2000 )

Using port 23 got me a step further. It seems to have found esp-link but is now having issues connecting to the projector.

Logger: benqprojector.benqprojector
Source: /usr/local/lib/python3.12/site-packages/benqprojector/benqprojector.py:277
First occurred: 09:57:08 (4 occurrences)
Last logged: 10:01:17

Failed to get projector command prompt, is your projector properly connected?

I swapped the TX & RX pins, tried again, and got the same error. Same with trying port 2000. All attempts were made with the projector powered on.

i’ve read somewhere the projector’s network should be in standby mode

(whatever that means…i don’t have one)

and port 23 and 2000 are the same, so it doesn’t matter which one you use :wink:

Tried again with the projector in standby mode, same result:

Logger: benqprojector.benqprojector
Source: /usr/local/lib/python3.12/site-packages/benqprojector/benqprojector.py:277
First occurred: 09:57:08 (7 occurrences)
Last logged: 19:48:54

Failed to get projector command prompt, is your projector properly connected?

Here are my pin connections. I’ve tried swapping TX/RX on the 8266 with the same result:

In the esp-link settings, I enabled SLIP for serial connections and have MQTT disabled. Do I need MQTT enabled? What should I try next?

Sorry…can’t be of much further help here (as I don’t own a Benq Projector)

But I am pretty sure SLIP needs to be disabled; it only allows the board to initiate a connection.
And Benq uses a TelNet connection, initiated from HA.
Also MQTT is not used.

You could try some different GpIO settings:
image
These are for my ESP01-s, which I use with my PelletStove,
Not sure exactly what settings to use for your ESP12-F :thinking:

I disabled SLIP and tried again with the same results. I also attempted using each of the pre-set profiles, once with UART normal and once reversed.

I went through the projector settings again and couldn’t find anything about enabling or disabling RS232. Enabling the 12v trigger didn’t change anything, as expected.

All of this is with TX wired to esp RX, and RX wired to esp TX.

Kinda feels like I’m missing a step somewhere. Is there config I need to apply to the serial bridge uC? Or settings/config for esp-link that tells it how to communicate with the projector? Unplugging the uC from the 8266 yields the same error message I keep seeing in the HASS logs:

Failed to get projector command prompt, is your projector properly connected?

I’m drawing a blank on troubleshooting next steps. Any ideas?