-
Notifications
You must be signed in to change notification settings - Fork 5
Description
The original author uses the Faikin premade board which inverts the RX pin (presumably in order to do level shifting).
Independent control of the UART line polarity is supported by the ESP32 and the ESP-IDF PlatformIO framework, but not Arduino.
Under ESP-IDF, ESPHome will apply the invert
configuration from the pin schema settings to the UART driver. The Arduino API doesn't support this:
- ESPHome Pin Configuration https://esphome.io/guides/configuration-types.html#pin-schema
- ESPHome ESP-IDF UART driver https://github.com/esphome/esphome/blob/c17a3b6fccb5ea0b782ef06cc6c9508702ec471e/esphome/components/uart/uart_component_esp_idf.cpp#L110
- ESP-IDF UART driver https://github.com/espressif/esp-idf/blob/8f224d6a637fb02261f886e3bdebd80432cb38cc/components/esp_driver_uart/src/uart.c#L403C11-L403C32
- ESPHome Arduino UART driver https://github.com/esphome/esphome/blob/c17a3b6fccb5ea0b782ef06cc6c9508702ec471e/esphome/components/uart/uart_component_esp32_arduino.cpp#L137
- Arduino UART driver https://github.com/espressif/arduino-esp32/blob/422e52684b824a3fde85989ea90abf6624f2b0eb/cores/esp32/esp32-hal-uart.c#L544
- note that it's all or nothing
I've opened a pull request to the Arduino project to provide a way to add independent control code for the ESPHome Arduino driver: espressif/arduino-esp32#11428
When that merges and the release is integrated into PlatformIO, I will update ESPHome's driver so the two frameworks have feature parity. Once ESPHome integrates that change, I can remove the special dual UART code in this component and add documentation on how to invert a pin using the ESPHome config YAML.