Using UART pins as GPIO

My main ESPHome configuration

Using UART pins as GPIO

Most devices have a header containing GPIO pins for flashing and UART debugging (RX & TX). With some caution, these can also be used as GPIO pins. In general I wouldn’t prefer to use these pins but in some cases this is the only way of extending devices with extra sensors.

Because these pins are also used for sending & receiving UART commands, the first thing you need to do is disable UART logging. This can be done by adding the following to your yaml file:

logger:
  ...
  baud_rate: 0

After that, the RX & TX pins can be used both as in- or output GPIO pins.

Notes of caution

Some notes of caution:

Rules of thumb

Because of the notes of caution, I keep the following rules of thumb: