I'm working on a device that is connected to 2 serial ports (both TX and RX).The first serial port is connected to a CP2104 USB chip, the second serial port is left open with TX,RX,GND,3V pins.
I want to be able to switch between these 2 ports with some kind of analog switch/multiplexer and a mechanical switch but I cannot find a way to implement it. To summarize, the user would select between USB serial or header pin serial. Pseudo-schematic:
The MCU is an ESP8266, which has only one serial port. Whenever I send data via its serial header pins it doesnt receive anything because it is already connected to the CP2104 serial port, and I dont wat to use softwareserial since it is not reliable for WiFi applications.
I did some search and found these analog switches but don't know how to make a circuit with a mechanical switch so that I can change from one serial port to another. Any help or advice is appreciated
=========== EDIT 1 ============
I found a MUX/DEMUX analog switch used for switching between 2 USB(D+,D-) ports. I made a prototype circuit of what I'm trying to achieve with the mechanical slide switch. What do you think?
=========== EDIT 2 ============ Asked another question related to this topic: Is this analog switch good for UART lines?