Change uart pins for logger

Hi, I’m running into strange issues with esphome on an esp32-s2 where the esp resets, doesn’t reconnect or just hangs.
To troubleshoot this I would like to attach a ftdi to the esp. I’ve tried using the usb port, but the port is being disconnected upon resets and I’m missing information then.
I would like to change the pins of the logger UART so they are on over of the pins brought out of the esp32. How can I achieve that?

Have you looked at the docs - specifically this table?

Yes, I did indeed. This table shows how to change the UART used for the logger, but nowhere how to change the pins used for the UART.

I suspect the only way is to fork your own version of one or more components (like the logger) and do it in code.

Thanks for your suggestion. This made me think of using a lambda function to initialise the UART with the pins I want to use. Have to figure out how still, if someone has a suggestion they are welcome!

For anyone having the same question in the future, this is how is solved it.

esphome:
  ...
  on_boot:
    priority: 800.0
    then:
      lambda: |-
        uart_set_pin(UART_NUM_0, 18, 33, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);

logger:
  baud_rate: 115200
  hardware_uart: UART0
1 Like

There seems to have been an API change. I used this:

uartSetPins(0, 20, 21, -1, -1);

I’m using an esp32c3 supermini. Maybe that’s why the constants UART_NUM_0 and UART_PIN_NO_CHANGE were not available. -1 means don’t change, I assigned pins 20 and 21 to UART 0.

For anybody with future issues, I used this to troubleshoot (remotely) an esp that was crashing.