I have an ESP32-based device that has two UART sensors on the same RX/TX pins via a bus switch chip. If a pin is high, the bus switch connects UART to sensor A, if low then sensor B. I currently have a working configuration that just sets the bus switch pin always high and only has configuration for sensor A.
Is it possible to have both sensors added to the configuration and have the firmware automatically set the bus switch pin appropriately when it wants to poll a sensor? I’ve looked through the list of Components in the documentation and I don’t see anything that would do this, but then I’m pretty new to ESPHome so I may be missing something obvious.
I’m confident it’s doable. You can poll the sensors “manually” with interval for example, switching the sensor before poll. For better suggestions, post specs of your hardware…
Thanks for the suggestion. What kind of specs would be helpful? This device is using the “ESP32-DEVKITC-32E” module. The two sensors connected to the UART line are the PMS5003 and the MH-Z19.
Config for the sensors:
Ran into another issue with component.update for the pmsx003:
ID ‘pmsx003a’ of type pmsx003::PMSX003Component doesn’t inherit from PollingComponent.
These devices are from an older project that originally ran custom firmware, so we just have to work with the existing hardware design wrt pin assignments. I’ve attached the full (redacted) config yaml below. You’ll notice there’s a slight difference to how I originally described it. The bus switch is controlled by two GPIO lines, one for enabling each UART sensor connection.