My main ESPHome configuration
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.
Some notes of caution:
RX
& TX
are pulled high at bootTX
is pulled lowTX
at the early boot stagesBecause of the notes of caution, I keep the following rules of thumb:
RX
for either in- or outputsTX
as data line and RX
as clock line; the data line will probably get some data at early boot stages but because the clock line is held high at boot, none of it will be clocked to the slaves.