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

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


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

Now it seems to crash with this message:
[libprotobuf ERROR google/protobuf/] 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/”, line 917, in _bootstrap_inner
File “/opt/esphome/esphome/api/”, line 408, in run
File “/opt/esphome/esphome/api/”, line 398, in _run_once
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:

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

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