Weird Technology

A blog on technology

Creating a Serial to WiFi bridge

I’m getting more and more requests to implement network control for my Home Assistant BenQ Projector integration. The network control of the BenQ projectors seems to be just a telnet connection running on TCP/IP port 8000 and the same commands as used over the serial connection should work over the network connection. This shouldn’t be to difficult to implement. However I don’t own a network connected projector and have thus not implemented any network functionality, yet. A simple RS-232 to WiFi module and some software should be enough to simulate the existence of a network connection on my projector.

Hardware considerations

To build my Serial to WiFi bridge I used a generic RS-232 to TTL converter from AliExpress and a Wemos C3 mini. The form factor of the Wemos fits the RS-232 to TTL converter very nicely.

The ESP32 on the Wemos supports multiple hardware serial connections so I can leave the original serial connection in place for debugging purposes. The ESP8266 only supports multiple serial connections using a software library and I found out this does not work well with higher baud rates on the secondary serial connection.

I’m using the v1.0.0 of the Wemos C3 mini which has a design flaw of the antenna and needs some extra software setting to make this work reliably. It is better to use the updated v2.1.0 which has this issue fixed.

Building the module

I desoldered the pins from the RS-232 to TTL converter to wire the two devices directly and create a smaller packaged end product. The RS-232 to TTL converter will be powered by the Wemos C3 mini directly and thus does not need it’s own power supply. The Wemos C3 mini will then be powered over USB.

I wired the two devices as follows:

RS323 to TTL converterWemos C3 mini
GNDGND
TXDGPIO 10
RXDGPIO 8
VCCVBUS

With some hot glue I sandwiched the Wemos C3 mini on top of the RS-232 connector to create a small packaged module. Only the antenna of the Wemos C3 mini sticks out, and that probably is a good thing.

The software

For the software I have considered the ESP-Link firmware and ESPHome with the very nice ESPHome Stream Server external component. I went for the later.

esphome:
  name: rs232-bridge
  friendly_name: RS-232 Bridge
  comment: "RS-232 to WiFi bridge"
  platformio_options:
    board_build.flash_mode: dio

external_components:
  # This external component does the magic to bridge the RS-232 to TCP/IP.
  - source: github://oxan/esphome-stream-server

esp32:
  board: lolin_c3_mini
  variant: esp32c3
  framework:
    type: esp-idf

# Enable logging
# logger:
#   baud_rate: 115200
#   level: DEBUG

# Enable Home Assistant API
api:
  encryption:
    # Your Home Assistant encryption key goes here.
    key: "..."

ota:
  password: "..."

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # This is needed to fix the antenna issues on the v1.0.0 of the Wemos C3 mini
  output_power: 8.5

uart:
  tx_pin: GPIO8
  rx_pin: GPIO10
  # The speed as defined in your BenQ projector
  baud_rate: 115200
  id: rs232_uart
  # You can have the serial commands being output to the debugging console
  # debug:
  #   after:
  #     delimiter: "\r\n"
  #   sequence:
  #     - lambda: UARTDebug::log_string(direction, bytes);

stream_server:
  uart_id: rs232_uart
  # Port 8000 to simulate the BenQ network connection
  port: 8000
Code language: YAML (yaml)

Security

It should be noted that the network connection to this RS-232 to WiFi bridge is not encrypted or secured by a password. Anyone with access to the same network where the RS-232 to WiFi bridge is connected to, and with the right knowledge, can send instructions to the projector connected to the RS-232 to WiFi bridge. This is also the case for the original network connection on the BenQ projector. It is more safe to run a separate network for your networked BenQ projector or your IoT devices in general.

End result

The finished product fits nicely on the back of my BenQ projector and can be powered by the USB A port also available there, however not when the projector is turned off. For me that is good enough to be able to work on the support of network controll of the Home Assistant BenQ Projector integration.

Comments

Leave a Reply

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