Esphome connect another device via serial is possible?

Hello, i have an esp32 devkit c4. I need to connect an external device via serial and control it through the esp32 via esphome but i cannot understand how to do this.

I have followed this guide:

I have wrote this on my device.yaml

uart:
id: uart_bus
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 115200

text_sensor:

  • platform: custom
    lambda: |-
    auto my_custom_sensor = new UartReadLineSensor(id(uart_bus));
    App.register_component(my_custom_sensor);
    return {my_custom_sensor};
    text_sensors:
    id: “uart_readline”

Now it seems to crash with this message:
[libprotobuf ERROR google/protobuf/wire_format_lite.cc:577] String field ‘SubscribeLogsResponse.message’ contains invalid UTF-8 data when parsing a protocol buffer. Use the ‘bytes’ type if you intend to send raw bytes.
Exception in thread Thread-1:
Traceback (most recent call last):
File “/usr/lib/python3.7/threading.py”, line 917, in _bootstrap_inner
self.run()
File “/opt/esphome/esphome/api/client.py”, line 408, in run
self._run_once()
File “/opt/esphome/esphome/api/client.py”, line 398, in _run_once
msg.ParseFromString(raw_msg)
google.protobuf.message.DecodeError: Error parsing message

Can anyone help me? For test i have connected an esp8266 tx rx to the gpio 17 and 16 of esp32

Please post your code properly

Yes - what Nick said. Have a read of this:

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371/3

Meanwhile - with that error message - I would suggest maybe your baud rate is incorrect.

Seems I have a similar issue. I am trying to read RS485 data that my ventilation system sends to its remote. I have connected it to ESP 32 via a MAX485 TTL converter (in RX mode). ESPhome Custom UART Text Sensor code is copy-pasted from the esphome.io.

Can this error be caused by a baud rate? Is there a way to figure out the correct baud rate?