Nodemcu momentary push button (gate)

why do you need UART if you only use pin D2?

Yesterday I had issues with UART and it was solved by either disabling logger or having logger at UART1:

logger:
  hardware_uart: UART1

See post: SDS011 or UART bug?